Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions test/prism/errors_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should this test be added to prism/encoding/regular_expression_encoding_test.rb instead?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's fine here.

private

def assert_errors(filepath, version)
Expand Down