1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

Use mutable strings for mutation tests.

* test/fiddle/test_func.rb (test_string): this test break String buffer
  by `strcpy` ("000" -> "123"). However, the string literal "000" with
  `frozen_string_literal: true` returns a string object from frozen
  string pool. So that after this test "000" from fstring pool becomes
  "123" (modified string). 'test/date/' uses "000" (as fstring) and tests
  are fails (we could check with `make test-all TESTS='fiddle date'`).

* test/fiddle/test_function.rb: ditto.

* test/fiddle/test_import.rb: ditto.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59861 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
ko1 2017-09-12 23:15:34 +00:00
parent 4ef5c754f7
commit 3fe69a0da4
3 changed files with 4 additions and 4 deletions

View file

@ -38,7 +38,7 @@ module Fiddle
def test_string def test_string
stress, GC.stress = GC.stress, true stress, GC.stress = GC.stress, true
f = Function.new(@libc['strcpy'], [TYPE_VOIDP, TYPE_VOIDP], TYPE_VOIDP) f = Function.new(@libc['strcpy'], [TYPE_VOIDP, TYPE_VOIDP], TYPE_VOIDP)
buff = "000" buff = +"000"
str = f.call(buff, "123") str = f.call(buff, "123")
assert_equal("123", buff) assert_equal("123", buff)
assert_equal("123", str.to_s) assert_equal("123", str.to_s)

View file

@ -60,13 +60,13 @@ module Fiddle
func = Function.new(@libc['strcpy'], [TYPE_VOIDP, TYPE_VOIDP], TYPE_VOIDP) func = Function.new(@libc['strcpy'], [TYPE_VOIDP, TYPE_VOIDP], TYPE_VOIDP)
assert_nil Fiddle.last_error assert_nil Fiddle.last_error
func.call("000", "123") func.call(+"000", "123")
refute_nil Fiddle.last_error refute_nil Fiddle.last_error
end end
def test_strcpy def test_strcpy
f = Function.new(@libc['strcpy'], [TYPE_VOIDP, TYPE_VOIDP], TYPE_VOIDP) f = Function.new(@libc['strcpy'], [TYPE_VOIDP, TYPE_VOIDP], TYPE_VOIDP)
buff = "000" buff = +"000"
str = f.call(buff, "123") str = f.call(buff, "123")
assert_equal("123", buff) assert_equal("123", buff)
assert_equal("123", str.to_s) assert_equal("123", str.to_s)

View file

@ -128,7 +128,7 @@ module Fiddle
end end
def test_strcpy() def test_strcpy()
buff = "000" buff = +"000"
str = LIBC.strcpy(buff, "123") str = LIBC.strcpy(buff, "123")
assert_equal("123", buff) assert_equal("123", buff)
assert_equal("123", str.to_s) assert_equal("123", str.to_s)