summaryrefslogtreecommitdiff
path: root/test/ruby/test_literal.rb
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2017-11-13 23:53:00 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2017-11-13 23:53:00 +0000
commit496b4267b2015254edb176f98943d7599b43d22f (patch)
treec86e64a09a1454741a8565cec831a4bc78befb90 /test/ruby/test_literal.rb
parent24d38cc447ee122c07208cf87a7899fe77792b02 (diff)
compile.c: fixup r60727
* compile.c (iseq_peephole_optimize): skip next `freezestring` instruction after `concatstrings` instruction when frozen string literal is enabled. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60756 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test/ruby/test_literal.rb')
-rw-r--r--test/ruby/test_literal.rb14
1 files changed, 14 insertions, 0 deletions
diff --git a/test/ruby/test_literal.rb b/test/ruby/test_literal.rb
index 9645e3234b..67a383bc3c 100644
--- a/test/ruby/test_literal.rb
+++ b/test/ruby/test_literal.rb
@@ -177,6 +177,20 @@ class TestRubyLiteral < Test::Unit::TestCase
end
end
+ if defined?(RubyVM::InstructionSequence.compile_option) and
+ RubyVM::InstructionSequence.compile_option.key?(:debug_frozen_string_literal)
+ def test_debug_frozen_string
+ src = 'n = 1; "foo#{n ? "-#{n}" : ""}"'; f = "test.rb"; n = 1
+ opt = {frozen_string_literal: true, debug_frozen_string_literal: true}
+ str = RubyVM::InstructionSequence.compile(src, f, f, n, opt).eval
+ assert_equal("foo-1", str)
+ assert_predicate(str, :frozen?)
+ assert_raise_with_message(RuntimeError, /created at #{Regexp.quote(f)}:#{n}/) {
+ str << "x"
+ }
+ end
+ end
+
def test_regexp
assert_instance_of Regexp, //
assert_match(//, 'a')