File: test_ast_processor.rb

package info (click to toggle)
ruby-whitequark-parser 3.3.4.2-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 2,828 kB
  • sloc: yacc: 40,699; ruby: 20,395; makefile: 12; sh: 8
file content (32 lines) | stat: -rw-r--r-- 723 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
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