From fd96e5c8cb51b2bd3b40f1dc1f483b11fe28c51f Mon Sep 17 00:00:00 2001 From: Jeremy Ruston Date: Thu, 23 Jul 2026 13:32:19 +0100 Subject: [PATCH] Add tests for changecount, scheme imports, derived palette entries and readability tests --- .../filters/DefaultFilterRunPrefixPragma.tid | 6 ++- .../tests/data/operators/changecount.tid | 18 +++++++ .../data/operators/colour/ColourComposite.tid | 3 +- .../tests/data/palettes/DerivedEntries.tid | 34 ++++++++++++ .../tests/data/palettes/ReadabilityTests.tid | 40 ++++++++++++++ .../tests/data/palettes/SchemeImports.tid | 52 +++++++++++++++++++ .../data/palettes/SpacedColourValues.tid | 38 ++++++++++++++ 7 files changed, 189 insertions(+), 2 deletions(-) create mode 100644 editions/test/tiddlers/tests/data/operators/changecount.tid create mode 100644 editions/test/tiddlers/tests/data/palettes/DerivedEntries.tid create mode 100644 editions/test/tiddlers/tests/data/palettes/ReadabilityTests.tid create mode 100644 editions/test/tiddlers/tests/data/palettes/SchemeImports.tid create mode 100644 editions/test/tiddlers/tests/data/palettes/SpacedColourValues.tid diff --git a/editions/test/tiddlers/tests/data/filters/DefaultFilterRunPrefixPragma.tid b/editions/test/tiddlers/tests/data/filters/DefaultFilterRunPrefixPragma.tid index f03433886..ee546c1b9 100644 --- a/editions/test/tiddlers/tests/data/filters/DefaultFilterRunPrefixPragma.tid +++ b/editions/test/tiddlers/tests/data/filters/DefaultFilterRunPrefixPragma.tid @@ -15,9 +15,13 @@ title: Output (<$text text={{{ ::defaultprefix:and ::defaultprefix:all 1 1 +[join[X]] }}}/>) +(<$text text={{{ ::defaultprefix:bogus [[x]] }}}/>) + +(<$text text={{{ ::defaultprefix 1 1 +[count[]] }}}/>) + (<$text text={{{ ::nonexistent X }}}/>) + title: ExpectedResult -

(1X1X1Y1)

(Filter Error: Filter pragmas are only allowed at the start of a filter)

(1X1)

(Filter Error: Unknown filter pragma)

\ No newline at end of file +

(1X1X1Y1)

(Filter Error: Filter pragmas are only allowed at the start of a filter)

(1X1)

(Filter Error: Unknown prefix for filter run)

(1)

(Filter Error: Unknown filter pragma)

\ No newline at end of file diff --git a/editions/test/tiddlers/tests/data/operators/changecount.tid b/editions/test/tiddlers/tests/data/operators/changecount.tid new file mode 100644 index 000000000..53a4071a0 --- /dev/null +++ b/editions/test/tiddlers/tests/data/operators/changecount.tid @@ -0,0 +1,18 @@ +title: Operators/ChangeCount +description: changecount operator returns per-title change counts +type: text/vnd.tiddlywiki-multiple +tags: [[$:/tags/wiki-test-spec]] + +title: Output + +\parsermode inline +(<$text text={{{ [[T]changecount[]] }}}/>)(<$text text={{{ [[U]changecount[]] }}}/>) ++ +title: Actions + +<$action-setfield $tiddler="T" text="first"/> +<$action-setfield $tiddler="T" text="second"/> ++ +title: ExpectedResult + +(2)(0) \ No newline at end of file diff --git a/editions/test/tiddlers/tests/data/operators/colour/ColourComposite.tid b/editions/test/tiddlers/tests/data/operators/colour/ColourComposite.tid index 8782ce661..9dbd09a30 100644 --- a/editions/test/tiddlers/tests/data/operators/colour/ColourComposite.tid +++ b/editions/test/tiddlers/tests/data/operators/colour/ColourComposite.tid @@ -13,8 +13,9 @@ title: Filter =[[#1919191A]colour-composite[white]] =[[red]colour-composite[white]] =[[#80808080]colour-composite[black]] +=[[#80808080]colour-composite[nonsense]] +[join[,]] + title: ExpectedResult -rgb(90.804% 90.804% 90.804%),rgb(100% 0% 0%),rgb(25.196% 25.196% 25.196%) \ No newline at end of file +rgb(90.804% 90.804% 90.804%),rgb(100% 0% 0%),rgb(25.196% 25.196% 25.196%),#80808080 \ No newline at end of file diff --git a/editions/test/tiddlers/tests/data/palettes/DerivedEntries.tid b/editions/test/tiddlers/tests/data/palettes/DerivedEntries.tid new file mode 100644 index 000000000..a3d2ce387 --- /dev/null +++ b/editions/test/tiddlers/tests/data/palettes/DerivedEntries.tid @@ -0,0 +1,34 @@ +title: Operators/Palettes/DerivedEntries +description: Palette entries derived with tf.interpolate-colours and colour-set-alpha +type: text/vnd.tiddlywiki-multiple +tags: [[$:/tags/wiki-test-spec]] + +title: Output + +\import [subfilter{$:/core/config/GlobalImportFilter}] +(<>) +(<>) ++ +title: Actions + +\import [subfilter{$:/core/config/GlobalImportFilter}] +<> ++ +title: $:/palette + +MyPalette ++ +title: MyPalette +tags: $:/tags/Palette +type: application/x-tiddler-dictionary +color-scheme: light + +base-a: #000000 +base-b: #ffffff +derived: [tf.interpolate-colours[base-a],[base-b],[0.5]] +wash: [tf.colour[base-b]colour-set-alpha[0.5]] ++ +title: ExpectedResult + +

(oklch(50% 0 0)) +(#ffffff80)

\ No newline at end of file diff --git a/editions/test/tiddlers/tests/data/palettes/ReadabilityTests.tid b/editions/test/tiddlers/tests/data/palettes/ReadabilityTests.tid new file mode 100644 index 000000000..e5aa02bbd --- /dev/null +++ b/editions/test/tiddlers/tests/data/palettes/ReadabilityTests.tid @@ -0,0 +1,40 @@ +title: Operators/Palettes/ReadabilityTests +description: Readability test entries report ok, failure messages, and composite translucent colours +type: text/vnd.tiddlywiki-multiple +tags: [[$:/tags/wiki-test-spec]] + +title: Output + +\import [subfilter{$:/core/config/GlobalImportFilter}] +(<$text text={{{ [[$:/temp/palette-colours]getindex[?pass]] }}}/>) +(<$text text={{{ [[$:/temp/palette-colours]getindex[?fail]] }}}/>) +(<$text text={{{ [[$:/temp/palette-colours]getindex[?wash]] }}}/>) ++ +title: Actions + +\import [subfilter{$:/core/config/GlobalImportFilter}] +<> ++ +title: $:/palette + +MyPalette ++ +title: MyPalette +tags: $:/tags/Palette +type: application/x-tiddler-dictionary +color-scheme: light + +background: #000000 +foreground: #ffffff +greya: #888888 +greyb: #999999 +wash: #ffffff19 +?pass: [tf.check-colour-contrast[background],[foreground],[45]] +?fail: [tf.check-colour-contrast[greya],[greyb],[45]] +?wash: [tf.check-colour-contrast[wash],[foreground],[45]] ++ +title: ExpectedResult + +

(ok) +(0.000: greya/greyb contrast is too low) +(ok)

\ No newline at end of file diff --git a/editions/test/tiddlers/tests/data/palettes/SchemeImports.tid b/editions/test/tiddlers/tests/data/palettes/SchemeImports.tid new file mode 100644 index 000000000..386c4dd27 --- /dev/null +++ b/editions/test/tiddlers/tests/data/palettes/SchemeImports.tid @@ -0,0 +1,52 @@ +title: Operators/Palettes/SchemeImports +description: Scheme-suffixed palette imports follow the scheme chosen by a filter-valued color-scheme field +type: text/vnd.tiddlywiki-multiple +tags: [[$:/tags/wiki-test-spec]] + +title: Output + +\import [subfilter{$:/core/config/GlobalImportFilter}] +(<>) +(<$text text={{{ [[$:/temp/palette-colours]get[color-scheme]] }}}/>) ++ +title: Actions + +\import [subfilter{$:/core/config/GlobalImportFilter}] +<> ++ +title: $:/palette + +TogglePalette ++ +title: SchemeSwitch + +dark ++ +title: TogglePalette +name: Toggle Palette +tags: $:/tags/Palette +type: application/x-tiddler-dictionary +color-scheme: [{SchemeSwitch}] :else[[light]] +palette-import@light: LightPalette +palette-import@dark: DarkPalette + +marker: #123456 ++ +title: LightPalette +tags: $:/tags/Palette +type: application/x-tiddler-dictionary +color-scheme: light + +background: #eeeeee ++ +title: DarkPalette +tags: $:/tags/Palette +type: application/x-tiddler-dictionary +color-scheme: dark + +background: #111111 ++ +title: ExpectedResult + +

(#111111) +(dark)

\ No newline at end of file diff --git a/editions/test/tiddlers/tests/data/palettes/SpacedColourValues.tid b/editions/test/tiddlers/tests/data/palettes/SpacedColourValues.tid new file mode 100644 index 000000000..68ae24b2b --- /dev/null +++ b/editions/test/tiddlers/tests/data/palettes/SpacedColourValues.tid @@ -0,0 +1,38 @@ +title: Operators/Palettes/SpacedColourValues +description: Palette entries whose values contain spaces survive compilation and preview +type: text/vnd.tiddlywiki-multiple +tags: [[$:/tags/wiki-test-spec]] + +title: Output + +\import [subfilter{$:/core/config/GlobalImportFilter}] +(<>) +<$palette.preview paletteTitle="MyPalette"> +(<>) +(<>) + ++ +title: Actions + +\import [subfilter{$:/core/config/GlobalImportFilter}] +<> ++ +title: $:/palette + +MyPalette ++ +title: MyPalette +tags: $:/tags/Palette +type: application/x-tiddler-dictionary +color-scheme: light + +background: rgb(1, 2, 3) +classic: <> ++ +title: ExpectedResult + +

(rgb(1, 2, 3)) + +(rgb(1, 2, 3)) +(rgb(1, 2, 3)) +

\ No newline at end of file