Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix a runtime warning for ambiguous /; wrap regexp in parentheses or add a space after / operator #1438

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
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
64 changes: 32 additions & 32 deletions test/cli_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ def test_jobs_count
stdout, status = sh(*steep, command, *args)

assert_predicate status, :success?, stdout
assert_match /No type error detected\./, stdout
assert_match(/No type error detected\./, stdout)
end
end
sub_test.call("check", %w(-j 1))
Expand Down Expand Up @@ -83,7 +83,7 @@ def test_steep_command_option
end

assert_predicate status, :success?, stdout
assert_match /No type error detected\./, stdout
assert_match(/No type error detected\./, stdout)
end
end

Expand All @@ -102,7 +102,7 @@ def test_check_success
stdout, status = sh(*steep, "check")

assert_predicate status, :success?, stdout
assert_match /No type error detected\./, stdout
assert_match(/No type error detected\./, stdout)
end
end

Expand All @@ -121,7 +121,7 @@ def test_check_failure
stdout, status = sh(*steep, "check")

refute_predicate status, :success?, stdout
assert_match /Detected 1 problem from 1 file/, stdout
assert_match(/Detected 1 problem from 1 file/, stdout)
end
end

Expand Down Expand Up @@ -253,10 +253,10 @@ def test_check_failure_severity_level
stdout, status = sh(*steep, "check", "--severity-level=warning")

refute_predicate status, :success?, stdout
assert_match /Detected 1 problem from 1 file/, stdout
assert_match(/Detected 1 problem from 1 file/, stdout)

assert_match /Ruby::NoMethod/, stdout
refute_match /Ruby::UnresolvedOverloading/, stdout
assert_match(/Ruby::NoMethod/, stdout)
refute_match(/Ruby::UnresolvedOverloading/, stdout)
end
end

Expand All @@ -274,11 +274,11 @@ def test_check_expectations_success

stdout, status = sh(*steep, "check", "--save-expectation=foo.yml")
assert_predicate status, :success?
assert_match /Saved expectations in foo\.yml\.\.\./, stdout
assert_match(/Saved expectations in foo\.yml\.\.\./, stdout)

stdout, status = sh(*steep, "check", "--with-expectation=foo.yml")
assert_predicate status, :success?
assert_match /Expectations satisfied:/, stdout
assert_match(/Expectations satisfied:/, stdout)
end
end

Expand All @@ -299,7 +299,7 @@ def test_check_expectations_lineno_changed

stdout, status = sh(*steep, "check", "--save-expectation=foo.yml")
assert_predicate status, :success?, stdout
assert_match /Saved expectations in foo\.yml\.\.\./, stdout
assert_match(/Saved expectations in foo\.yml\.\.\./, stdout)

(current_dir + "foo.rb").write(<<-EOF)
1 + "2"
Expand All @@ -308,10 +308,10 @@ def test_check_expectations_lineno_changed
stdout, status = sh(*steep, "check", "--with-expectation=foo.yml")
refute_predicate status, :success?, stdout

assert_match /Expectations unsatisfied:/, stdout
assert_match /0 expected diagnostics/, stdout
assert_match /1 unexpected diagnostic/, stdout
assert_match /1 missing diagnostic/, stdout
assert_match(/Expectations unsatisfied:/, stdout)
assert_match(/0 expected diagnostics/, stdout)
assert_match(/1 unexpected diagnostic/, stdout)
assert_match(/1 missing diagnostic/, stdout)
end
end

Expand All @@ -329,7 +329,7 @@ def test_check_expectations_fail

stdout, status = sh(*steep, "check", "--save-expectation=foo.yml")
assert_predicate status, :success?, stdout
assert_match /Saved expectations in foo\.yml\.\.\./, stdout
assert_match(/Saved expectations in foo\.yml\.\.\./, stdout)

(current_dir + "foo.rb").write(<<-EOF)
1 + 2
Expand All @@ -338,10 +338,10 @@ def test_check_expectations_fail
stdout, status = sh(*steep, "check", "--with-expectation=foo.yml")
refute_predicate status, :success?, stdout

assert_match /Expectations unsatisfied:/, stdout
assert_match /0 expected diagnostics/, stdout
assert_match /0 unexpected diagnostics/, stdout
assert_match /1 missing diagnostic/, stdout
assert_match(/Expectations unsatisfied:/, stdout)
assert_match(/0 expected diagnostics/, stdout)
assert_match(/0 unexpected diagnostics/, stdout)
assert_match(/1 missing diagnostic/, stdout)
end
end

Expand All @@ -363,7 +363,7 @@ def test_check_expectations_fail2

stdout, status = sh(*steep, "check", "--save-expectation")
assert_predicate status, :success?, stdout
assert_match /Saved expectations in steep_expectations\.yml\.\.\./, stdout
assert_match(/Saved expectations in steep_expectations\.yml\.\.\./, stdout)

(current_dir + "foo.rb").write(<<-EOF)
1 + 2
Expand All @@ -372,16 +372,16 @@ def test_check_expectations_fail2
stdout, status = sh(*steep, "check", "--with-expectation", "foo.rb")
refute_predicate status, :success?, stdout

assert_match /Expectations unsatisfied:/, stdout
assert_match /0 expected diagnostics/, stdout
assert_match /0 unexpected diagnostics/, stdout
assert_match /1 missing diagnostic/, stdout
assert_match(/Expectations unsatisfied:/, stdout)
assert_match(/0 expected diagnostics/, stdout)
assert_match(/0 unexpected diagnostics/, stdout)
assert_match(/1 missing diagnostic/, stdout)

stdout, status = sh(*steep, "check", "--with-expectation", "bar.rb")
assert_predicate status, :success?, stdout

assert_match /Expectations satisfied:/, stdout
assert_match /1 expected diagnostic/, stdout
assert_match(/Expectations satisfied:/, stdout)
assert_match(/1 expected diagnostic/, stdout)
end
end

Expand Down Expand Up @@ -420,7 +420,7 @@ def test_check_broken

stdout, status = sh(*steep, "check")
refute_predicate status, :success?, stdout
assert_match /Syntax error: cannot start a declaration, token=/, stdout.force_encoding(Encoding::ASCII_8BIT)
assert_match(/Syntax error: cannot start a declaration, token=/, stdout.force_encoding(Encoding::ASCII_8BIT))
end
end

Expand Down Expand Up @@ -448,9 +448,9 @@ def test_check_no_steepfile
stdout, stderr, status = sh3(*steep, 'check')

assert_predicate status, :success?, stdout
assert_match /current directory/, stderr
assert_match /steep init/, stderr
assert_match /No type error detected\./, stdout
assert_match(/current directory/, stderr)
assert_match(/steep init/, stderr)
assert_match(/No type error detected\./, stdout)
end
end

Expand Down Expand Up @@ -788,14 +788,14 @@ def test_ci_jobs_setup_message
["check", "checkfile", "stats"].each do |command|
_, stderr, status = sh3(*steep, command, "foo.rb")
assert_predicate status, :success?
assert_match /CI environment is detected but no `--jobs` option is given./, stderr
assert_match(/CI environment is detected but no `--jobs` option is given./, stderr)
end

["check", "checkfile", "stats"].each do |command|
_, stderr, status = sh3(*steep, command, "--jobs=1", "foo.rb")

assert_predicate status, :success?
refute_match /CI environment is detected but no `--jobs` option is given./, stderr
refute_match(/CI environment is detected but no `--jobs` option is given./, stderr)
end
end
end
Expand Down
18 changes: 9 additions & 9 deletions test/driver_helper_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ def test_load_config_successful__no_collection_file__no_configuration
RUBY

Test.new.load_config(path: path)
refute_match /rbs collection install/, Steep.log_output.string
refute_match(/rbs collection install/, Steep.log_output.string)
end
end

Expand All @@ -52,7 +52,7 @@ def test_load_config_successful__collection_disabled
RUBY

Test.new.load_config(path: path)
refute_match /rbs collection install/, Steep.log_output.string
refute_match(/rbs collection install/, Steep.log_output.string)
end
end

Expand All @@ -66,7 +66,7 @@ def test_load_config_error__collection_file_missing
RUBY

Test.new.load_config(path: path)
assert_match /rbs-collection configuration is missing/, Steep.log_output.string
assert_match(/rbs-collection configuration is missing/, Steep.log_output.string)
end
end

Expand All @@ -81,7 +81,7 @@ def test_load_config_error__lock_file_missing
current_dir.join("test.yaml").write("[]")

Test.new.load_config(path: path)
assert_match /rbs collection install/, Steep.log_output.string
assert_match(/rbs collection install/, Steep.log_output.string)
end
end

Expand All @@ -97,8 +97,8 @@ def test_load_config_error__lock_file_is_broken
current_dir.join("test.lock.yaml").write("[")

Test.new.load_config(path: path)
assert_match /rbs-collection setup is broken:/, Steep.log_output.string
assert_match /syntax error/, Steep.log_output.string
assert_match(/rbs-collection setup is broken:/, Steep.log_output.string)
assert_match(/syntax error/, Steep.log_output.string)
end
end

Expand Down Expand Up @@ -138,7 +138,7 @@ def test_load_config__install_from_lockfile

Test.new.load_config(path: path)

assert_match /Installing RBS files for collection: /, Steep.log_output.string
assert_match(/Installing RBS files for collection: /, Steep.log_output.string)
end
end

Expand Down Expand Up @@ -180,7 +180,7 @@ def test_load_config__install_from_lockfile__disabled
test.disable_install_collection = true
test.load_config(path: path)

assert_match /rbs collection install/, Steep.log_output.string
assert_match(/rbs collection install/, Steep.log_output.string)
end
end

Expand Down Expand Up @@ -221,7 +221,7 @@ def test_load_config__install_from_lockfile__failure
test = Test.new
test.load_config(path: path)

assert_match /Failed to set up RBS collection:/, Steep.log_output.string
assert_match(/Failed to set up RBS collection:/, Steep.log_output.string)
end
end
end
2 changes: 1 addition & 1 deletion test/subtyping_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1064,7 +1064,7 @@ def f: (String) -> String
assert_fail_check checker, "::_A", "::_C" do |result|
assert_instance_of Failure::UnsatisfiedConstraints, result.error

assert_match /X\(\d+\)/, result.error.var.to_s
assert_match(/X\(\d+\)/, result.error.var.to_s)
assert_equal parse_type("::String", checker: checker), result.error.sub_type
assert_equal parse_type("::Numeric & ::String", checker: checker), result.error.super_type
end
Expand Down
2 changes: 1 addition & 1 deletion test/type_construction_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7049,7 +7049,7 @@ class Method
assert_typing_error typing, size: 1 do |errors|
assert_any!(errors) do |error|
assert_instance_of Diagnostic::Ruby::BlockTypeMismatch, error
assert /^\^\(::Integer\) -> X\(\d+\)$/ =~ error.expected.to_s
assert (/^\^\(::Integer\) -> X\(\d+\)$/ =~ error.expected.to_s)
assert_equal parse_type("^(::String) -> ::String"), error.actual
end
end
Expand Down