summaryrefslogtreecommitdiffhomepage
path: root/test
diff options
context:
space:
mode:
authorTomoyuki Sahara <[email protected]>2012-11-13 16:50:41 +0900
committerTomoyuki Sahara <[email protected]>2012-11-13 16:50:41 +0900
commitb1f5840aefe0c4edac9dc3f238bdb757521eb67c (patch)
treee0706bb7da909491dbf2aa8e0b34496db81afb95 /test
parent1cd9d7e40abb8112fe9f05193f9af6ec357a71eb (diff)
downloadmruby-b1f5840aefe0c4edac9dc3f238bdb757521eb67c.tar.gz
mruby-b1f5840aefe0c4edac9dc3f238bdb757521eb67c.zip
fix the issue String#slice with Range may return broken String.
Diffstat (limited to 'test')
-rw-r--r--test/t/string.rb26
1 files changed, 26 insertions, 0 deletions
diff --git a/test/t/string.rb b/test/t/string.rb
index 26b7df584..1e921c668 100644
--- a/test/t/string.rb
+++ b/test/t/string.rb
@@ -61,6 +61,32 @@ assert('String#[]', '15.2.10.5.6') do
a3 == 'bc' and b3 == nil
end
+assert('String#[] with Range') do
+ a1 = 'abc'[1..0]
+ b1 = 'abc'[1..1]
+ c1 = 'abc'[1..2]
+ d1 = 'abc'[1..3]
+ e1 = 'abc'[1..4]
+ f1 = 'abc'[0..-2]
+ g1 = 'abc'[-2..3]
+ h1 = 'abc'[3..4]
+ i1 = 'abc'[4..5]
+ a2 = 'abc'[1...0]
+ b2 = 'abc'[1...1]
+ c2 = 'abc'[1...2]
+ d2 = 'abc'[1...3]
+ e2 = 'abc'[1...4]
+ f2 = 'abc'[0...-2]
+ g2 = 'abc'[-2...3]
+ h2 = 'abc'[3...4]
+ i2 = 'abc'[4...5]
+
+ a1 == '' and b1 == 'b' and c1 == 'bc' and d1 == 'bc' and e1 == 'bc' and
+ f1 == 'ab' and g1 == 'bc' and h1 == '' and i2 == nil and
+ a2 == '' and b2 == '' and c2 == 'b' and d2 == 'bc' and e2 == 'bc' and
+ f2 == 'a' and g2 == 'bc' and h2 == '' and i2 == nil
+end
+
assert('String#capitalize', '15.2.10.5.7') do
a = 'abc'
a.capitalize