summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorJohn Hawthorn <[email protected]>2021-09-03 17:07:16 -0700
committerAlan Wu <[email protected]>2021-10-20 18:19:40 -0400
commitc2b1934475bd2494b47b2441ac89188215fa60cc (patch)
tree390bc96a6dab604b9cff2d114b22e753a2ff1db0 /test
parent10f1d808d57ac3e8e5c30385b61300d3cc40b0db (diff)
Add tests against opt_eq side exits
Diffstat (limited to 'test')
-rw-r--r--test/ruby/test_yjit.rb42
1 files changed, 42 insertions, 0 deletions
diff --git a/test/ruby/test_yjit.rb b/test/ruby/test_yjit.rb
index 90940009e2..4307a7dfb6 100644
--- a/test/ruby/test_yjit.rb
+++ b/test/ruby/test_yjit.rb
@@ -63,6 +63,48 @@ class TestYJIT < Test::Unit::TestCase
assert_compiles('-"foo" == -"bar"', insns: %i[opt_eq], result: false)
end
+ def test_compile_eq_symbol
+ assert_compiles(':foo == :foo', insns: %i[opt_eq], result: true)
+ assert_compiles(':foo == :bar', insns: %i[opt_eq], result: false)
+ assert_compiles(':foo == "foo".to_sym', insns: %i[opt_eq], result: true)
+ end
+
+ def test_compile_eq_object
+ assert_compiles(<<~RUBY, insns: %i[opt_eq], result: false)
+ def eq(a, b)
+ a == b
+ end
+
+ eq(Object.new, Object.new)
+ RUBY
+
+ assert_compiles(<<~RUBY, insns: %i[opt_eq], result: true)
+ def eq(a, b)
+ a == b
+ end
+
+ obj = Object.new
+ eq(obj, obj)
+ RUBY
+ end
+
+ def test_compile_eq_arbitrary_class
+ assert_compiles(<<~RUBY, insns: %i[opt_eq], result: "yes")
+ def eq(a, b)
+ a == b
+ end
+
+ class Foo
+ def ==(other)
+ "yes"
+ end
+ end
+
+ eq(Foo.new, Foo.new)
+ eq(Foo.new, Foo.new)
+ RUBY
+ end
+
def test_compile_set_and_get_global
assert_compiles('$foo = 123; $foo', insns: %i[setglobal], result: 123)
end