1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34
|
require 'test/minirunit'
test_check "Test string#gsub stress test:"
# this test originally caused out of memory errors on the 0.9.0 release
mess="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghihklmnopqrstuvwxyz0123456789!+" #64
mess << mess #128
mess << mess #256
mess << mess #512
mess << mess #1024
mess << mess #2048
mess << mess #4096
mess << mess
mess << mess
# puts mess.size
result = mess.gsub(/(.)/,'(\1)')
test_equal("+", result[-2].chr)
# this test originally caused out of memory errors on the 0.9.0 release
count = 0
my_arr = []
result = mess.gsub(/./) do |m|
my_arr << m # this is what actually causes the OOM error - without this line its just very slow
count += 1
# test_equal("E\n", line) if count == 5
"(#{m})"
# print "Expecting E got " + c if count == 5
end
test_equal("+", result[-2].chr)
# puts count
|