summaryrefslogtreecommitdiff
path: root/test/prism/result/warnings_test.rb
diff options
context:
space:
mode:
Diffstat (limited to 'test/prism/result/warnings_test.rb')
-rw-r--r--test/prism/result/warnings_test.rb23
1 files changed, 12 insertions, 11 deletions
diff --git a/test/prism/result/warnings_test.rb b/test/prism/result/warnings_test.rb
index 504458e178..fa87295898 100644
--- a/test/prism/result/warnings_test.rb
+++ b/test/prism/result/warnings_test.rb
@@ -336,23 +336,24 @@ module Prism
def test_shebang_ending_with_carriage_return
msg = "shebang line ending with \\r may cause problems"
- assert_warning(<<~RUBY, msg, compare: false)
+ assert_warning(<<~RUBY, msg, compare: false, main_script: true)
#!ruby\r
p(123)
RUBY
- assert_warning(<<~RUBY, msg, compare: false)
+ assert_warning(<<~RUBY, msg, compare: false, main_script: true)
#!ruby \r
p(123)
RUBY
- assert_warning(<<~RUBY, msg, compare: false)
+ assert_warning(<<~RUBY, msg, compare: false, main_script: true)
#!ruby -Eutf-8\r
p(123)
RUBY
- # Used with the `-x` object, to ignore the script up until the first shebang that mentioned "ruby".
- assert_warning(<<~SCRIPT, msg, compare: false)
+ # Used with the `-x` object, to ignore the script up until the first
+ # shebang that mentioned "ruby".
+ assert_warning(<<~SCRIPT, msg, compare: false, main_script: true)
#!/usr/bin/env bash
# Some initial shell script or other content
# that Ruby should ignore
@@ -364,11 +365,11 @@ module Prism
puts "Hello from Ruby!"
SCRIPT
- refute_warning("#ruby not_a_shebang\r\n", compare: false)
+ refute_warning("#ruby not_a_shebang\r\n", compare: false, main_script: true)
- # CRuby doesn't emit the warning if a malformed file only has `\r` and not `\n`.
- # https://bugs.ruby-lang.org/issues/20700
- refute_warning("#!ruby\r", compare: false)
+ # CRuby doesn't emit the warning if a malformed file only has `\r` and
+ # not `\n`. https://bugs.ruby-lang.org/issues/20700.
+ refute_warning("#!ruby\r", compare: false, main_script: true)
end
end
@@ -384,8 +385,8 @@ module Prism
private
- def assert_warning(source, *messages, compare: true)
- warnings = Prism.parse(source).warnings
+ def assert_warning(source, *messages, compare: true, **options)
+ warnings = Prism.parse(source, **options).warnings
assert_equal messages.length, warnings.length, "Expected #{messages.length} warning(s) in #{source.inspect}, got #{warnings.map(&:message).inspect}"
warnings.zip(messages).each do |warning, message|