mirror of
https://github.com/ruby/ruby.git
synced 2025-08-28 15:36:16 +02:00
* string.c (rb_str_times): reduce loop overhead.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@15514 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
71c5e48598
commit
35cb0f807b
3 changed files with 23 additions and 5 deletions
|
@ -174,7 +174,7 @@ class TestString < Test::Unit::TestCase
|
|||
s = "a"
|
||||
10.times {|i|
|
||||
s << s
|
||||
assert_equal("a" * (2<<i), s)
|
||||
assert_equal("a" * (2 << i), s)
|
||||
}
|
||||
end
|
||||
|
||||
|
@ -1370,4 +1370,13 @@ class TestString < Test::Unit::TestCase
|
|||
def test_end_with?
|
||||
assert("abc".end_with?("c"))
|
||||
end
|
||||
|
||||
def test_times
|
||||
s1 = ''
|
||||
100.times {|n|
|
||||
s2 = "a" * n
|
||||
assert_equal(s1, s2)
|
||||
s1 << 'a'
|
||||
}
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue