summaryrefslogtreecommitdiff
path: root/test/ruby
diff options
context:
space:
mode:
authorJohn Hawthorn <john@hawthorn.email>2021-08-30 20:58:53 -0700
committerAlan Wu <XrXr@users.noreply.github.com>2021-10-20 18:19:39 -0400
commit3ecc6befcdfb14c6bfd345bd6bebd2e84dc32c27 (patch)
treeacb3ff0fd7944c055f90a101cb2aa970ea564051 /test/ruby
parentfbde1d9bee1da0a27ead6ce3ae7bc4411b10198d (diff)
Implement invokesuper using cfp->ep[ME] check
This fixes and re-enables invokesuper, replacing the existing guards with a guard on the method entry for the EP.
Diffstat (limited to 'test/ruby')
-rw-r--r--test/ruby/test_yjit.rb34
1 files changed, 34 insertions, 0 deletions
diff --git a/test/ruby/test_yjit.rb b/test/ruby/test_yjit.rb
index 04502f925c..50b415107d 100644
--- a/test/ruby/test_yjit.rb
+++ b/test/ruby/test_yjit.rb
@@ -162,6 +162,40 @@ class TestYJIT < Test::Unit::TestCase
RUBY
end
+ def test_super_iseq
+ assert_compiles(<<~'RUBY', insns: %i[invokesuper opt_plus opt_mult], result: 15)
+ class A
+ def foo
+ 1 + 2
+ end
+ end
+
+ class B < A
+ def foo
+ super * 5
+ end
+ end
+
+ B.new.foo
+ RUBY
+ end
+
+ def test_super_cfunc
+ assert_compiles(<<~'RUBY', insns: %i[invokesuper], result: "Hello")
+ class Gnirts < String
+ def initialize
+ super(-"olleH")
+ end
+
+ def to_s
+ super().reverse
+ end
+ end
+
+ Gnirts.new.to_s
+ RUBY
+ end
+
def test_fib_recursion
assert_compiles(<<~'RUBY', insns: %i[opt_le opt_minus opt_plus opt_send_without_block], result: 34)
def fib(n)