summaryrefslogtreecommitdiff
path: root/test/ruby
diff options
context:
space:
mode:
authorakr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2014-10-17 09:49:28 +0000
committerakr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2014-10-17 09:49:28 +0000
commit0d4185f30e360b078d663acd8f4dfda95fe2aae9 (patch)
tree5df4391258496199530f6875163a3e98e2e84706 /test/ruby
parent1efb3c31b731e99627bbc0da13dfd3463bb67c67 (diff)
* Avoid undefined behaviors found by gcc -fsanitize=undefined.
gcc (Debian 4.9.1-16) 4.9.1 * string.c (rb_str_sum): Avoid undefined behavior. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@47997 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test/ruby')
-rw-r--r--test/ruby/test_string.rb4
1 files changed, 3 insertions, 1 deletions
diff --git a/test/ruby/test_string.rb b/test/ruby/test_string.rb
index d82d2bc59e..543c1389bd 100644
--- a/test/ruby/test_string.rb
+++ b/test/ruby/test_string.rb
@@ -1584,6 +1584,8 @@ class TestString < Test::Unit::TestCase
assert_equal(16, n.sum(17))
n[0] = 2.chr
assert_not_equal(15, n.sum)
+ assert_equal(17, n.sum(0))
+ assert_equal(17, n.sum(-1))
end
def check_sum(str, bits=16)
@@ -1598,7 +1600,7 @@ class TestString < Test::Unit::TestCase
assert_equal(294, "abc".sum)
check_sum("abc")
check_sum("\x80")
- 0.upto(70) {|bits|
+ -3.upto(70) {|bits|
check_sum("xyz", bits)
}
end