From 16cdb860e9e8e5550c1178a41eabb52e461ffa46 Mon Sep 17 00:00:00 2001 From: Benoit Giannangeli Date: Fri, 24 Mar 2017 11:58:00 +0100 Subject: TValue.id to print something when tostring({}) --- tests/single.lua | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) (limited to 'tests') diff --git a/tests/single.lua b/tests/single.lua index d9b6ce9..4960b11 100644 --- a/tests/single.lua +++ b/tests/single.lua @@ -105,3 +105,29 @@ if string.packsize("i") == 4 then checkerror("too large", string.rep, 'aa', (1 << 30)) checkerror("too large", string.rep, 'a', (1 << 30), ',') end + +-- repetitions with separator +assert(string.rep('teste', 0, 'xuxu') == '') +assert(string.rep('teste', 1, 'xuxu') == 'teste') +assert(string.rep('\1\0\1', 2, '\0\0') == '\1\0\1\0\0\1\0\1') +assert(string.rep('', 10, '.') == string.rep('.', 9)) +assert(not pcall(string.rep, "aa", maxi // 2 + 10)) +assert(not pcall(string.rep, "", maxi // 2 + 10, "aa")) + +assert(string.reverse"" == "") +assert(string.reverse"\0\1\2\3" == "\3\2\1\0") +assert(string.reverse"\0001234" == "4321\0") + +for i=0,30 do assert(string.len(string.rep('a', i)) == i) end + +assert(type(tostring(nil)) == 'string') +assert(type(tostring(12)) == 'string') +assert(string.find(tostring{}, 'table:')) +assert(string.find(tostring(print), 'function:')) +assert(#tostring('\0') == 1) +assert(tostring(true) == "true") +assert(tostring(false) == "false") +assert(tostring(-1203) == "-1203") +assert(tostring(1203.125) == "1203.125") +assert(tostring(-0.5) == "-0.5") +assert(tostring(-32767) == "-32767") -- cgit v1.2.3-70-g09d2