diff options
author | Alan Wu <XrXr@users.noreply.github.com> | 2021-06-23 20:28:42 -0400 |
---|---|---|
committer | Alan Wu <XrXr@users.noreply.github.com> | 2021-10-20 18:19:36 -0400 |
commit | 3996e0ab07d06b7685eecd56a542e9672702dee2 (patch) | |
tree | d659767dc3ce523b4bfae0fa23a8b95e0a4e9513 /bootstraptest | |
parent | 6883aeda77c09c4982080f968491eacbc43a47e1 (diff) |
Add tests, comments, and an assert for invokesuper
Diffstat (limited to 'bootstraptest')
-rw-r--r-- | bootstraptest/test_yjit.rb | 57 |
1 files changed, 57 insertions, 0 deletions
diff --git a/bootstraptest/test_yjit.rb b/bootstraptest/test_yjit.rb index fd1310b04e..fc0b693ec2 100644 --- a/bootstraptest/test_yjit.rb +++ b/bootstraptest/test_yjit.rb @@ -1238,3 +1238,60 @@ assert_equal '[:A, [:A, :B]]', %q{ C.new.bar } + +# Same invokesuper bytecode, multiple destinations +assert_equal '[:Forward, :SecondTerminus]', %q{ + module Terminus + def foo = :Terminus + end + + module SecondTerminus + def foo = :SecondTerminus + end + + + module Forward + def foo = [:Forward, super] + end + + class B + include SecondTerminus + end + + class A < B + include Terminus + include Forward + end + + A.new.foo + A.new.foo # compile + + class B + include Forward + alias bar foo + end + + # A.ancestors.take(5) == [A, Forward, Terminus, B, Forward, SecondTerminus] + + A.new.bar +} + +# invokesuper calling into itself +assert_equal '[:B, [:B, :m]]', %q{ + module M + def foo = :m + end + + class B + include M + def foo = [:B, super] + end + + ins = B.new + ins.singleton_class # materialize the singleton class + ins.foo + ins.foo # compile + + ins.singleton_class.define_method(:bar, B.instance_method(:foo)) + ins.bar +} |