Joined common code in 'lua_rawset' and 'lua_rawsetp'
This commit is contained in:
@@ -516,9 +516,11 @@ print"+"
|
||||
|
||||
do -- getp/setp
|
||||
local a = {}
|
||||
T.testC("rawsetp 2 1", a, 20)
|
||||
local a1 = T.testC("rawsetp 2 1; return 1", a, 20)
|
||||
assert(a == a1)
|
||||
assert(a[T.pushuserdata(1)] == 20)
|
||||
assert(T.testC("rawgetp -1 1; return 1", a) == 20)
|
||||
local a1, res = T.testC("rawgetp -1 1; return 2", a)
|
||||
assert(a == a1 and res == 20)
|
||||
end
|
||||
|
||||
|
||||
|
||||
@@ -161,18 +161,21 @@ do -- tests for '%p' format
|
||||
local null = string.format("%p", nil)
|
||||
assert(string.format("%p", {}) ~= null)
|
||||
assert(string.format("%p", 4) == null)
|
||||
assert(string.format("%p", true) == null)
|
||||
assert(string.format("%p", print) ~= null)
|
||||
assert(string.format("%p", coroutine.running()) ~= null)
|
||||
assert(string.format("%p", io.stdin) ~= null)
|
||||
assert(string.format("%p", io.stdin) == string.format("%p", io.stdin))
|
||||
do
|
||||
local t1 = {}; local t2 = {}
|
||||
assert(string.format("%p", t1) ~= string.format("%p", t2))
|
||||
end
|
||||
do -- short strings
|
||||
do -- short strings are internalized
|
||||
local s1 = string.rep("a", 10)
|
||||
local s2 = string.rep("a", 10)
|
||||
assert(string.format("%p", s1) == string.format("%p", s2))
|
||||
end
|
||||
do -- long strings
|
||||
do -- long strings aren't internalized
|
||||
local s1 = string.rep("a", 300); local s2 = string.rep("a", 300)
|
||||
assert(string.format("%p", s1) ~= string.format("%p", s2))
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user