summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authornagachika <nagachika@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2013-04-26 16:15:17 +0000
committernagachika <nagachika@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2013-04-26 16:15:17 +0000
commitc72e5e70d98c63718b2e606e1e1f8c29b1c33677 (patch)
tree46cc1ccce493364176ff4e23b05f29e063454cd8 /test
parenta2ac434a0700d5bd08bf213b4ede09899330f9df (diff)
merge revision(s) 40413,40414,40415,40423: [Backport #8290]
* string.c (rb_str_inspect): NUL should not be represented as "\0" when octal digits may follow. * string.c (rb_str_inspect): NUL should not be represented as "\0" when octal digits may follow. [ruby-core:54458] [Bug #8290] * test/ruby/test_module.rb (TestModule#test_const_get_invalid_name) (test_const_defined_invalid_name): Fix expected values. * string.c (rb_str_inspect): refix r40413, on Ruby 1.9 usual character escape uses hex/Unicode escapes, so fix to use Unicode escape on Unicode strings and hex on others. [ruby-core:54458] [Bug #8290] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_0_0@40488 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test')
-rw-r--r--test/ruby/test_module.rb4
-rw-r--r--test/ruby/test_string.rb8
2 files changed, 10 insertions, 2 deletions
diff --git a/test/ruby/test_module.rb b/test/ruby/test_module.rb
index 06c1820853..1dd27561b0 100644
--- a/test/ruby/test_module.rb
+++ b/test/ruby/test_module.rb
@@ -590,7 +590,7 @@ class TestModule < Test::Unit::TestCase
assert_raise(TypeError, bug5084) { c1.const_get(1) }
bug7574 = '[ruby-dev:46749]'
e = assert_raise(NameError) { Object.const_get("String\0") }
- assert_equal("wrong constant name \"String\\0\"", e.message, bug7574)
+ assert_equal("wrong constant name \"String\\u0000\"", e.message, bug7574)
end
def test_const_defined_invalid_name
@@ -600,7 +600,7 @@ class TestModule < Test::Unit::TestCase
assert_raise(TypeError, bug5084) { c1.const_defined?(1) }
bug7574 = '[ruby-dev:46749]'
e = assert_raise(NameError) { Object.const_defined?("String\0") }
- assert_equal("wrong constant name \"String\\0\"", e.message, bug7574)
+ assert_equal("wrong constant name \"String\\u0000\"", e.message, bug7574)
end
def test_const_get_no_inherited
diff --git a/test/ruby/test_string.rb b/test/ruby/test_string.rb
index 43be67893c..3a60213c2e 100644
--- a/test/ruby/test_string.rb
+++ b/test/ruby/test_string.rb
@@ -1984,6 +1984,14 @@ class TestString < Test::Unit::TestCase
assert_instance_of(String, s.to_s)
end
+ def test_inspect_nul
+ bug8290 = '[ruby-core:54458]'
+ s = "\0" + "12"
+ assert_equal '"\u000012"', s.inspect, bug8290
+ s = "\0".b + "12"
+ assert_equal '"\x0012"', s.inspect, bug8290
+ end
+
def test_partition
assert_equal(%w(he l lo), "hello".partition(/l/))
assert_equal(%w(he l lo), "hello".partition("l"))