Skip to content

Commit

Permalink
[PRISM] Enable test_ast.rb
Browse files Browse the repository at this point in the history
  • Loading branch information
kddnewton committed May 2, 2024
1 parent 41977ef commit 2eefbef
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 1 deletion.
2 changes: 1 addition & 1 deletion .github/workflows/prism.yml
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ jobs:
timeout-minutes: 40
env:
GNUMAKEFLAGS: ''
RUBY_TESTOPTS: '-q --tty=no --excludes-dir="../src/test/.excludes-prism" --exclude="test_ast.rb" --exclude="error_highlight/test_error_highlight.rb" --exclude="prism/encoding_test.rb" --exclude="prism/locals_test.rb" --exclude="prism/newline_test.rb"'
RUBY_TESTOPTS: '-q --tty=no --excludes-dir="../src/test/.excludes-prism" --exclude="error_highlight/test_error_highlight.rb" --exclude="prism/encoding_test.rb" --exclude="prism/locals_test.rb" --exclude="prism/newline_test.rb"'
RUN_OPTS: ${{ matrix.run_opts }}

- name: make test-prism-spec
Expand Down
23 changes: 23 additions & 0 deletions test/ruby/test_ast.rb
Original file line number Diff line number Diff line change
Expand Up @@ -337,6 +337,8 @@ def test_invalid_yield
end

def test_node_id_for_location
omit if compiling_with_prism?

exception = begin
raise
rescue => e
Expand All @@ -356,6 +358,8 @@ def test_node_id_for_backtrace_location_raises_argument_error
end

def test_of_proc_and_method
omit if compiling_with_prism?

proc = Proc.new { 1 + 2 }
method = self.method(__method__)

Expand Down Expand Up @@ -385,6 +389,8 @@ def sample_backtrace_location
end

def test_of_backtrace_location
omit if compiling_with_prism?

backtrace_location, lineno = sample_backtrace_location
node = RubyVM::AbstractSyntaxTree.of(backtrace_location)
assert_instance_of(RubyVM::AbstractSyntaxTree::Node, node)
Expand All @@ -396,6 +402,8 @@ def test_of_error
end

def test_of_proc_and_method_under_eval
omit if compiling_with_prism?

keep_script_lines_back = RubyVM.keep_script_lines
RubyVM.keep_script_lines = false

Expand Down Expand Up @@ -425,6 +433,7 @@ def test_of_proc_and_method_under_eval
end

def test_of_proc_and_method_under_eval_with_keep_script_lines
omit if compiling_with_prism?
pend if ENV['RUBY_ISEQ_DUMP_DEBUG'] # TODO

keep_script_lines_back = RubyVM.keep_script_lines
Expand Down Expand Up @@ -456,6 +465,8 @@ def test_of_proc_and_method_under_eval_with_keep_script_lines
end

def test_of_backtrace_location_under_eval
omit if compiling_with_prism?

keep_script_lines_back = RubyVM.keep_script_lines
RubyVM.keep_script_lines = false

Expand All @@ -474,6 +485,7 @@ def self.sample_backtrace_location
end

def test_of_backtrace_location_under_eval_with_keep_script_lines
omit if compiling_with_prism?
pend if ENV['RUBY_ISEQ_DUMP_DEBUG'] # TODO

keep_script_lines_back = RubyVM.keep_script_lines
Expand Down Expand Up @@ -736,6 +748,8 @@ def test_keep_script_lines_for_parse
end

def test_keep_script_lines_for_of
omit if compiling_with_prism?

proc = Proc.new { 1 + 2 }
method = self.method(__method__)

Expand Down Expand Up @@ -1247,6 +1261,15 @@ def test_memory_leak
end;
end

private

# We can't revisit instruction sequences to find node ids if the prism
# compiler was used instead of the parse.y compiler. In that case, we'll omit
# some tests.
def compiling_with_prism?
RubyVM::InstructionSequence.compile("").to_a[4][:parser] == :prism
end

def assert_error_tolerant(src, expected, keep_tokens: false)
begin
verbose_bak, $VERBOSE = $VERBOSE, false
Expand Down

0 comments on commit 2eefbef

Please sign in to comment.