From 379b86fdea9f01c4bbff7fe66dec5a659ae82b27 Mon Sep 17 00:00:00 2001 From: Benoit Giannangeli Date: Fri, 24 Mar 2017 14:28:18 +0100 Subject: string.format operate on byte array instead of js strings --- tests/single.lua | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'tests') diff --git a/tests/single.lua b/tests/single.lua index f74c096..e206568 100644 --- a/tests/single.lua +++ b/tests/single.lua @@ -138,3 +138,15 @@ if math.tointeger(4611686018427387904) then -- no overflow? (64 bits) assert(tostring(4611686018427387904) == "4611686018427387904") assert(tostring(-4611686018427387904) == "-4611686018427387904") end + +if tostring(0.0) == "0.0" then -- "standard" coercion float->string + assert('' .. 12 == '12' and 12.0 .. '' == '12.0') + assert(tostring(-1203 + 0.0) == "-1203.0") +else -- compatible coercion + assert(tostring(0.0) == "0") + assert('' .. 12 == '12' and 12.0 .. '' == '12') + assert(tostring(-1203 + 0.0) == "-1203") +end + +x = '"ílo"\n\\' +assert(string.format('%q%s', x, x) == '"\\"ílo\\"\\\n\\\\""ílo"\n\\') -- cgit v1.2.3-70-g09d2