summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorTakashi Kokubun <takashikkbn@gmail.com>2020-10-19 20:56:08 -0700
committerTakashi Kokubun <takashikkbn@gmail.com>2020-10-19 20:56:09 -0700
commit4a7dccf44f02fa471e848ec729393c257b97da4d (patch)
treea3acf85f9954d88fbd4f7f076384f733e116799e /test
parenta76a30724dfdfd26938960d2f756b4d97f8d855e (diff)
Add a Ripper.lex test of :on_embexpr_end
This is a weird use case of Ripper.lex which I'm not sure is supposed to be maintained, so I'm adding this test so that we can easily notice such changes. If we change the behavior, this will break the behavior of hamlit.gem v1 and code like https://github.com/haml/haml/pull/1043.
Diffstat (limited to 'test')
-rw-r--r--test/ripper/test_lexer.rb7
1 files changed, 7 insertions, 0 deletions
diff --git a/test/ripper/test_lexer.rb b/test/ripper/test_lexer.rb
index 1794773d89..3fc44234b9 100644
--- a/test/ripper/test_lexer.rb
+++ b/test/ripper/test_lexer.rb
@@ -138,4 +138,11 @@ class TestRipper::Lexer < Test::Unit::TestCase
assert_equal pos, code.bytesize
assert_equal expected.size, result.size
end
+
+ def test_trailing_on_embexpr_end
+ # This is useful for scanning a template engine literal `{ foo, bar: baz }`
+ # whose body inside brackes works like trailing method arguments, like Haml.
+ token = Ripper.lex("a( foo, bar: baz }").last
+ assert_equal [[1, 17], :on_embexpr_end, "}", state(:EXPR_ARG)], token
+ end
end