From 41ddeab88d4f3a12072e36a1cc974921a3c04f67 Mon Sep 17 00:00:00 2001 From: Caleb Maclennan Date: Tue, 10 May 2022 12:53:19 +0300 Subject: [PATCH] test(classes): Redo class tests with Penlight class model --- tests/classes/testsidenote.lua | 17 ++++++++++------- tests/classes/testtwocol.lua | 11 +++++++---- 2 files changed, 17 insertions(+), 11 deletions(-) diff --git a/tests/classes/testsidenote.lua b/tests/classes/testsidenote.lua index e0daafb627..2a463242dd 100644 --- a/tests/classes/testsidenote.lua +++ b/tests/classes/testsidenote.lua @@ -1,23 +1,26 @@ -local plain = SILE.require("plain", "classes") -local testsidenote = plain { id = "testsidenote" } +local plain = require("classes.plain") +local testsidenote = pl.class(plain) +testsidenote._name = "testsidenote" local gutterWidth = "3%pw" -function testsidenote:init () +function testsidenote:_init (options) + plain._init(self, options) self:declareFrame("contentA", {left = "left(content)", right = "left(gutter)", top = "top(content)", bottom = "bottom(content)" }) self:declareFrame("sidenotes", {left = "right(gutter)", width="width(contentA) * 2 / 3", right = "right(content)", top = "top(content)", bottom = "bottom(content)", balanced = true }) self:declareFrame("gutter", {left = "right(contentA)", right = "left(sidenotes)", width = gutterWidth }) self.pageTemplate.firstContentFrame = self.pageTemplate.frames["contentA"] - local insertions = SILE.require("packages/insertions") - SILE.require("packages/footnotes") - insertions.exports:initInsertionClass("footnote", { + self:loadPackage("insertions") + self:loadPackage("footnotes") + self:initInsertionClass("footnote", { maxHeight = SILE.length("75%ph"):absolute(), topBox = SILE.nodefactory.zerovglue(), interInsertionSkip = SILE.length("1ex"), insertInto = { frame = "sidenotes", ratio = 0 }, stealFrom = { }, }) - return plain.init(self) + self:post_init() + return self end return testsidenote diff --git a/tests/classes/testtwocol.lua b/tests/classes/testtwocol.lua index e8b2586ba1..5a8491bd6f 100644 --- a/tests/classes/testtwocol.lua +++ b/tests/classes/testtwocol.lua @@ -1,18 +1,21 @@ -local plain = SILE.require("plain", "classes") -local testtwocols = plain { id = "testtwocols" } +local plain = require("classes.plain") +local testtwocols = pl.class(plain) +testtwocols._name = "testtwocols" local gutterWidth = "3%pw" testtwocols.defaultFrameset = {} testtwocols.firstContentFrame = "contentA" -testtwocols.init = function(self) +function testtwocols:_init (options) + plain._init(self, options) self:declareFrame("contentA", {left = "left(content)", right = "left(gutter)", top = "5%ph", bottom = "83.3%ph", next = "contentB", balanced = true }) self:declareFrame("contentB", {left = "right(gutter)", width="width(contentA) * 2 / 3", right = "right(content)", top = "5%ph", bottom = "top(footnotes)", balanced = true }) self:declareFrame("gutter", {left = "right(contentA)", right = "left(contentB)", width = gutterWidth }) self:declareFrame("footnotes", { left="left(contentB)", right = "right(contentB)", height = "0", bottom="83.3%ph"}) self:loadPackage("footnotes", { insertInto = "footnotes", stealFrom = { contentB = 1 } } ) - return plain.init(self) + self:post_init() + return self end return testtwocols