Commit 951d9907 authored by François Perrad's avatar François Perrad
Browse files

switch to Test.Assertion

parent ee4c4f23
Pipeline #393387 passed with stages
in 29 seconds
......@@ -5,27 +5,22 @@ read_globals = {
'done_testing',
'skip_all',
'BAIL_OUT',
'ok',
'nok',
'is',
'isnt',
'like',
'unlike',
'cmp_ok',
'type_ok',
'subtest',
'pass',
'fail',
'require_ok',
'eq_array',
'is_deeply',
'error_is',
'error_like',
'lives_ok',
'diag',
'note',
'skip',
'todo_skip',
'skip_rest',
'todo',
-- Test.Assertion
'equals',
'array_equals',
'is_function',
'is_string',
'is_table',
'falsy',
'truthy',
'matches',
'error_matches',
'require_ok',
}
......@@ -101,7 +101,7 @@ deb:
bed:
hererocks bed $(BED_OPTS) --no-readline --luarocks latest --verbose
bed/bin/luarocks install lua-testmore
bed/bin/luarocks install lua-testassertion
bed/bin/luarocks install lrexlib-pcre
bed/bin/luarocks install luafilesystem
bed/bin/luarocks install luaposix
......
#!/usr/bin/env lua
require 'Test.More'
require 'Test.Assertion'
plan(10)
......@@ -9,15 +9,15 @@ if not require_ok 'Silva' then
end
local m = require 'Silva'
type_ok( m, 'table' )
is( m, package.loaded.Silva )
is_table( m )
equals( m, package.loaded.Silva )
type_ok( m.matcher, 'function', 'matcher' )
type_ok( m.array_matcher, 'function', 'array_matcher' )
is_function( m.matcher, 'matcher' )
is_function( m.array_matcher, 'array_matcher' )
is( m._NAME, 'Silva', "_NAME" )
like( m._COPYRIGHT, 'Perrad', "_COPYRIGHT" )
like( m._DESCRIPTION, 'string matching expert', "_DESCRIPTION" )
type_ok( m._VERSION, 'string', "_VERSION" )
like( m._VERSION, '^%d%.%d%.%d$' )
equals( m._NAME, 'Silva', "_NAME" )
matches( m._COPYRIGHT, 'Perrad', "_COPYRIGHT" )
matches( m._DESCRIPTION, 'string matching expert', "_DESCRIPTION" )
is_string( m._VERSION, "_VERSION" )
matches( m._VERSION, '^%d%.%d%.%d$' )
#!/usr/bin/env lua
require 'Test.More'
require 'Test.Assertion'
plan(5)
local sme = require 'Silva'
local sme0 = sme('/foo/bar', 'identity')
ok( sme0('/foo/bar'), 'same string' )
nok( sme0('/foo/baz') )
truthy( sme0('/foo/bar'), 'same string' )
falsy( sme0('/foo/baz') )
local sme1 = sme'/foo/{var}'
local t = sme1('/foo/bar')
type_ok( t, 'table' )
is( t.var, 'bar' )
nok( sme1('/bar/baz') )
is_table( t )
equals( t.var, 'bar' )
falsy( sme1('/bar/baz') )
#!/usr/bin/env lua
require 'Test.More'
require 'Test.Assertion'
plan(4)
local ctor = require 'Silva.identity'
type_ok( ctor, 'function' )
is_function( ctor )
local sme0 = ctor'/foo/bar'
ok( sme0('/foo/bar'), 'same string' )
nok( sme0('/foo/baz') )
nok( sme0('/foo/bar/baz') )
truthy( sme0('/foo/bar'), 'same string' )
falsy( sme0('/foo/baz') )
falsy( sme0('/foo/bar/baz') )
#!/usr/bin/env lua
require 'Test.More'
require 'Test.Assertion'
plan(8)
local ctor = require 'Silva.lua'
type_ok( ctor, 'function' )
is_function( ctor )
local sme0 = ctor'^hello'
local sme1 = ctor'^(h.ll.)'
local sme2 = ctor'^(h.)l(l.)'
ok( sme0('hello') )
ok( sme0('hello world') )
nok( sme0('Hello world') )
truthy( sme0('hello') )
truthy( sme0('hello world') )
falsy( sme0('Hello world') )
eq_array( sme1('hello world'), {'hello'})
nok( sme1('Hello world') )
array_equals( sme1('hello world'), {'hello'})
falsy( sme1('Hello world') )
eq_array( sme2('hello world'), {'he', 'lo'})
nok( sme2('Hello world') )
array_equals( sme2('hello world'), {'he', 'lo'})
falsy( sme2('Hello world') )
#!/usr/bin/env lua
require 'Test.More'
require 'Test.Assertion'
if not pcall(require, 'rex_pcre') then
skip_all 'no rex_pcre'
......@@ -10,17 +10,17 @@ plan(7)
local ctor = require 'Silva.pcre'
type_ok( ctor, 'function' )
is_function( ctor )
local sme0 = ctor'^hello'
local sme1 = ctor'^(h.ll.)'
local sme2 = ctor'^(h.)l(l.)'
ok( sme0('hello world') )
nok( sme0('Hello world') )
truthy( sme0('hello world') )
falsy( sme0('Hello world') )
eq_array( sme1('hello world'), {'hello'})
nok( sme1('Hello world') )
array_equals( sme1('hello world'), {'hello'})
falsy( sme1('Hello world') )
eq_array( sme2('hello world'), {'he', 'lo'})
nok( sme2('Hello world') )
array_equals( sme2('hello world'), {'he', 'lo'})
falsy( sme2('Hello world') )
#!/usr/bin/env lua
require 'Test.More'
require 'Test.Assertion'
plan(40)
local ctor = require 'Silva.shell'
type_ok( ctor, 'function' )
is_function( ctor )
local sme0 = ctor'foo.c'
ok( sme0, 'foo.c' )
ok( sme0'foo.c' )
nok( sme0'foo.cpp' )
nok( sme0'foo.h' )
nok( sme0'foo' )
nok( sme0'bar' )
truthy( sme0, 'foo.c' )
truthy( sme0'foo.c' )
falsy( sme0'foo.cpp' )
falsy( sme0'foo.h' )
falsy( sme0'foo' )
falsy( sme0'bar' )
local sme1 = ctor'foo?bar'
ok( sme1, 'foo?bar' )
ok( sme1'foo0bar' )
nok( sme1'foo0baz' )
nok( sme1'foo' )
nok( sme1'foo/bar' )
truthy( sme1, 'foo?bar' )
truthy( sme1'foo0bar' )
falsy( sme1'foo0baz' )
falsy( sme1'foo' )
falsy( sme1'foo/bar' )
local sme2 = ctor'foo???baz'
ok( sme2, 'foo???baz' )
ok( sme2'foobarbaz' )
nok( sme2'foobarbar' )
truthy( sme2, 'foo???baz' )
truthy( sme2'foobarbaz' )
falsy( sme2'foobarbar' )
local sme3 = ctor'?foo'
ok( sme3, '?foo' )
ok( sme3'0foo' )
nok( sme3'.foo' )
truthy( sme3, '?foo' )
truthy( sme3'0foo' )
falsy( sme3'.foo' )
local sme4 = ctor'foo*'
ok( sme4, 'foo*' )
ok( sme4'foo' )
ok( sme4'foo0' )
ok( sme4'foo00' )
ok( sme4'foo000' )
ok( sme4'foo/000' )
truthy( sme4, 'foo*' )
truthy( sme4'foo' )
truthy( sme4'foo0' )
truthy( sme4'foo00' )
truthy( sme4'foo000' )
truthy( sme4'foo/000' )
local sme5 = ctor'foo*?'
ok( sme5, 'foo*?' )
nok( sme5'foo' )
ok( sme5'foo0' )
ok( sme5'foo00' )
ok( sme5'foo000' )
ok( sme5'foo.000' )
nok( sme5'foo/000' )
truthy( sme5, 'foo*?' )
falsy( sme5'foo' )
truthy( sme5'foo0' )
truthy( sme5'foo00' )
truthy( sme5'foo000' )
truthy( sme5'foo.000' )
falsy( sme5'foo/000' )
local sme6 = ctor'*.c'
ok( sme6, '*.c' )
ok( sme6'foo.c' )
nok( sme6'foo.cpp' )
nok( sme6'foo.h' )
nok( sme6'.foo.c' )
truthy( sme6, '*.c' )
truthy( sme6'foo.c' )
falsy( sme6'foo.cpp' )
falsy( sme6'foo.h' )
falsy( sme6'.foo.c' )
local sme7 = ctor'foo/*/*.t'
ok( sme7, 'foo/*/*.t' )
ok( sme7'foo/bar/baz.t' )
nok( sme7'foo/bak/.baz.t' )
nok( sme7'foo/.bak/baz.t' )
truthy( sme7, 'foo/*/*.t' )
truthy( sme7'foo/bar/baz.t' )
falsy( sme7'foo/bak/.baz.t' )
falsy( sme7'foo/.bak/baz.t' )
#!/usr/bin/env lua
require 'Test.More'
require 'Test.Assertion'
plan(166)
......@@ -8,219 +8,219 @@ local ctor = require 'Silva.shell'
local sme0, sme1
sme0 = ctor'foo[1234]bar'
ok( sme0, 'foo[1234]bar' )
nok( sme0'foo0bar' )
ok( sme0'foo1bar' )
ok( sme0'foo2bar' )
ok( sme0'foo3bar' )
ok( sme0'foo4bar' )
nok( sme0'foo5bar' )
truthy( sme0, 'foo[1234]bar' )
falsy( sme0'foo0bar' )
truthy( sme0'foo1bar' )
truthy( sme0'foo2bar' )
truthy( sme0'foo3bar' )
truthy( sme0'foo4bar' )
falsy( sme0'foo5bar' )
sme1 = ctor'foo[^1234]bar'
ok( sme1, 'foo[^1234]bar' )
ok( sme1'foo0bar' )
nok( sme1'foo1bar' )
nok( sme1'foo2bar' )
nok( sme1'foo3bar' )
nok( sme1'foo4bar' )
ok( sme1'foo5bar' )
truthy( sme1, 'foo[^1234]bar' )
truthy( sme1'foo0bar' )
falsy( sme1'foo1bar' )
falsy( sme1'foo2bar' )
falsy( sme1'foo3bar' )
falsy( sme1'foo4bar' )
truthy( sme1'foo5bar' )
sme0 = ctor'foo[1-4]bar'
ok( sme0, 'foo[1-4]bar' )
nok( sme0'foo0bar' )
ok( sme0'foo1bar' )
ok( sme0'foo2bar' )
ok( sme0'foo3bar' )
ok( sme0'foo4bar' )
nok( sme0'foo5bar' )
truthy( sme0, 'foo[1-4]bar' )
falsy( sme0'foo0bar' )
truthy( sme0'foo1bar' )
truthy( sme0'foo2bar' )
truthy( sme0'foo3bar' )
truthy( sme0'foo4bar' )
falsy( sme0'foo5bar' )
sme1 = ctor'foo[^1-4]bar'
ok( sme1, 'foo[^1-4]bar' )
ok( sme1'foo0bar' )
nok( sme1'foo1bar' )
nok( sme1'foo2bar' )
nok( sme1'foo3bar' )
nok( sme1'foo4bar' )
ok( sme1'foo5bar' )
truthy( sme1, 'foo[^1-4]bar' )
truthy( sme1'foo0bar' )
falsy( sme1'foo1bar' )
falsy( sme1'foo2bar' )
falsy( sme1'foo3bar' )
falsy( sme1'foo4bar' )
truthy( sme1'foo5bar' )
sme0 = ctor'foo[12-4]bar'
ok( sme0, 'foo[12-4]bar' )
nok( sme0'foo0bar' )
ok( sme0'foo1bar' )
ok( sme0'foo2bar' )
ok( sme0'foo3bar' )
ok( sme0'foo4bar' )
nok( sme0'foo5bar' )
truthy( sme0, 'foo[12-4]bar' )
falsy( sme0'foo0bar' )
truthy( sme0'foo1bar' )
truthy( sme0'foo2bar' )
truthy( sme0'foo3bar' )
truthy( sme0'foo4bar' )
falsy( sme0'foo5bar' )
sme1 = ctor'foo[^12-4]bar'
ok( sme1, 'foo[^12-4]bar' )
ok( sme1'foo0bar' )
nok( sme1'foo1bar' )
nok( sme1'foo2bar' )
nok( sme1'foo3bar' )
nok( sme1'foo4bar' )
ok( sme1'foo5bar' )
truthy( sme1, 'foo[^12-4]bar' )
truthy( sme1'foo0bar' )
falsy( sme1'foo1bar' )
falsy( sme1'foo2bar' )
falsy( sme1'foo3bar' )
falsy( sme1'foo4bar' )
truthy( sme1'foo5bar' )
sme0 = ctor'foo[123-4]bar'
ok( sme0, 'foo[123-4]bar' )
nok( sme0'foo0bar' )
ok( sme0'foo1bar' )
ok( sme0'foo2bar' )
ok( sme0'foo3bar' )
ok( sme0'foo4bar' )
nok( sme0'foo5bar' )
truthy( sme0, 'foo[123-4]bar' )
falsy( sme0'foo0bar' )
truthy( sme0'foo1bar' )
truthy( sme0'foo2bar' )
truthy( sme0'foo3bar' )
truthy( sme0'foo4bar' )
falsy( sme0'foo5bar' )
sme1 = ctor'foo[^123-4]bar'
ok( sme1, 'foo[^123-4]bar' )
ok( sme1'foo0bar' )
nok( sme1'foo1bar' )
nok( sme1'foo2bar' )
nok( sme1'foo3bar' )
nok( sme1'foo4bar' )
ok( sme1'foo5bar' )
truthy( sme1, 'foo[^123-4]bar' )
truthy( sme1'foo0bar' )
falsy( sme1'foo1bar' )
falsy( sme1'foo2bar' )
falsy( sme1'foo3bar' )
falsy( sme1'foo4bar' )
truthy( sme1'foo5bar' )
sme0 = ctor'foo[12-34]bar'
ok( sme0, 'foo[12-34]bar' )
nok( sme0'foo0bar' )
ok( sme0'foo1bar' )
ok( sme0'foo2bar' )
ok( sme0'foo3bar' )
ok( sme0'foo4bar' )
nok( sme0'foo5bar' )
truthy( sme0, 'foo[12-34]bar' )
falsy( sme0'foo0bar' )
truthy( sme0'foo1bar' )
truthy( sme0'foo2bar' )
truthy( sme0'foo3bar' )
truthy( sme0'foo4bar' )
falsy( sme0'foo5bar' )
sme1 = ctor'foo[^12-34]bar'
ok( sme1, 'foo[^12-34]bar' )
ok( sme1'foo0bar' )
nok( sme1'foo1bar' )
nok( sme1'foo2bar' )
nok( sme1'foo3bar' )
nok( sme1'foo4bar' )
ok( sme1'foo5bar' )
truthy( sme1, 'foo[^12-34]bar' )
truthy( sme1'foo0bar' )
falsy( sme1'foo1bar' )
falsy( sme1'foo2bar' )
falsy( sme1'foo3bar' )
falsy( sme1'foo4bar' )
truthy( sme1'foo5bar' )
sme0 = ctor'foo[1-234]bar'
ok( sme0, 'foo[1-234]bar' )
nok( sme0'foo0bar' )
ok( sme0'foo1bar' )
ok( sme0'foo2bar' )
ok( sme0'foo3bar' )
ok( sme0'foo4bar' )
nok( sme0'foo5bar' )
truthy( sme0, 'foo[1-234]bar' )
falsy( sme0'foo0bar' )
truthy( sme0'foo1bar' )
truthy( sme0'foo2bar' )
truthy( sme0'foo3bar' )
truthy( sme0'foo4bar' )
falsy( sme0'foo5bar' )
sme1 = ctor'foo[^1-234]bar'
ok( sme1, 'foo[^1-234]bar' )
ok( sme1'foo0bar' )
nok( sme1'foo1bar' )
nok( sme1'foo2bar' )
nok( sme1'foo3bar' )
nok( sme1'foo4bar' )
ok( sme1'foo5bar' )
truthy( sme1, 'foo[^1-234]bar' )
truthy( sme1'foo0bar' )
falsy( sme1'foo1bar' )
falsy( sme1'foo2bar' )
falsy( sme1'foo3bar' )
falsy( sme1'foo4bar' )
truthy( sme1'foo5bar' )
sme0 = ctor'foo[1-34]bar'
ok( sme0, 'foo[1-34]bar' )
nok( sme0'foo0bar' )
ok( sme0'foo1bar' )
ok( sme0'foo2bar' )
ok( sme0'foo3bar' )
ok( sme0'foo4bar' )
nok( sme0'foo5bar' )
truthy( sme0, 'foo[1-34]bar' )
falsy( sme0'foo0bar' )
truthy( sme0'foo1bar' )
truthy( sme0'foo2bar' )
truthy( sme0'foo3bar' )
truthy( sme0'foo4bar' )
falsy( sme0'foo5bar' )
sme1 = ctor'foo[^1-34]bar'
ok( sme1, 'foo[1234]bar' )
ok( sme1'foo0bar' )
nok( sme1'foo1bar' )
nok( sme1'foo2bar' )
nok( sme1'foo3bar' )
nok( sme1'foo4bar' )
ok( sme1'foo5bar' )
truthy( sme1, 'foo[1234]bar' )
truthy( sme1'foo0bar' )
falsy( sme1'foo1bar' )
falsy( sme1'foo2bar' )
falsy( sme1'foo3bar' )
falsy( sme1'foo4bar' )
truthy( sme1'foo5bar' )
sme0 = ctor'foo[1-23-4]bar'
ok( sme0, 'foo[1-23-4]bar' )
nok( sme0'foo0bar' )
ok( sme0'foo1bar' )
ok( sme0'foo2bar' )
ok( sme0'foo3bar' )
ok( sme0'foo4bar' )
nok( sme0'foo5bar' )
truthy( sme0, 'foo[1-23-4]bar' )
falsy( sme0'foo0bar' )
truthy( sme0'foo1bar' )
truthy( sme0'foo2bar' )
truthy( sme0'foo3bar' )
truthy( sme0'foo4bar' )
falsy( sme0'foo5bar' )
sme1 = ctor'foo[^1-23-4]bar'
ok( sme1, 'foo[^1-23-4]bar' )
ok( sme1'foo0bar' )
nok( sme1'foo1bar' )
nok( sme1'foo2bar' )
nok( sme1'foo3bar' )
nok( sme1'foo4bar' )
ok( sme1'foo5bar' )
truthy( sme1, 'foo[^1-23-4]bar' )
truthy( sme1'foo0bar' )
falsy( sme1'foo1bar' )
falsy( sme1'foo2bar' )
falsy( sme1'foo3bar' )
falsy( sme1'foo4bar' )
truthy( sme1'foo5bar' )
sme0 = ctor'foo[_]bar'
ok( sme0, 'foo[_]bar' )
nok( sme0'foo bar' )
ok( sme0'foo_bar' )
truthy( sme0, 'foo[_]bar' )
falsy( sme0'foo bar' )
truthy( sme0'foo_bar' )
sme1 = ctor'foo[^_]bar'
ok( sme1, 'foo[^_]bar' )
ok( sme1'foo bar' )
nok( sme1'foo_bar' )
truthy( sme1, 'foo[^_]bar' )
truthy( sme1'foo bar' )
falsy( sme1'foo_bar' )
sme0 = ctor'foo[_-]bar'
ok( sme0, 'foo[_-]bar' )
nok( sme0'foo bar' )
ok( sme0'foo-bar' )
ok( sme0'foo_bar' )
truthy( sme0, 'foo[_-]bar' )
falsy( sme0'foo bar' )
truthy( sme0'foo-bar' )
truthy( sme0'foo_bar' )
sme1 = ctor'foo[^_-]bar'
ok( sme1, 'foo[^_-]bar' )
ok( sme1'foo bar' )
nok( sme1'foo-bar' )
nok( sme1'foo_bar' )
truthy( sme1, 'foo[^_-]bar' )
truthy( sme1'foo bar' )
falsy( sme1'foo-bar' )
falsy( sme1'foo_bar' )
sme0 = ctor'foo[-]bar'
ok( sme0, 'foo[-]bar' )
nok( sme0'foo bar' )
ok( sme0'foo-bar' )
truthy( sme0, 'foo[-]bar' )
falsy( sme0'foo bar' )