First commit
- License - Readme containing examples, roadmap and description - The initial lua test functions and the tests to test itselfmaster
commit
5ad053a7db
|
@ -0,0 +1,24 @@
|
|||
License
|
||||
=======
|
||||
You are free to:
|
||||
|
||||
Share — copy and redistribute the material in any medium or format
|
||||
Adapt — remix, transform, and build upon the material
|
||||
for any purpose, even commercially.
|
||||
|
||||
The licensor cannot revoke these freedoms as long as you follow the license terms.
|
||||
|
||||
Under the following terms:
|
||||
|
||||
Attribution — You must give appropriate credit, provide a link to the license, and indicate if changes were made. You may do so in any reasonable manner, but not in any way that suggests the licensor endorses you or your use.
|
||||
|
||||
ShareAlike — If you remix, transform, or build upon the material, you must distribute your contributions under the same license as the original.
|
||||
|
||||
No additional restrictions — You may not apply legal terms or technological measures that legally restrict others from doing anything the license permits.
|
||||
|
||||
Notices:
|
||||
|
||||
You do not have to comply with the license for elements of the material in the public domain or where your use is permitted by an applicable exception or limitation.
|
||||
No warranties are given. The license may not give you all of the permissions necessary for your intended use. For example, other rights such as publicity, privacy, or moral rights may limit how you use the material.
|
||||
|
||||
http://creativecommons.org/licenses/by-sa/3.0/
|
|
@ -0,0 +1,29 @@
|
|||
Lunit
|
||||
=====
|
||||
Write tests for your lua code.
|
||||
|
||||
Usage
|
||||
-----
|
||||
*example taken from the tests.lua*
|
||||
```lua
|
||||
lunit.tests( 'lunit', function( unit )
|
||||
|
||||
unit.ok( true, 'true is ok')
|
||||
unit.ok( 'string', 'string is ok')
|
||||
unit.ok( '', 'empty string is ok')
|
||||
unit.ok( {}, 'table is ok')
|
||||
unit.ok( not nil, 'nil is not ok')
|
||||
unit.ok( not false, 'false is not ok')
|
||||
|
||||
unit.equal( true, true, 'equals true')
|
||||
unit.equal( false, false, 'equals false')
|
||||
unit.equal( 'hello', 'hello', 'equals string')
|
||||
unit.equal( type(''), 'string', 'check type')
|
||||
|
||||
end)
|
||||
```
|
||||
|
||||
Roadmap
|
||||
-------
|
||||
- deep equals for testing table outputs
|
||||
- asynchronous tests
|
|
@ -0,0 +1,31 @@
|
|||
lunit = {}
|
||||
lunit.tests = function( name, tests )
|
||||
print("TEST: "..name)
|
||||
local succes = function( description )
|
||||
print( 'succes: '..description )
|
||||
return true
|
||||
end
|
||||
local failed = function( description, expected, value )
|
||||
print( 'failed: '..description..'\texpected '..tostring(expected)..' got '..tostring(value) )
|
||||
return false
|
||||
end
|
||||
local unit = {
|
||||
ok = function( value, description )
|
||||
if value then
|
||||
succes( description )
|
||||
else
|
||||
failed( description, 'true-ish', value )
|
||||
end
|
||||
return value
|
||||
end,
|
||||
equal = function( value, expected, description)
|
||||
if value == expected then
|
||||
succes( description )
|
||||
else
|
||||
failed( description, expected, value )
|
||||
end
|
||||
return value
|
||||
end,
|
||||
}
|
||||
return tests( unit )
|
||||
end
|
|
@ -0,0 +1,15 @@
|
|||
lunit.tests( 'lunit', function( unit )
|
||||
|
||||
unit.ok( true, 'true is ok')
|
||||
unit.ok( 'string', 'string is ok')
|
||||
unit.ok( '', 'empty string is ok')
|
||||
unit.ok( {}, 'table is ok')
|
||||
unit.ok( not nil, 'nil is not ok')
|
||||
unit.ok( not false, 'false is not ok')
|
||||
|
||||
unit.equal( true, true, 'equals true')
|
||||
unit.equal( false, false, 'equals false')
|
||||
unit.equal( 'hello', 'hello', 'equals string')
|
||||
unit.equal( type(''), 'string', 'check type')
|
||||
|
||||
end)
|
Loading…
Reference in New Issue