ruby-changes:69257
From: John <ko1@a...>
Date: Thu, 21 Oct 2021 08:24:22 +0900 (JST)
Subject: [ruby-changes:69257] c2b1934475 (master): Add tests against opt_eq side exits
https://git.ruby-lang.org/ruby.git/commit/?id=c2b1934475 From c2b1934475bd2494b47b2441ac89188215fa60cc Mon Sep 17 00:00:00 2001 From: John Hawthorn <john@h...> Date: Fri, 3 Sep 2021 17:07:16 -0700 Subject: Add tests against opt_eq side exits --- test/ruby/test_yjit.rb | 42 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) 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 https://github.com/ruby/ruby/blob/trunk/test/ruby/test_yjit.rb#L63 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 -- cgit v1.2.1 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/