diff options
author | Maxime Chevalier-Boisvert <maximechevalierb@gmail.com> | 2021-05-05 16:06:19 -0400 |
---|---|---|
committer | Alan Wu <XrXr@users.noreply.github.com> | 2021-10-20 18:19:34 -0400 |
commit | e5f8b417862cf7a7d03c82067b9870151cd6ce28 (patch) | |
tree | e610d91dd6d9dd994712fa2845260f94cf96bd76 /bootstraptest | |
parent | 0758115d112a1ff452876d3689d20e84d5ff1e37 (diff) |
Implement send with alias method (#23)
* Implement send with alias method
* Add alias_method tests
Diffstat (limited to 'bootstraptest')
-rw-r--r-- | bootstraptest/test_yjit.rb | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/bootstraptest/test_yjit.rb b/bootstraptest/test_yjit.rb index b8ae5a989c..0b469ff5fa 100644 --- a/bootstraptest/test_yjit.rb +++ b/bootstraptest/test_yjit.rb @@ -130,6 +130,52 @@ assert_normal_exit %q{ foo() } +# Method aliasing +assert_equal '42', %q{ + class Foo + def method_a + 42 + end + + alias method_b method_a + + def method_a + :somethingelse + end + end + + @obj = Foo.new + + def test + @obj.method_b + end + + test + test +} + +# Method aliasing with method from parent class +assert_equal '777', %q{ + class A + def method_a + 777 + end + end + + class B < A + alias method_b method_a + end + + @obj = B.new + + def test + @obj.method_b + end + + test + test +} + # The hash method is a C function and uses the self argument assert_equal 'true', %q{ def lehashself |