summaryrefslogtreecommitdiff
path: root/test/ruby/test_stringchar.rb
diff options
context:
space:
mode:
Diffstat (limited to 'test/ruby/test_stringchar.rb')
-rw-r--r--test/ruby/test_stringchar.rb29
1 files changed, 22 insertions, 7 deletions
diff --git a/test/ruby/test_stringchar.rb b/test/ruby/test_stringchar.rb
index 34934e87bd..44c8634c02 100644
--- a/test/ruby/test_stringchar.rb
+++ b/test/ruby/test_stringchar.rb
@@ -34,11 +34,11 @@ class TestStringchar < Test::Unit::TestCase
ABCD
ABCD
END
- $x.gsub!(/((.|\n)*?)B((.|\n)*?)D/){$1+$3}
+ $x.gsub!(/((.|\n)*?)B((.|\n)*?)D/m ,'\1\3')
assert_equal("AC\nAC\n", $x)
- assert("foobar" =~ /foo(?=(bar)|(baz))/)
- assert("foobaz" =~ /foo(?=(bar)|(baz))/)
+ assert_match(/foo(?=(bar)|(baz))/, "foobar")
+ assert_match(/foo(?=(bar)|(baz))/, "foobaz")
$foo = "abc"
assert_equal("abc = abc", "#$foo = abc")
@@ -68,9 +68,9 @@ END
# character constants(assumes ASCII)
assert_equal(?a, "a"[0])
assert_equal(?a, ?a)
- assert_equal(1, ?\C-a)
- assert_equal(225, ?\M-a)
- assert_equal(129, ?\M-\C-a)
+ assert_equal("\1", ?\C-a)
+ assert_equal("\341", ?\M-a)
+ assert_equal("\201", ?\M-\C-a)
assert_equal(?A, "a".upcase![0])
assert_equal(?a, "A".downcase![0])
assert_equal("ABC", "abc".tr!("a-z", "A-Z"))
@@ -82,7 +82,7 @@ END
$y = [ ?a, ?b, ?c, ?d, ?e, ?f ]
$bad = false
$x.each_byte {|i|
- if i != $y.shift
+ if i.chr != $y.shift
$bad = true
break
end
@@ -163,4 +163,19 @@ EOS
s.delete!("a-z")
assert_equal("BB", s)
end
+
+ def test_dump
+ bug3996 = '[ruby-core:32935]'
+ Encoding.list.find_all {|enc| enc.ascii_compatible?}.each do |enc|
+ (0..256).map do |c|
+ begin
+ s = c.chr(enc)
+ rescue RangeError, ArgumentError
+ break
+ else
+ assert_not_match(/\0/, s.dump, bug3996)
+ end
+ end
+ end
+ end
end