Skip to content

Commit 5590eff

Browse files
committed
test(frames): Update tests for new frame APIs
1 parent fecb558 commit 5590eff

File tree

8 files changed

+22
-26
lines changed

8 files changed

+22
-26
lines changed

core/frameparser.lua

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ SILE._frameParserBits = {
2828
relation = relation,
2929
}
3030

31-
return P{
31+
local frameparser = P{
3232
"additive",
3333
additive = V"plus" + V"minus" + V"multiplicative",
3434
multiplicative = V"times" + V"divide" + V"primary",
@@ -40,3 +40,5 @@ return P{
4040
braced = ws * P"(" * ws * V"additive" * ws * P")" * ws
4141
}
4242
-- stylua: ignore end
43+
44+
return frameparser

core/utilities/init_spec.lua

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
11
SILE = require("core.sile")
22
SILE.init()
33

4-
-- Work around not having an active class in this test but needing language modules
5-
SILE.typesetter = SILE.typesetters.default()
6-
74
describe("SILE.utilities", function ()
5+
require("classes.plain")({})
6+
87
it("should exist as SU", function ()
98
assert.is.truthy(SU)
109
end)

core/utilities/numbers_spec.lua

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,9 @@ SILE.init()
33
SILE.utilities.error = error
44
SILE.utilities.warn = function () end
55

6-
-- Work around not having an active class in this test but needing language modules
7-
SILE.typesetter = SILE.typesetters.default()
8-
96
describe("SILE.utilities", function ()
7+
require("classes.plain")({})
8+
109
describe("formatNumber", function ()
1110
local icu = require("justenoughicu")
1211
local icu73plus = tostring(icu.version()) >= "73.0"

spec/frame_spec.lua

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,9 @@ describe("The frame factory", function ()
1111

1212
describe("Simple", function ()
1313
local frame = SILE.newFrame({ id = "hello", top = 20, left = 30, bottom = 200, right = 300 })
14-
it("should exist", function ()
15-
assert.is.truthy(frame)
14+
it("should be a frame", function ()
15+
local isframe = SILE.types.frame:class_of(frame)
16+
assert.is.truthy(isframe)
1617
end)
1718
it("should have width", function ()
1819
assert.is.equal(270, frame:width():tonumber())
@@ -21,8 +22,9 @@ describe("The frame factory", function ()
2122
assert.is.equal(180, frame:height():tonumber())
2223
end)
2324
it("should be registered in the class frames table", function ()
24-
assert.is.truthy(SILE.frames["hello"])
25-
assert.is.equal(frame, SILE.frames["hello"])
25+
local hello = SILE.frames:pull("hello")
26+
assert.is.truthy(hello)
27+
assert.is.equal(frame, hello)
2628
end)
2729
end)
2830
end)

spec/frameparser_spec.lua

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,9 @@ describe("The frame parser", function ()
2323

2424
describe("function", function () -- also tests identifier
2525
require("classes.plain")({})
26-
SILE.documentState.thisPageTemplate = {
27-
frames = {
28-
a = SILE.newFrame({ id = "A", top = 20, left = 30, bottom = 200, right = 300 }),
29-
bb3 = SILE.newFrame({ id = "B", top = 20, left = 30, bottom = 200, right = 300 }),
30-
},
31-
}
26+
local a = SILE.frames:new({ id = "a", top = 20, left = 30, bottom = 200, right = 300 })
27+
local bb3 = SILE.frames:new({ id = "bb3", top = 20, left = 30, bottom = 200, right = 300 })
28+
3229
--it("should match valid functions", function() assert.is.equal(30,r:match("left(a)")) end)
3330
it("should match valid functions", function ()
3431
assert.is.truthy(r:match("top(bb3)"))

spec/hyphenator_spec.lua

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,9 @@ SILE = require("core.sile")
33
SILE.input.backend = "debug"
44
SILE.init()
55

6-
-- Work around not having an active class in this test but needing language modules
7-
SILE.typesetter = SILE.typesetters.default()
8-
96
describe("Hyphenation module", function ()
7+
require("classes.plain")({})
8+
109
SILE.call("language", { main = "fr" })
1110
local hyphenator = SILE.typesetter.language.hyphenator
1211

spec/languages_spec.lua

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,9 @@ SILE = require("core.sile")
22
SILE.input.backend = "debug"
33
SILE.init()
44

5-
-- Work around not having an active class in this test but needing language modules
6-
SILE.typesetter = SILE.typesetters.default()
7-
85
describe("Language module", function ()
6+
require("classes.plain")({})
7+
98
it("should set env locale", function ()
109
SILE.call("language", { main = "tr" })
1110
local syslang = os.getenv("LANG")

spec/shaper_spec.lua

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ SILE.input.backend = "debug"
33
SILE.init()
44

55
describe("SILE.shapers.default", function ()
6+
require("classes.plain")({})
7+
68
it("should always have positive stretch and shrink", function ()
79
SILE.settings:set("shaper.variablespaces", true)
810
SILE.settings:set("shaper.spacestretchfactor", 2)
@@ -14,9 +16,6 @@ describe("SILE.shapers.default", function ()
1416
end)
1517

1618
describe("measureChar", function ()
17-
-- Work around not having an active class in this test but needing language modules
18-
SILE.typesetter = SILE.typesetters.default()
19-
2019
SILE.settings:set("font.family", "Libertinus Serif", true)
2120

2221
it("should measure simple characters", function ()

0 commit comments

Comments
 (0)