2016-11-30 17:11:57 +02:00
|
|
|
local luaunit = require('luaunit')
|
2016-12-03 02:44:39 +02:00
|
|
|
local parser = require('pink.parser')
|
2016-11-30 17:11:57 +02:00
|
|
|
|
|
|
|
|
2016-12-03 02:44:39 +02:00
|
|
|
function testEmpt() doTestS(
|
|
|
|
"",
|
|
|
|
{}
|
|
|
|
) end
|
|
|
|
|
2016-12-03 01:08:14 +02:00
|
|
|
function testText() doTestS(
|
|
|
|
"Hello world",
|
|
|
|
{{"para", "Hello world"}}
|
|
|
|
) end
|
|
|
|
|
2016-12-04 02:38:27 +02:00
|
|
|
function testOpt1() doTestS(
|
2016-12-03 01:08:14 +02:00
|
|
|
'* "I am somewhat tired[."]," I repeated.',
|
2016-12-03 04:05:00 +02:00
|
|
|
{{'choice', {"option", '"I am somewhat tired', '."', '," I repeated.'}}}
|
2016-12-03 01:08:14 +02:00
|
|
|
) end
|
|
|
|
|
2016-12-04 02:38:27 +02:00
|
|
|
|
2016-12-03 01:08:14 +02:00
|
|
|
function testBasic() doTest('basic') end
|
|
|
|
function testChoices() doTest('choices') end
|
2016-12-04 02:38:27 +02:00
|
|
|
function testNest() doTest('nested') end
|
|
|
|
function testNest2() doTest('nested2') end
|
|
|
|
function testKnot() doTest('knot') end
|
2016-12-04 02:54:34 +02:00
|
|
|
function testBranching() doTest('branching') end
|
2016-12-04 03:47:33 +02:00
|
|
|
function testGlue() doTest('glue') end
|
2016-11-30 17:11:57 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
-----------------------------
|
|
|
|
|
|
|
|
function doTestS(ink, expected)
|
|
|
|
luaunit.assertEquals(parser:match(ink), expected)
|
|
|
|
end
|
|
|
|
|
|
|
|
function doTest(name)
|
|
|
|
local test = require ('test.'..name)
|
|
|
|
local parsed = parser:match(test.ink)
|
|
|
|
luaunit.assertEquals(parsed, test.expected)
|
|
|
|
end
|
|
|
|
|
|
|
|
os.exit( luaunit.LuaUnit.run() )
|