From b35cdb4758c0a569574a047bda6ce6a19c302aef Mon Sep 17 00:00:00 2001 From: Jenny Shen Date: Fri, 2 Feb 2024 16:57:51 -0500 Subject: [PRISM] Implement opt_aset_with Part of ruby/prism#2231 Co-authored-by: Adrianna Chang Co-authored-by: Peter Zhu --- test/ruby/test_compile_prism.rb | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'test/ruby') diff --git a/test/ruby/test_compile_prism.rb b/test/ruby/test_compile_prism.rb index b9c8d1bb5b..e70c73c30a 100644 --- a/test/ruby/test_compile_prism.rb +++ b/test/ruby/test_compile_prism.rb @@ -2076,6 +2076,18 @@ end before == after RUBY + + # Test opt_aset_with instruction when calling []= with a string key + assert_prism_eval(<<~RUBY) + ObjectSpace.count_objects + + h = {"abc" => 1} + before = ObjectSpace.count_objects[:T_STRING] + 5.times{ h["abc"] = 2} + after = ObjectSpace.count_objects[:T_STRING] + + before == after + RUBY end def test_CallAndWriteNode -- cgit v1.2.3