Skip to content

Commit ec4178b

Browse files
authored
Merge pull request #3735 from hexdevs/ta/add-test-to-regexp-encoding-mismatch-error-2667
Add tests to `regexp_encoding_option_mismatch`
2 parents 297b708 + 44f075b commit ec4178b

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

test/prism/errors_test.rb

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,24 @@ def test_invalid_message_name
6464
assert_equal :"", Prism.parse_statement("+.@foo,+=foo").write_name
6565
end
6666

67+
def test_regexp_encoding_option_mismatch_error
68+
# UTF-8 char with ASCII-8BIT modifier
69+
result = Prism.parse('/Ȃ/n')
70+
assert_includes result.errors.map(&:type), :regexp_encoding_option_mismatch
71+
72+
# UTF-8 char with EUC-JP modifier
73+
result = Prism.parse('/Ȃ/e')
74+
assert_includes result.errors.map(&:type), :regexp_encoding_option_mismatch
75+
76+
# UTF-8 char with Windows-31J modifier
77+
result = Prism.parse('/Ȃ/s')
78+
assert_includes result.errors.map(&:type), :regexp_encoding_option_mismatch
79+
80+
# UTF-8 char with UTF-8 modifier
81+
result = Prism.parse('/Ȃ/u')
82+
assert_empty result.errors
83+
end
84+
6785
private
6886

6987
def assert_errors(filepath, version)

0 commit comments

Comments
 (0)