summaryrefslogtreecommitdiff
path: root/test/ruby
diff options
context:
space:
mode:
authorPeter Zhu <peter@peterzhu.ca>2024-01-29 11:58:26 -0500
committerPeter Zhu <peter@peterzhu.ca>2024-01-29 14:53:34 -0500
commit32bbf4750097f7b3358e06e9d8efd81a2089d139 (patch)
treef5aa61e9b1b8b273012e7f79a1ccde043647bd91 /test/ruby
parentd7501c403130b575219a672073a06792e81dcdb4 (diff)
[PRISM] Use opt_str_freeze instruction
Fixes ruby/prism#2290.
Diffstat (limited to 'test/ruby')
-rw-r--r--test/ruby/test_compile_prism.rb10
1 files changed, 10 insertions, 0 deletions
diff --git a/test/ruby/test_compile_prism.rb b/test/ruby/test_compile_prism.rb
index be8d8650a7..48912c31f6 100644
--- a/test/ruby/test_compile_prism.rb
+++ b/test/ruby/test_compile_prism.rb
@@ -1986,6 +1986,16 @@ end
end
test_prism_call_node
CODE
+
+ # Test opt_str_freeze instruction when calling #freeze on a string literal
+ assert_prism_eval(<<~RUBY)
+ "foo".freeze.equal?("foo".freeze)
+ RUBY
+ # Test encoding in opt_str_freeze
+ assert_prism_eval(<<~'RUBY', raw: true)
+ # -*- coding: us-ascii -*-
+ "\xff".freeze.encoding
+ RUBY
end
def test_CallAndWriteNode