-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest.lua
More file actions
56 lines (50 loc) · 1.03 KB
/
test.lua
File metadata and controls
56 lines (50 loc) · 1.03 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
local jevko = require "jevko"
function test(name, fn)
xpcall(function()
io.write("Running test ["..name.."]... ")
fn()
print("passed!")
end,
function(err)
print("failed!\nError: "..err)
end)
end
local parsed = jevko.decode([[
first name [John]
last name [Smith]
is alive [true]
age [27]
address [
street address [21 2nd Street]
city [New York]
state [NY]
postal code [10021-3100]
]
phone numbers [
[
type [home]
number [212 555-1234]
]
[
type [office]
number [646 555-4567]
]
]
children []
spouse []
]])
local expected = [[
street address [21 2nd Street]
city [New York]
state [NY]
postal code [10021-3100]
]]
test('escapes', function()
local t = jevko.from_string(" ````aaa`[bbb`]`]ccc`` ")
assert(t.suffix == " ``aaa[bbb]]ccc` ", t.suffix)
assert(jevko.from_string(" ````aaa`[bbb`]`]ccc`` []").subjevkos[1].prefix == " ``aaa[bbb]]ccc` ")
end)
test('roundtrip', function()
local actual = jevko.encode(parsed.subjevkos[5].jevko)
assert(actual == expected, actual)
end)