From a6104b392ab347c323c93a51fb3b95c3c2cc9e8f Mon Sep 17 00:00:00 2001 From: John Hawthorn Date: Wed, 27 Oct 2021 07:55:43 -0700 Subject: YJIT: Support newhash with values (#5029) * YJIT: Implement newhash with values * YJIT: Add test of duphash * Fix compilation on macos/clang --- test/ruby/test_yjit.rb | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'test/ruby') diff --git a/test/ruby/test_yjit.rb b/test/ruby/test_yjit.rb index 9b26e6c37f..7b8cde6c0c 100644 --- a/test/ruby/test_yjit.rb +++ b/test/ruby/test_yjit.rb @@ -85,6 +85,16 @@ class TestYJIT < Test::Unit::TestCase assert_compiles('e = 5; (..e)', insns: %i[newrange], result: ..5) end + def test_compile_duphash + assert_compiles('{ two: 2 }', insns: %i[duphash], result: { two: 2 }) + end + + def test_compile_newhash + assert_compiles('{}', insns: %i[newhash], result: {}) + assert_compiles('{ two: 1 + 1 }', insns: %i[newhash], result: { two: 2 }) + assert_compiles('{ 1 + 1 => :two }', insns: %i[newhash], result: { 2 => :two }) + end + def test_compile_opt_nil_p assert_compiles('nil.nil?', insns: %i[opt_nil_p], result: true) assert_compiles('false.nil?', insns: %i[opt_nil_p], result: false) -- cgit v1.2.3