From 44f075bae40a7933d600b47b93442f7695efd2f6 Mon Sep 17 00:00:00 2001 From: Thiago Araujo Date: Wed, 19 Nov 2025 21:05:29 -0700 Subject: [PATCH] Add tests to `regexp_encoding_option_mismatch` related to #2667 --- test/prism/errors_test.rb | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/test/prism/errors_test.rb b/test/prism/errors_test.rb index 9abed92652..bd7a8a6381 100644 --- a/test/prism/errors_test.rb +++ b/test/prism/errors_test.rb @@ -64,6 +64,24 @@ def test_invalid_message_name assert_equal :"", Prism.parse_statement("+.@foo,+=foo").write_name end + def test_regexp_encoding_option_mismatch_error + # UTF-8 char with ASCII-8BIT modifier + result = Prism.parse('/Ȃ/n') + assert_includes result.errors.map(&:type), :regexp_encoding_option_mismatch + + # UTF-8 char with EUC-JP modifier + result = Prism.parse('/Ȃ/e') + assert_includes result.errors.map(&:type), :regexp_encoding_option_mismatch + + # UTF-8 char with Windows-31J modifier + result = Prism.parse('/Ȃ/s') + assert_includes result.errors.map(&:type), :regexp_encoding_option_mismatch + + # UTF-8 char with UTF-8 modifier + result = Prism.parse('/Ȃ/u') + assert_empty result.errors + end + private def assert_errors(filepath, version)