diff options
author | Kevin Newton <[email protected]> | 2024-07-03 15:57:24 -0400 |
---|---|---|
committer | Kevin Newton <[email protected]> | 2024-07-11 14:25:54 -0400 |
commit | c1df15c3e69201ed01c1b902de8c9302740899eb (patch) | |
tree | b7e4a20b7b8b7e92d82dde53454f4b5be6b9e66c /test | |
parent | 0006fb1e9e30add81ca8644c633c548f3b239796 (diff) |
[PRISM] Use node ids for error highlight
Diffstat (limited to 'test')
-rw-r--r-- | test/error_highlight/test_error_highlight.rb | 37 |
1 files changed, 10 insertions, 27 deletions
diff --git a/test/error_highlight/test_error_highlight.rb b/test/error_highlight/test_error_highlight.rb index 9af530b69f..de4e46ad42 100644 --- a/test/error_highlight/test_error_highlight.rb +++ b/test/error_highlight/test_error_highlight.rb @@ -5,13 +5,6 @@ require "did_you_mean" require "tempfile" class ErrorHighlightTest < Test::Unit::TestCase - # 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 self.compiling_with_prism? - RubyVM::InstructionSequence.compile("").to_a[4][:parser] == :prism - end - class DummyFormatter def self.message_for(corrections) "" @@ -876,27 +869,13 @@ uninitialized constant ErrorHighlightTest::NotDefined end end - if ErrorHighlight.const_get(:Spotter).const_get(:OPT_GETCONSTANT_PATH) && !compiling_with_prism? - def test_COLON2_5 - # Unfortunately, we cannot identify which `NotDefined` caused the NameError - assert_error_message(NameError, <<~END) do -uninitialized constant ErrorHighlightTest::NotDefined - END - - ErrorHighlightTest::NotDefined::NotDefined - end - end - else - def test_COLON2_5 - assert_error_message(NameError, <<~END) do + def test_COLON2_5 + # Unfortunately, we cannot identify which `NotDefined` caused the NameError + assert_error_message(NameError, <<~END) do uninitialized constant ErrorHighlightTest::NotDefined + END - ErrorHighlightTest::NotDefined::NotDefined - ^^^^^^^^^^^^ - END - - ErrorHighlightTest::NotDefined::NotDefined - end + ErrorHighlightTest::NotDefined::NotDefined end end @@ -1342,7 +1321,11 @@ undefined method `foo' for #{ NIL_RECV_MESSAGE } def test_spot_with_node omit unless RubyVM::AbstractSyntaxTree.respond_to?(:node_id_for_backtrace_location) - omit if ErrorHighlightTest.compiling_with_prism? + + # 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. + omit if RubyVM::InstructionSequence.compile("").to_a[4][:parser] == :prism begin raise_name_error |