-
-
Notifications
You must be signed in to change notification settings - Fork 102
/
Copy pathframeparser_spec.lua
50 lines (45 loc) · 1.67 KB
/
frameparser_spec.lua
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
SILE = require("core.sile")
describe("The frame parser", function ()
it("should exist", function ()
assert.is.truthy(SILE.frameParser)
end)
local n = SILE.parserBits.number
local m = SILE._frameParserBits.measurement
local r = SILE._frameParserBits.relation
describe("Number", function () -- also tests all the number subrules
it("should capture number information", function ()
assert.is.equal(0.35, n:match("0.35"))
end)
it("should capture number information", function ()
assert.is.equal(-0.85, n:match("-.85"))
end)
it("should capture number information", function ()
assert.is.equal(44, n:match("44 xyz"))
end)
end)
describe("function", function () -- also tests identifier
SILE.documentState = {
thisPageTemplate = {
frames = {
a = SILE.newFrame({ id = "A", top = 20, left = 30, bottom = 200, right = 300 }),
bb3 = SILE.newFrame({ id = "B", top = 20, left = 30, bottom = 200, right = 300 }),
},
},
}
--it("should match valid functions", function() assert.is.equal(30,r:match("left(a)")) end)
it("should match valid functions", function ()
assert.is.truthy(r:match("top(bb3)"))
end)
it("should not match invalid functions", function ()
assert.is.falsy(r:match("xxx(a)"))
end)
it("should not match invalid functions", function ()
assert.is.falsy(r:match("left(&)"))
end)
end)
describe("dimensioned string", function ()
it("should convert SILE measurements", function ()
assert.is.equal(14.4, m:match("0.2 in"))
end)
end)
end)