Commit 074fefa5 authored by François Perrad's avatar François Perrad
Browse files

conversion to Test.Assertion

parent ac57a6c5
codes = true
max_line_length = 132
read_globals = {
-- tap (subset of Test.More)
-- tap (subset of Test.Assertion)
'plan',
'done_testing',
'skip_all',
'ok',
'nok',
'is',
'isnt',
'like',
'type_ok',
'pass',
'fail',
'truthy',
'falsy',
'equals',
'not_equals',
'matches',
'is_false', 'is_nil', 'is_true',
'is_boolean', 'is_cdata', 'is_function', 'is_number', 'is_string', 'is_table', 'is_thread', 'is_userdata',
'passes',
'fails',
'require_ok',
'eq_array',
'error_is',
'error_like',
'lives_ok',
'array_equals',
'error_equals',
'error_matches',
'not_errors',
'diag',
'skip',
'skip_rest',
......
......@@ -8,7 +8,7 @@
The directory `test_lua` contains the following files:
- *.t : test files written in Lua
- tap.lua : a minimal TAP library used when [Test.More](https://fperrad.frama.io/lua-TestMore/) is not available
- tap.lua : a minimal TAP library used when [Test.Assertion](https://fperrad.frama.io/lua-TestAssertion/) is not available
- profile*.lua : a set of predefined profile files, `profile.lua` is loaded by default.
- Makefile : an helper
......
......@@ -2,7 +2,7 @@
--
-- lua-Harness : <https://fperrad.frama.io/lua-Harness/>
--
-- Copyright (C) 2018, Perrad Francois
-- Copyright (C) 2018-2021, Perrad Francois
--
-- This code is licensed under the terms of the MIT/X11 license,
-- like Lua itself.
......@@ -25,9 +25,9 @@
require'tap'
plan(3)
ok( true, 'ok' )
is( 42, 42, '42 == 42' )
pass( 'pass' )
truthy( true, 'truthy' )
equals( 42, 42, '42 == 42' )
passes( 'pass' )
-- Local Variables:
-- mode: lua
......
......@@ -2,7 +2,7 @@
--
-- lua-Harness : <https://fperrad.frama.io/lua-Harness/>
--
-- Copyright (C) 2018, Perrad Francois
-- Copyright (C) 2018-2021, Perrad Francois
--
-- This code is licensed under the terms of the MIT/X11 license,
-- like Lua itself.
......@@ -26,14 +26,14 @@ require'tap'
plan'no_plan'
type_ok(_VERSION, 'string', "variable _VERSION")
like(_VERSION, '^Lua 5%.%d$')
is_string(_VERSION, "variable _VERSION")
matches(_VERSION, '^Lua 5%.%d$')
if jit then
type_ok(jit.version_num, 'number', "variable jit.version_num")
is_number(jit.version_num, "variable jit.version_num")
end
local profile = require_ok'profile'
require_ok'profile'
done_testing()
......
......@@ -2,7 +2,7 @@
--
-- lua-Harness : <https://fperrad.frama.io/lua-Harness/>
--
-- Copyright (C) 2009-2018, Perrad Francois
-- Copyright (C) 2009-2021, Perrad Francois
--
-- This code is licensed under the terms of the MIT/X11 license,
-- like Lua itself.
......@@ -27,91 +27,91 @@ local has_op53 = _VERSION >= 'Lua 5.3'
plan'no_plan'
error_like(function () return -true end,
"^[^:]+:%d+: attempt to perform arithmetic on a %w+ value",
"-true")
error_matches(function () return -true end,
"^[^:]+:%d+: attempt to perform arithmetic on a %w+ value",
"-true")
error_like(function () return #true end,
"^[^:]+:%d+: attempt to get length of a boolean value",
"#true")
error_matches(function () return #true end,
"^[^:]+:%d+: attempt to get length of a boolean value",
"#true")
is(not false, true, "not false")
equals(not false, true, "not false")
error_like(function () return true + 10 end,
"^[^:]+:%d+: attempt to perform arithmetic on a boolean value",
"true + 10")
error_matches(function () return true + 10 end,
"^[^:]+:%d+: attempt to perform arithmetic on a boolean value",
"true + 10")
error_like(function () return true - 2 end,
"^[^:]+:%d+: attempt to perform arithmetic on a boolean value",
"true - 2")
error_matches(function () return true - 2 end,
"^[^:]+:%d+: attempt to perform arithmetic on a boolean value",
"true - 2")
error_like(function () return true * 3.14 end,
"^[^:]+:%d+: attempt to perform arithmetic on a boolean value",
"true * 3.14")
error_matches(function () return true * 3.14 end,
"^[^:]+:%d+: attempt to perform arithmetic on a boolean value",
"true * 3.14")
error_like(function () return true / -7 end,
"^[^:]+:%d+: attempt to perform arithmetic on a boolean value",
"true / -7")
error_matches(function () return true / -7 end,
"^[^:]+:%d+: attempt to perform arithmetic on a boolean value",
"true / -7")
error_like(function () return true % 4 end,
"^[^:]+:%d+: attempt to perform arithmetic on a boolean value",
"true % 4")
error_matches(function () return true % 4 end,
"^[^:]+:%d+: attempt to perform arithmetic on a boolean value",
"true % 4")
error_like(function () return true ^ 3 end,
"^[^:]+:%d+: attempt to perform arithmetic on a boolean value",
"true ^ 3")
error_matches(function () return true ^ 3 end,
"^[^:]+:%d+: attempt to perform arithmetic on a boolean value",
"true ^ 3")
error_like(function () return true .. 'end' end,
"^[^:]+:%d+: attempt to concatenate a boolean value",
"true .. 'end'")
error_matches(function () return true .. 'end' end,
"^[^:]+:%d+: attempt to concatenate a boolean value",
"true .. 'end'")
is(true == true, true, "true == true")
equals(true == true, true, "true == true")
is(true ~= false, true, "true ~= false")
equals(true ~= false, true, "true ~= false")
is(true == 1, false, "true == 1")
equals(true == 1, false, "true == 1")
is(true ~= 1, true, "true ~= 1")
equals(true ~= 1, true, "true ~= 1")
error_like(function () return true < false end,
"^[^:]+:%d+: attempt to compare two boolean values",
"true < false")
error_matches(function () return true < false end,
"^[^:]+:%d+: attempt to compare two boolean values",
"true < false")
error_like(function () return true <= false end,
"^[^:]+:%d+: attempt to compare two boolean values",
"true <= false")
error_matches(function () return true <= false end,
"^[^:]+:%d+: attempt to compare two boolean values",
"true <= false")
error_like(function () return true > false end,
"^[^:]+:%d+: attempt to compare two boolean values",
"true > false")
error_matches(function () return true > false end,
"^[^:]+:%d+: attempt to compare two boolean values",
"true > false")
error_like(function () return true >= false end,
"^[^:]+:%d+: attempt to compare two boolean values",
"true >= false")
error_matches(function () return true >= false end,
"^[^:]+:%d+: attempt to compare two boolean values",
"true >= false")
error_like(function () return true < 0 end,
"^[^:]+:%d+: attempt to compare %w+ with %w+",
"true < 0")
error_matches(function () return true < 0 end,
"^[^:]+:%d+: attempt to compare %w+ with %w+",
"true < 0")
error_like(function () return true <= 0 end,
"^[^:]+:%d+: attempt to compare %w+ with %w+",
"true <= 0")
error_matches(function () return true <= 0 end,
"^[^:]+:%d+: attempt to compare %w+ with %w+",
"true <= 0")
error_like(function () return true > 0 end,
"^[^:]+:%d+: attempt to compare %w+ with %w+",
"true > 0")
error_matches(function () return true > 0 end,
"^[^:]+:%d+: attempt to compare %w+ with %w+",
"true > 0")
error_like(function () return true >= 0 end,
"^[^:]+:%d+: attempt to compare %w+ with %w+",
"true >= 0")
error_matches(function () return true >= 0 end,
"^[^:]+:%d+: attempt to compare %w+ with %w+",
"true >= 0")
error_like(function () local a = true; local b = a[1]; end,
"^[^:]+:%d+: attempt to index",
"index")
error_matches(function () local a = true; local b = a[1]; end,
"^[^:]+:%d+: attempt to index",
"index")
error_like(function () local a = true; a[1] = 1; end,
"^[^:]+:%d+: attempt to index",
"index")
error_matches(function () local a = true; a[1] = 1; end,
"^[^:]+:%d+: attempt to index",
"index")
if has_op53 then
dofile'lexico53/boolean.t'
......
......@@ -2,7 +2,7 @@
--
-- lua-Harness : <https://fperrad.frama.io/lua-Harness/>
--
-- Copyright (C) 2009-2018, Perrad Francois
-- Copyright (C) 2009-2021, Perrad Francois
--
-- This code is licensed under the terms of the MIT/X11 license,
-- like Lua itself.
......@@ -29,168 +29,168 @@ plan'no_plan'
local f = function () return 1 end
error_like(function () return -f end,
"^[^:]+:%d+: attempt to perform arithmetic on",
"-f")
error_matches(function () return -f end,
"^[^:]+:%d+: attempt to perform arithmetic on",
"-f")
error_like(function () f = print; return -f end,
"^[^:]+:%d+: attempt to perform arithmetic on")
error_matches(function () f = print; return -f end,
"^[^:]+:%d+: attempt to perform arithmetic on")
error_like(function () return #f end,
"^[^:]+:%d+: attempt to get length of",
"#f")
error_matches(function () return #f end,
"^[^:]+:%d+: attempt to get length of",
"#f")
error_like(function () f = print; return #f end,
"^[^:]+:%d+: attempt to get length of")
error_matches(function () f = print; return #f end,
"^[^:]+:%d+: attempt to get length of")
is(not f, false, "not f")
equals(not f, false, "not f")
is(not print, false)
equals(not print, false)
error_like(function () return f + 10 end,
"^[^:]+:%d+: attempt to perform arithmetic on",
"f + 10")
error_matches(function () return f + 10 end,
"^[^:]+:%d+: attempt to perform arithmetic on",
"f + 10")
error_like(function () f = print; return f + 10 end,
"^[^:]+:%d+: attempt to perform arithmetic on")
error_matches(function () f = print; return f + 10 end,
"^[^:]+:%d+: attempt to perform arithmetic on")
error_like(function () return f - 2 end,
"^[^:]+:%d+: attempt to perform arithmetic on",
"f - 2")
error_matches(function () return f - 2 end,
"^[^:]+:%d+: attempt to perform arithmetic on",
"f - 2")
error_like(function () f = print; return f - 2 end,
"^[^:]+:%d+: attempt to perform arithmetic on")
error_matches(function () f = print; return f - 2 end,
"^[^:]+:%d+: attempt to perform arithmetic on")
error_like(function () return f * 3.14 end,
"^[^:]+:%d+: attempt to perform arithmetic on",
"f * 3.14")
error_matches(function () return f * 3.14 end,
"^[^:]+:%d+: attempt to perform arithmetic on",
"f * 3.14")
error_like(function () f = print; return f * 3.14 end,
"^[^:]+:%d+: attempt to perform arithmetic on")
error_matches(function () f = print; return f * 3.14 end,
"^[^:]+:%d+: attempt to perform arithmetic on")
error_like(function () return f / -7 end,
"^[^:]+:%d+: attempt to perform arithmetic on",
"f / -7")
error_matches(function () return f / -7 end,
"^[^:]+:%d+: attempt to perform arithmetic on",
"f / -7")
error_like(function () f = print; return f / -7 end,
"^[^:]+:%d+: attempt to perform arithmetic on")
error_matches(function () f = print; return f / -7 end,
"^[^:]+:%d+: attempt to perform arithmetic on")
error_like(function () return f % 4 end,
"^[^:]+:%d+: attempt to perform arithmetic on",
"f % 4")
error_matches(function () return f % 4 end,
"^[^:]+:%d+: attempt to perform arithmetic on",
"f % 4")
error_like(function () f = print; return f % 4 end,
"^[^:]+:%d+: attempt to perform arithmetic on")
error_matches(function () f = print; return f % 4 end,
"^[^:]+:%d+: attempt to perform arithmetic on")
error_like(function () return f ^ 3 end,
"^[^:]+:%d+: attempt to perform arithmetic on",
"f ^ 3")
error_matches(function () return f ^ 3 end,
"^[^:]+:%d+: attempt to perform arithmetic on",
"f ^ 3")
error_like(function () f = print; return f ^ 3 end,
"^[^:]+:%d+: attempt to perform arithmetic on")
error_matches(function () f = print; return f ^ 3 end,
"^[^:]+:%d+: attempt to perform arithmetic on")
error_like(function () return f .. 'end' end,
"^[^:]+:%d+: attempt to concatenate",
"f .. 'end'")
error_matches(function () return f .. 'end' end,
"^[^:]+:%d+: attempt to concatenate",
"f .. 'end'")
error_like(function () f = print; return f .. 'end' end,
"^[^:]+:%d+: attempt to concatenate")
error_matches(function () f = print; return f .. 'end' end,
"^[^:]+:%d+: attempt to concatenate")
local g = f
is(f == g, true, "f == f")
equals(f == g, true, "f == f")
g = print
is(g == print, true)
equals(g == print, true)
g = function () return 2 end
is(f ~= g, true, "f ~= g")
equals(f ~= g, true, "f ~= g")
local h = type
is(f ~= h, true)
equals(f ~= h, true)
is(print ~= g, true)
is(print ~= h, true)
equals(print ~= g, true)
equals(print ~= h, true)
is(f == 1, false, "f == 1")
equals(f == 1, false, "f == 1")
is(print == 1, false)
equals(print == 1, false)
is(f ~= 1, true, "f ~= 1")
equals(f ~= 1, true, "f ~= 1")
is(print ~= 1, true)
equals(print ~= 1, true)
error_like(function () return f < g end,
"^[^:]+:%d+: attempt to compare two function values",
"f < g")
error_matches(function () return f < g end,
"^[^:]+:%d+: attempt to compare two function values",
"f < g")
error_like(function () f = print; g = type; return f < g end,
"^[^:]+:%d+: attempt to compare two function values")
error_matches(function () f = print; g = type; return f < g end,
"^[^:]+:%d+: attempt to compare two function values")
error_like(function () return f <= g end,
"^[^:]+:%d+: attempt to compare two function values",
"f <= g")
error_matches(function () return f <= g end,
"^[^:]+:%d+: attempt to compare two function values",
"f <= g")
error_like(function () f = print; g = type; return f <= g end,
"^[^:]+:%d+: attempt to compare two function values")
error_matches(function () f = print; g = type; return f <= g end,
"^[^:]+:%d+: attempt to compare two function values")
error_like(function () return f > g end,
"^[^:]+:%d+: attempt to compare two function values",
"f > g")
error_matches(function () return f > g end,
"^[^:]+:%d+: attempt to compare two function values",
"f > g")
error_like(function () f = print; g = type; return f > g end,
"^[^:]+:%d+: attempt to compare two function values")
error_matches(function () f = print; g = type; return f > g end,
"^[^:]+:%d+: attempt to compare two function values")
error_like(function () return f >= g end,
"^[^:]+:%d+: attempt to compare two function values",
"f >= g")
error_matches(function () return f >= g end,
"^[^:]+:%d+: attempt to compare two function values",
"f >= g")
error_like(function () f = print; g = type; return f >= g end,
"^[^:]+:%d+: attempt to compare two function values")
error_matches(function () f = print; g = type; return f >= g end,
"^[^:]+:%d+: attempt to compare two function values")
error_like(function () return f < 0 end,
"^[^:]+:%d+: attempt to compare %w+ with %w+",
"f < 0")
error_matches(function () return f < 0 end,
"^[^:]+:%d+: attempt to compare %w+ with %w+",
"f < 0")
error_like(function () f = print; return f < 0 end,
"^[^:]+:%d+: attempt to compare %w+ with %w+")
error_matches(function () f = print; return f < 0 end,
"^[^:]+:%d+: attempt to compare %w+ with %w+")
error_like(function () return f <= 0 end,
"^[^:]+:%d+: attempt to compare %w+ with %w+",
"f <= 0")
error_matches(function () return f <= 0 end,
"^[^:]+:%d+: attempt to compare %w+ with %w+",
"f <= 0")
error_like(function () f = print; return f <= 0 end,
"^[^:]+:%d+: attempt to compare %w+ with %w+")
error_matches(function () f = print; return f <= 0 end,
"^[^:]+:%d+: attempt to compare %w+ with %w+")
error_like(function () return f > 0 end,
"^[^:]+:%d+: attempt to compare %w+ with %w+",
"f > 0")
error_matches(function () return f > 0 end,
"^[^:]+:%d+: attempt to compare %w+ with %w+",
"f > 0")
error_like(function () f = print; return f > 0 end,
"^[^:]+:%d+: attempt to compare %w+ with %w+")
error_matches(function () f = print; return f > 0 end,
"^[^:]+:%d+: attempt to compare %w+ with %w+")
error_like(function () return f > 0 end,
"^[^:]+:%d+: attempt to compare %w+ with %w+",
"f >= 0")
error_matches(function () return f > 0 end,
"^[^:]+:%d+: attempt to compare %w+ with %w+",
"f >= 0")
error_like(function () f = print; return f >= 0 end,
"^[^:]+:%d+: attempt to compare %w+ with %w+")
error_matches(function () f = print; return f >= 0 end,
"^[^:]+:%d+: attempt to compare %w+ with %w+")
error_like(function () local a = f; local b = a[1]; end,
"^[^:]+:%d+: attempt to index",
"index")
error_matches(function () local a = f; local b = a[1]; end,
"^[^:]+:%d+: attempt to index",
"index")
error_like(function () local a = print; local b = a[1]; end,
"^[^:]+:%d+: attempt to index")
error_matches(function () local a = print; local b = a[1]; end,
"^[^:]+:%d+: attempt to index")
error_like(function () local a = f; a[1] = 1; end,
"^[^:]+:%d+: attempt to index",
"index")
error_matches(function () local a = f; a[1] = 1; end,
"^[^:]+:%d+: attempt to index",
"index")
error_like(function () local a = print; a[1] = 1; end,
"^[^:]+:%d+: attempt to index")
error_matches(function () local a = print; a[1] = 1; end,
"^[^:]+:%d+: attempt to index")
local t = {}
t[print] = true
ok(t[print])
truthy(t[print])
if has_op53 then
dofile'lexico53/function.t'
......
......@@ -2,7 +2,7 @@
--
-- lua-Harness : <https://fperrad.frama.io/lua-Harness/>
--
-- Copyright (C) 2009-2018, Perrad Francois
-- Copyright (C) 2009-2021, Perrad Francois
--
-- This code is licensed under the terms of the MIT/X11 license,
-- like Lua itself.
......@@ -27,91 +27,91 @@ local has_op53 = _VERSION >= 'Lua 5.3'
plan'no_plan'
error_like(function () return -nil end,
"^[^:]+:%d+: attempt to perform arithmetic on a nil value",
"-nil")
error_matches(function () return -nil end,
"^[^:]+:%d+: attempt to perform arithmetic on a nil value",
"-nil")
error_like(function () return #nil end,
"^[^:]+:%d+: attempt to get length of a nil value",
"#nil")
error_matches(function () return #nil end,
"^[^:]+:%d+: attempt to get length of a nil value",
"#nil")
is(not nil, true, "not nil")
equals(not nil, true, "not nil")
error_like(function () return nil + 10 end,
"^[^:]+:%d+: attempt to perform arithmetic on a nil value",
"nil + 10")
error_matches(function () return nil + 10 end,
"^[^:]+:%d+: attempt to perform arithmetic on a nil value",
"nil + 10")
error_like(function () return nil - 2 end,
"^[^:]+:%d+: attempt to perform arithmetic on a nil value",
"nil - 2")
error_matches(function () return nil - 2 end,
"^[^:]+:%d+: attempt to perform arithmetic on a nil value",
"nil - 2")
error_like(function () return nil * 3.14 end,
"^[^:]+:%d+: attempt to perform arithmetic on a nil value",
"nil * 3.14")
error_matches(function () return nil * 3.14 end,
"^[^:]+:%d+: attempt to perform arithmetic on a nil value",
"nil * 3.14")