From 3ecc6befcdfb14c6bfd345bd6bebd2e84dc32c27 Mon Sep 17 00:00:00 2001 From: John Hawthorn Date: Mon, 30 Aug 2021 20:58:53 -0700 Subject: 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. --- test/ruby/test_yjit.rb | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) (limited to 'test/ruby') 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) -- cgit v1.2.3