From d5d461b564299b112e4c9611998a0ee385d68bd6 Mon Sep 17 00:00:00 2001 From: Francois Perrad Date: Sat, 23 Sep 2017 09:23:54 +0200 Subject: add a Lua 5.3 variant without implicit number/string coercion --- .travis.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 3cd431f..fdc86fe 100644 --- a/.travis.yml +++ b/.travis.yml @@ -7,6 +7,7 @@ env: - LUA="lua 5.2" COMPAT=none - LUA="lua 5.3" COMPAT=default - LUA="lua 5.3" COMPAT=none + - LUA="lua 5.3" COMPAT=default CFLAGS="-DLUA_NOCVTN2S -DLUA_NOCVTS2N" - LUA="luajit 2.0" COMPAT=none - LUA="luajit 2.0" COMPAT=all - LUA="luajit 2.1" COMPAT=none @@ -14,7 +15,7 @@ env: before_install: - pip install hererocks - - hererocks HERE --$LUA --compat $COMPAT --no-readline --luarocks latest --verbose + - hererocks HERE --$LUA --compat $COMPAT --cflags="$CFLAGS" --no-readline --luarocks latest --verbose - hererocks HERE --show - source HERE/bin/activate -- cgit v1.2.3-54-g00ecf From 28b2fc636d658daaf1a64f57e137b78d4330b2b6 Mon Sep 17 00:00:00 2001 From: Francois Perrad Date: Sat, 23 Sep 2017 09:29:47 +0200 Subject: use explicit tostring --- valua-test.lua | 2 +- valua.lua | 9 +++++---- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/valua-test.lua b/valua-test.lua index a4cb0dd..c12a1a4 100644 --- a/valua-test.lua +++ b/valua-test.lua @@ -3,7 +3,7 @@ local passing = true local function check(val_test, test_value, expected, n) local res,err = val_test(test_value) - local msg = "Validation "..n.." " + local msg = "Validation "..tostring(n).." " if res == expected then msg = msg.. "succeeded" diff --git a/valua.lua b/valua.lua index cf5a536..6e1c6e4 100644 --- a/valua.lua +++ b/valua.lua @@ -19,7 +19,8 @@ -- reusable_validation("test!") -- true -- -local tinsert,setmetatable,len,match,tonumber = table.insert,setmetatable,string.len,string.match,tonumber +local tinsert,setmetatable,len,match = table.insert,setmetatable,string.len,string.match +local tonumber,tostring = tonumber,tostring local next,type,floor,ipairs = next,type,math.floor, ipairs local unpack = unpack or table.unpack local pack = table.pack or function(...) return { n = select('#', ...), ... } end @@ -86,7 +87,7 @@ end -- String function valua._len(value,min,max) local l = len(value or '') - if l < min or l > max then return false,"should have "..min.."-"..max.." characters" end + if l < min or l > max then return false,"should have "..tostring(min).."-"..tostring(max).." characters" end return true end @@ -125,12 +126,12 @@ end -- Numbers function valua._min(value,n) - if not empty(value) and value < n then return false,"must be greater than "..n end + if not empty(value) and value < n then return false,"must be greater than "..tostring(n) end return true end function valua._max(value,n) - if not empty(value) and value > n then return false,"must not be greater than "..n end + if not empty(value) and value > n then return false,"must not be greater than "..tostring(n) end return true end -- cgit v1.2.3-54-g00ecf