Skip to content
Merged
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
10 changes: 10 additions & 0 deletions test/parse_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,8 @@ def assert_source_range(expect_range, range, version, what)
# )
# ~~~
def assert_parses(ast, code, source_maps='', versions=ALL_VERSIONS)
refute_operator(versions, :empty?)

with_versions(versions) do |version, parser|
try_parsing(ast, code, parser, source_maps, version)
end
Expand Down Expand Up @@ -160,6 +162,8 @@ def try_parsing(ast, code, parser, source_maps, version)
# | ~~~ highlights (0)})
# ~~~
def assert_diagnoses(diagnostic, code, source_maps='', versions=ALL_VERSIONS)
refute_operator(versions, :empty?)

with_versions(versions) do |version, parser|
source_file = Parser::Source::Buffer.new('(assert_diagnoses)', source: code)

Expand Down Expand Up @@ -217,6 +221,8 @@ def assert_diagnoses(diagnostic, code, source_maps='', versions=ALL_VERSIONS)
# SINCE_2_4)
# ~~~
def assert_diagnoses_many(diagnostics, code, versions=ALL_VERSIONS)
refute_operator(versions, :empty?)

with_versions(versions) do |version, parser|
source_file = Parser::Source::Buffer.new('(assert_diagnoses_many)', source: code)

Expand All @@ -242,6 +248,8 @@ def assert_diagnoses_many(diagnostics, code, versions=ALL_VERSIONS)
end

def refute_diagnoses(code, versions=ALL_VERSIONS)
refute_operator(versions, :empty?)

with_versions(versions) do |version, parser|
source_file = Parser::Source::Buffer.new('(refute_diagnoses)', source: code)

Expand All @@ -258,6 +266,8 @@ def refute_diagnoses(code, versions=ALL_VERSIONS)
end

def assert_context(context, code, versions=ALL_VERSIONS)
refute_operator(versions, :empty?)

with_versions(versions) do |version, parser|
source_file = Parser::Source::Buffer.new('(assert_context)', source: code)

Expand Down
10 changes: 5 additions & 5 deletions test/test_parser.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2239,15 +2239,15 @@ def test_arg_scope
s(:lvar, :var)),
%q{def f(var = defined?(var)) var end},
%q{},
SINCE_2_7 - SINCE_2_1)
SINCE_2_1 - SINCE_2_7)

assert_parses(
s(:def, :f,
s(:args, s(:kwoptarg, :var, s(:defined?, s(:lvar, :var)))),
s(:lvar, :var)),
%q{def f(var: defined?(var)) var end},
%q{},
SINCE_2_7 - SINCE_2_1)
SINCE_2_1 - SINCE_2_7)

assert_parses(
s(:block,
Expand Down Expand Up @@ -5721,7 +5721,7 @@ def test_regexp_encoding
s(:str, "")),
%q{/\xa8/n =~ ""}.dup.force_encoding(Encoding::UTF_8),
%{},
SINCE_3_1 - SINCE_1_9)
SINCE_1_9 - SINCE_3_1)
end

#
Expand Down Expand Up @@ -6626,7 +6626,7 @@ def test_parser_bug_198
s(:str, "#")),
%q{[/()\\1/, ?#]},
%q{},
SINCE_3_1 - SINCE_1_9)
SINCE_1_9 - SINCE_3_1)
end

def test_parser_bug_272
Expand Down Expand Up @@ -8160,7 +8160,7 @@ def test_forward_args_invalid
[:error, :unexpected_token, { :token => 'tDOT3' }],
%q{def foo ...; end},
%q{ ^^^ location},
SINCE_3_1 - SINCE_2_7)
SINCE_2_7 - SINCE_3_1)
end

def test_trailing_forward_arg
Expand Down
Loading