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

make sure that all nodes are known for AST::Processor. #698

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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
32 changes: 32 additions & 0 deletions test/test_ast_processor.rb
@@ -0,0 +1,32 @@
# frozen_string_literal: true

require 'helper'

class TestASTProcessor < Minitest::Test
LEAF_NODES = %i[
sym str int float complex rational
true false nil self
__FILE__ __LINE__ __ENCODING__
cbase regopt zsuper
match_with_trailing_comma match_nil_pattern
forward_args forwarded_args numargs kwnilarg
objc_varargs objc_restarg objc_kwarg
ident
].freeze

def setup
@traversible = Parser::AST::Processor
.instance_methods(false)
.map { |mid| mid.to_s.scan(/\Aon_(.*)/) }
.flatten
.map(&:to_sym)

@traversible += LEAF_NODES
end

def test_nodes_are_traversible
for_each_node do |node|
assert_includes @traversible, node.type
end
end
end
2 changes: 1 addition & 1 deletion test/test_base.rb
Expand Up @@ -26,6 +26,6 @@ def test_loc_to_node
def test_loc_dup
ast = Parser::CurrentRuby.parse('1')
assert_nil ast.loc.dup.node
Parser::AST::Node.new(:root, [], :location => ast.loc)
Parser::AST::Node.new(:zsuper, [], :location => ast.loc)
end
end