aboutsummaryrefslogtreecommitdiffstats
path: root/bootstraptest/test_yjit.rb
diff options
context:
space:
mode:
Diffstat (limited to 'bootstraptest/test_yjit.rb')
-rw-r--r--bootstraptest/test_yjit.rb32
1 files changed, 31 insertions, 1 deletions
diff --git a/bootstraptest/test_yjit.rb b/bootstraptest/test_yjit.rb
index 6d0ba93fc8..503af1ab80 100644
--- a/bootstraptest/test_yjit.rb
+++ b/bootstraptest/test_yjit.rb
@@ -1339,12 +1339,42 @@ assert_equal 'foo123', %q{
# test that invalidation of String#to_s doesn't crash
assert_equal 'meh', %q{
+ def inval_method
+ "".to_s
+ end
+
+ inval_method
+
class String
def to_s
"meh"
end
end
- "".to_s
+
+ inval_method
+}
+
+# test that overriding to_s on a String subclass isn't over-optimised
+assert_equal 'meh', %q{
+ class MyString < String
+ def to_s
+ "meh"
+ end
+ end
+
+ def test_to_s(obj)
+ obj.to_s
+ end
+
+ OBJ = MyString.new
+
+ # Should return 'meh' both times
+ test_to_s("")
+ test_to_s("")
+
+ # Can return '' if YJIT optimises String#to_s too aggressively
+ test_to_s(OBJ)
+ test_to_s(OBJ)
}
# test string interpolation with overridden to_s