Commit c9186752 authored by François Perrad's avatar François Perrad

luacheck testsuite

parent 90f53787
globals = {
-- Test.More
'plan',
'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',
-- Coat
'argerror',
'checktype',
'can',
'isa',
'does',
'dump',
'new',
'instance',
'_INIT',
'has',
'method',
'overload',
'override',
'mock',
'unmock',
'before',
'around',
'after',
'memoize',
'bind',
'extends',
'with',
'module',
'class',
'singleton',
'abstract',
'augment',
-- Coat.Role
'requires',
'excludes',
'role',
-- Coat.Types
'find_type_constraint',
'coercion_map',
'subtype',
'enum',
'coerce',
-- Coat.Persistent
'establish_connection',
'connection',
'save',
'delete',
'create',
'find_by_sql',
'find',
'has_p',
'has_one',
'has_many',
'persistent',
-- testsuite
'Person',
'Friend',
'Avatar',
'Car',
}
ignore = { 'sql_create' }
......@@ -112,6 +112,7 @@ test.lsqlite3:
luacheck:
luacheck --std=max --no-unused-args src
luacheck --std=max --no-unused-args src.lsqlite3 --ignore err
luacheck --std=min --config .test.luacheckrc test/*.t
coverage:
rm -f src/luacov.stats.out src/luacov.report.out
......
......@@ -36,7 +36,7 @@ ok( mc.has( Person, 'id' ), "field id" )
ok( mc.has( Person, 'name' ), "field name" )
ok( mc.has( Person, 'age' ), "field age" )
john = Person { name = 'John', age = 23 }
local john = Person { name = 'John', age = 23 }
is( john:type(), 'Person', "Person" )
ok( john:isa 'Person' )
......@@ -44,7 +44,7 @@ is( john.id, nil, "john.id is nil" )
ok( john:save(), "john:save() --> insert" )
is( john.id, 1, "john.id is 1" )
brenda = Person { name = 'Brenda', age = 22 }
local brenda = Person { name = 'Brenda', age = 22 }
is( brenda.id, nil, "brenda.id is nil" )
ok( brenda:save(), "brenda:save()" )
is( brenda.id, 2, "brenda.id is 2" )
......@@ -55,7 +55,7 @@ ok( p:isa 'Person', "it is a Person" )
is( p.name, 'John', "it is John" )
is( p.age, 23 )
local p = Person.find_by_name('Brenda')()
p = Person.find_by_name('Brenda')()
ok( p, "Person.find_by_name returns something" )
ok( p:isa 'Person', "it is a Person" )
is( p.name, 'Brenda', "it is Brenda" )
......
......@@ -81,7 +81,7 @@ is( p.avatar_id, a.id, "p.avatar_id == a.id" )
ok( p:save(), "p:save() -- with avatar" )
p2 = Person.find(p.id)()
local p2 = Person.find(p.id)()
ok( p2.avatar, "p2.avatar is defined after a find" )
is( p2.avatar.id, a.id, "p2.avatar.id == a.id" )
......
......@@ -53,8 +53,8 @@ is( first.name, 'Joe' )
error_like( [[local first = Person.find_by_age()()]],
"Cannot find without a value" )
local nb = 0
for p in Person.find() do
nb = 0
for _ in Person.find() do
nb = nb + 1
end
is( nb, 3, "3 items returned" )
......@@ -47,7 +47,7 @@ for p in Person.find_by_sql "select * from person where name like 'Jo%'" do
end
is( nb, 2, "2 items returned", find_by_sql )
local nb = 0
nb = 0
for p in Person.find "name like 'Jo%'" do
ok( p:isa 'Person' )
nb = nb + 1
......
......@@ -70,7 +70,7 @@ ok( p:isa 'Person' )
is( p.people_id, 1, "primary_key people_id is set" )
is( p.name, 'John', "name is set" )
pp = Person.find_by_name 'John'()
local pp = Person.find_by_name 'John'()
is( pp.name, 'John', "find_by_name works" )
pp = Person.find(1)()
......@@ -85,7 +85,7 @@ local car = Car.create{ color = 'red', max_speed = 180 }
ok( car:isa 'Car', "car created" )
p.its_car = car
c = p.its_car
local c = p.its_car
is( car.c_id, c.c_id )
ok( p:save(), "p:save() with car" )
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment