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

test older parsers don't throw non-syntax errors on new syntax #746

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
18 changes: 18 additions & 0 deletions test/parse_helper.rb
Expand Up @@ -84,6 +84,24 @@ def assert_parses(ast, code, source_maps='', versions=ALL_VERSIONS)
parser.instance_eval { @lexer.force_utf32 = true }
try_parsing(ast, code, parser, source_maps, version)
end

# Also check that it doesn't throw anything
# except (possibly) Parser::SyntaxError on other versions of Ruby
with_versions(ALL_VERSIONS - versions) do |version, parser|
begin
source_file = Parser::Source::Buffer.new('(assert_older_rubies)', source: code)
parser.parse(source_file)
rescue Parser::SyntaxError
# ok
rescue StandardError
# unacceptable
raise
else
# No error means that `code` is valid for `version`, but has a different meaning.
# Sometimes Ruby has breaking changes (like numparams)
# that re-use constructions from previous versions.
end
end
end

def try_parsing(ast, code, parser, source_maps, version)
Expand Down