diff options
author | ko1 <ko1@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2015-10-23 19:02:55 +0000 |
---|---|---|
committer | ko1 <ko1@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2015-10-23 19:02:55 +0000 |
commit | 8b158973b551d8993a533fb576935b3f7b1ac156 (patch) | |
tree | c0e89d90d7ad34e7aa833a800227724f62c0930a /test/ruby | |
parent | bfbed018c7e3b612b77a8e4ec76a80d4640114a1 (diff) | |
download | ruby-8b158973b551d8993a533fb576935b3f7b1ac156.tar.gz |
* ruby.c: introduce --enable-frozen-string-literal-debug option.
If this option is enabled, the modify error will be:
can't modify frozen String (RuntimeError) =>
can't modify frozen String, created at test.rb:3 (RuntimeError)
* iseq.h: add compile option frozen_string_literal_debug.
* compile.c: catch up this fix.
* error.c (rb_error_frozen): ditto.
* iseq.c (set_compile_option_from_hash): ditto.
* test/ruby/test_rubyoptions.rb: add a test for this fix.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52257 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test/ruby')
-rw-r--r-- | test/ruby/test_rubyoptions.rb | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/test/ruby/test_rubyoptions.rb b/test/ruby/test_rubyoptions.rb index f446afc48e..7da34bd5f6 100644 --- a/test/ruby/test_rubyoptions.rb +++ b/test/ruby/test_rubyoptions.rb @@ -804,4 +804,15 @@ class TestRubyOptions < Test::Unit::TestCase end end end + + def test_frozen_string_literal_debug + assert_in_out_err(["--disable=gems", "--enable-frozen-string-literal", "--enable-frozen-string-literal-debug" ], '"foo" << "bar"', [], /created at/) + assert_in_out_err(["--disable=gems", "--enable-frozen-string-literal", "--disable-frozen-string-literal-debug"], '"foo" << "bar"', [], /can\'t modify frozen String \(RuntimeError\)\n\z/) + assert_in_out_err(["--disable=gems", "--disable-frozen-string-literal", "--enable-frozen-string-literal-debug" ], '"foo" << "bar"', [], []) + assert_in_out_err(["--disable=gems", "--disable-frozen-string-literal", "--disable-frozen-string-literal-debug"], '"foo" << "bar"', [], []) + assert_in_out_err(["--disable=gems", "--enable-frozen-string-literal-debug" ], '"foo" << "bar"', [], []) + assert_in_out_err(["--disable=gems", "--disable-frozen-string-literal-debug"], '"foo" << "bar"', [], []) + assert_in_out_err(["--disable=gems", "--enable-frozen-string-literal", ], '"foo" << "bar"', [], /can\'t modify frozen String \(RuntimeError\)\n\z/) + assert_in_out_err(["--disable=gems", "--enable-frozen-string-literal", ], '"foo" << "bar"', [], /can\'t modify frozen String \(RuntimeError\)\n\z/) + end end |