1
0
Fork 0
mirror of https://github.com/Oreolek/ink-instead.git synced 2024-07-08 01:24:39 +03:00
ink-instead/test.lua

38 lines
752 B
Lua
Raw Normal View History

2016-11-30 17:11:57 +02:00
local luaunit = require('luaunit')
local parser = require('pink.parser')
2016-11-30 17:11:57 +02:00
function testEmpt() doTestS(
"",
{}
) end
2016-12-03 01:08:14 +02:00
function testText() doTestS(
"Hello world",
{{"para", "Hello world"}}
) end
function testOptS() doTestS(
'* "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
function testBasic() doTest('basic') end
function testChoices() doTest('choices') 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() )