Joined common code in 'lua_rawset' and 'lua_rawsetp'

This commit is contained in:
Roberto Ierusalimschy
2019-12-17 15:45:13 -03:00
parent e0ab13c62f
commit c646e57fd6
3 changed files with 25 additions and 23 deletions

View File

@@ -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