@@ -463,39 +463,24 @@ defmodule EExTest do
463
463
end
464
464
end
465
465
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
480
467
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\) /
482
469
483
470
assert_raise EEx.SyntaxError , msg , fn ->
484
- EEx . compile_string ( "<%/ true %>" )
471
+ EEx . compile_string ( "<%| true %>" )
485
472
end
486
473
end
487
474
488
- test "when trying to use marker '| ' without implementation" do
475
+ test "when trying to use marker '/ ' without implementation" do
489
476
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\) /
491
478
492
479
assert_raise EEx.SyntaxError , msg , fn ->
493
- EEx . compile_string ( "<%| true %>" )
480
+ EEx . compile_string ( "<%/ true %>" )
494
481
end
495
482
end
496
- end
497
483
498
- describe "error messages" do
499
484
test "honor line numbers" do
500
485
assert_raise EEx.SyntaxError ,
501
486
"nofile:100:6: expected closing '%>' for EEx expression" ,
@@ -516,18 +501,30 @@ defmodule EExTest do
516
501
EEx . compile_string ( "foo <%= bar" , file: "my_file.eex" )
517
502
end
518
503
end
504
+ end
519
505
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
527
512
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"
531
528
end
532
529
end
533
530
0 commit comments