summaryrefslogtreecommitdiff
path: root/test/ruby
diff options
context:
space:
mode:
authorJemma Issroff <jemmaissroff@gmail.com>2023-10-13 10:59:37 -0700
committerGitHub <noreply@github.com>2023-10-13 10:59:37 -0700
commit34add1e5955742d46f5138b3ded4a6d149675b9b (patch)
tree9b417cfc7620bbecd66758dfd948096fd081874f /test/ruby
parent92bdc3757f078138fe34a87c9db1b497fc00f68f (diff)
[PRISM] Compile fixes (#8644)
* Fix compiling UndefNodes * Fix compiling super on ClassNode * Fix compile popped for ModuleNode * Add checks for NULL nodes * Only add newhash if not popped
Diffstat (limited to 'test/ruby')
-rw-r--r--test/ruby/test_compile_prism.rb43
1 files changed, 43 insertions, 0 deletions
diff --git a/test/ruby/test_compile_prism.rb b/test/ruby/test_compile_prism.rb
index f0e389d30a..f94bd603ca 100644
--- a/test/ruby/test_compile_prism.rb
+++ b/test/ruby/test_compile_prism.rb
@@ -322,6 +322,7 @@ module Prism
test_prism_eval("a = 1; { a: }")
test_prism_eval("{ to_s: }")
test_prism_eval("{ Prism: }")
+ test_prism_eval("[ Prism: [:b, :c]]")
end
############################################################################
@@ -362,12 +363,54 @@ module Prism
# Scopes/statements #
############################################################################
+ def test_ClassNode
+ test_prism_eval("class PrismClassA; end")
+ test_prism_eval("class PrismClassA; end; class PrismClassB < PrismClassA; end")
+ test_prism_eval("class PrismClassA; end; class PrismClassA::PrismClassC; end")
+ test_prism_eval(<<-HERE
+ class PrismClassA; end
+ class PrismClassA::PrismClassC; end
+ class PrismClassB; end
+ class PrismClassB::PrismClassD < PrismClassA::PrismClassC; end
+ HERE
+ )
+ end
+
+ def test_ModuleNode
+ test_prism_eval("module M; end")
+ test_prism_eval("module M::N; end")
+ test_prism_eval("module ::O; end")
+ end
+
def test_ParenthesesNode
test_prism_eval("()")
test_prism_eval("(1)")
end
############################################################################
+ # Methods / parameters #
+ ############################################################################
+
+ def test_UndefNode
+ test_prism_eval("def prism_undef_node_1; end; undef prism_undef_node_1")
+ test_prism_eval(<<-HERE
+ def prism_undef_node_2
+ end
+ def prism_undef_node_3
+ end
+ undef prism_undef_node_2, prism_undef_node_3
+ HERE
+ )
+ test_prism_eval(<<-HERE
+ def prism_undef_node_4
+ end
+ undef :'prism_undef_node_#{4}'
+ HERE
+ )
+ end
+
+
+ ############################################################################
# Pattern matching #
############################################################################