From b27db13e59306bbcb7d5981514de0c2d57db6c51 Mon Sep 17 00:00:00 2001 From: Ilya Bylich Date: Fri, 22 May 2020 20:31:47 +0300 Subject: [PATCH] make sure that all nodes are known for AST::Processor. --- test/test_ast_processor.rb | 32 ++++++++++++++++++++++++++++++++ test/test_base.rb | 2 +- 2 files changed, 33 insertions(+), 1 deletion(-) create mode 100644 test/test_ast_processor.rb diff --git a/test/test_ast_processor.rb b/test/test_ast_processor.rb new file mode 100644 index 000000000..2d7c21c4b --- /dev/null +++ b/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 diff --git a/test/test_base.rb b/test/test_base.rb index f99f08c5a..733d93d9a 100644 --- a/test/test_base.rb +++ b/test/test_base.rb @@ -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