diff options
Diffstat (limited to 'bootstraptest/test_yjit.rb')
-rw-r--r-- | bootstraptest/test_yjit.rb | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/bootstraptest/test_yjit.rb b/bootstraptest/test_yjit.rb index 503af1ab80..3ae0cdb33a 100644 --- a/bootstraptest/test_yjit.rb +++ b/bootstraptest/test_yjit.rb @@ -1393,6 +1393,33 @@ assert_equal 'foo', %q{ make_str("foo") } +# Test that String unary plus returns the same object ID for an unfrozen string. +assert_equal '', %q{ + str = "bar" + + old_obj_id = str.object_id + uplus_str = +str + + if uplus_str.object_id != old_obj_id + raise "String unary plus on unfrozen should return the string exactly, not a duplicate" + end + + '' +} + +# Test that String unary plus returns a different unfrozen string when given a frozen string +assert_equal 'false', %q{ + frozen_str = "foo".freeze + + old_obj_id = frozen_str.object_id + uplus_str = +frozen_str + + if uplus_str.object_id == old_obj_id + raise "String unary plus on frozen should return a new duplicated string" + end + + uplus_str.frozen? +} # test invokebuiltin as used in struct assignment assert_equal '123', %q{ |