summaryrefslogtreecommitdiff
path: root/test/prism/regexp_test.rb
diff options
context:
space:
mode:
authoreileencodes <[email protected]>2023-10-17 13:13:37 -0400
committergit <[email protected]>2023-10-17 17:50:38 +0000
commit5a3e8d2f187d54f336090c438ad9a202f137373a (patch)
treefc2450d22987db486e33d1e3ab0378e76fc47f84 /test/prism/regexp_test.rb
parentd458b4127f1815e76774cb7c3c23b7c31dfd54bc (diff)
[ruby/prism] Ensure last encoding flag wins
You can't encoding a string with more than one encoding so ensure that the last one wins. https://github.com/ruby/prism/commit/4182c988c9
Diffstat (limited to 'test/prism/regexp_test.rb')
-rw-r--r--test/prism/regexp_test.rb12
1 files changed, 12 insertions, 0 deletions
diff --git a/test/prism/regexp_test.rb b/test/prism/regexp_test.rb
index 67114c7bf3..0a5fc2b4fc 100644
--- a/test/prism/regexp_test.rb
+++ b/test/prism/regexp_test.rb
@@ -227,6 +227,18 @@ module Prism
assert_equal(value, options("mix"))
end
+ def test_last_encoding_option_wins
+ regex = "/foo/nu"
+ option = Prism.parse(regex).value.statements.body.first.options
+
+ assert_equal Regexp::FIXEDENCODING, option
+
+ regex = "/foo/un"
+ option = Prism.parse(regex).value.statements.body.first.options
+
+ assert_equal Regexp::NOENCODING, option
+ end
+
private
def named_captures(source)