@@ -463,39 +463,24 @@ defmodule EExTest do
463463 end
464464 end
465465
466- test "when middle expression has a modifier" do
467- assert ExUnit.CaptureIO . capture_io ( :stderr , fn ->
468- EEx . compile_string ( "foo <%= if true do %>true<%= else %>false<% end %>" )
469- end ) =~ ~s[ unexpected beginning of EEx tag \" <%=\" on \" <%= else %>\" ]
470- end
471-
472- test "when end expression has a modifier" do
473- assert ExUnit.CaptureIO . capture_io ( :stderr , fn ->
474- EEx . compile_string ( "foo <%= if true do %>true<% else %>false<%= end %>" )
475- end ) =~
476- ~s[ unexpected beginning of EEx tag \" <%=\" on \" <%= end %>\" ]
477- end
478-
479- test "when trying to use marker '/' without implementation" do
466+ test "when trying to use marker '|' without implementation" do
480467 msg =
481- ~r/ unsupported EEx syntax <%\/ %> \( the syntax is valid but not supported by the current EEx engine\) /
468+ ~r/ unsupported EEx syntax <%| %> \( the syntax is valid but not supported by the current EEx engine\) /
482469
483470 assert_raise EEx.SyntaxError , msg , fn ->
484- EEx . compile_string ( "<%/ true %>" )
471+ EEx . compile_string ( "<%| true %>" )
485472 end
486473 end
487474
488- test "when trying to use marker '| ' without implementation" do
475+ test "when trying to use marker '/ ' without implementation" do
489476 msg =
490- ~r/ unsupported EEx syntax <%| %> \( the syntax is valid but not supported by the current EEx engine\) /
477+ ~r/ unsupported EEx syntax <%\/ %> \( the syntax is valid but not supported by the current EEx engine\) /
491478
492479 assert_raise EEx.SyntaxError , msg , fn ->
493- EEx . compile_string ( "<%| true %>" )
480+ EEx . compile_string ( "<%/ true %>" )
494481 end
495482 end
496- end
497483
498- describe "error messages" do
499484 test "honor line numbers" do
500485 assert_raise EEx.SyntaxError ,
501486 "nofile:100:6: expected closing '%>' for EEx expression" ,
@@ -516,18 +501,30 @@ defmodule EExTest do
516501 EEx . compile_string ( "foo <%= bar" , file: "my_file.eex" )
517502 end
518503 end
504+ end
519505
520- test "when <%!-- is not closed" do
521- message = """
522- my_file.eex:1:5: expected closing '--%>' for EEx expression
523- |
524- 1 | foo <%!-- bar
525- | ^\
526- """
506+ describe "warnings" do
507+ test "when middle expression has a modifier" do
508+ assert ExUnit.CaptureIO . capture_io ( :stderr , fn ->
509+ EEx . compile_string ( "foo <%= if true do %>true<%= else %>false<% end %>" )
510+ end ) =~ ~s[ unexpected beginning of EEx tag \" <%=\" on \" <%= else %>\" ]
511+ end
527512
528- assert_raise EEx.SyntaxError , message , fn ->
529- EEx . compile_string ( "foo <%!-- bar" , file: "my_file.eex" )
530- end
513+ test "when end expression has a modifier" do
514+ assert ExUnit.CaptureIO . capture_io ( :stderr , fn ->
515+ EEx . compile_string ( "foo <%= if true do %>true<% else %>false<%= end %>" )
516+ end ) =~
517+ ~s[ unexpected beginning of EEx tag \" <%=\" on \" <%= end %>\" ]
518+ end
519+
520+ test "from tokenizer" do
521+ warning =
522+ ExUnit.CaptureIO . capture_io ( :stderr , fn ->
523+ EEx . compile_string ( ~s' <%= :"foo" %>' , file: "tokenizer.ex" )
524+ end )
525+
526+ assert warning =~ "found quoted atom \" foo\" but the quotes are not required"
527+ assert warning =~ "tokenizer.ex:1:5"
531528 end
532529 end
533530
0 commit comments