From 496b4267b2015254edb176f98943d7599b43d22f Mon Sep 17 00:00:00 2001 From: nobu Date: Mon, 13 Nov 2017 23:53:00 +0000 Subject: 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 --- test/ruby/test_literal.rb | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'test/ruby/test_literal.rb') 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') -- cgit v1.2.3