Add tests for changecount, scheme imports, derived palette entries and readability tests

This commit is contained in:
Jeremy Ruston
2026-07-23 13:32:19 +01:00
parent 52a36c01ff
commit fd96e5c8cb
7 changed files with 189 additions and 2 deletions
@@ -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
<p>(1X1X1Y1)</p><p>(Filter Error: Filter pragmas are only allowed at the start of a filter)</p><p>(1X1)</p><p>(Filter Error: Unknown filter pragma)</p>
<p>(1X1X1Y1)</p><p>(Filter Error: Filter pragmas are only allowed at the start of a filter)</p><p>(1X1)</p><p>(Filter Error: Unknown prefix for filter run)</p><p>(1)</p><p>(Filter Error: Unknown filter pragma)</p>
@@ -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)
@@ -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%)
rgb(90.804% 90.804% 90.804%),rgb(100% 0% 0%),rgb(25.196% 25.196% 25.196%),#80808080
@@ -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}]
(<<colour derived>>)
(<<colour wash>>)
+
title: Actions
\import [subfilter{$:/core/config/GlobalImportFilter}]
<<actions-recompile-current-palette>>
+
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
<p>(oklch(50% 0 0))
(#ffffff80)</p>
@@ -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}]
<<actions-recompile-current-palette>>
+
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
<p>(ok)
(0.000: greya/greyb contrast is too low)
(ok)</p>
@@ -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}]
(<<colour background>>)
(<$text text={{{ [[$:/temp/palette-colours]get[color-scheme]] }}}/>)
+
title: Actions
\import [subfilter{$:/core/config/GlobalImportFilter}]
<<actions-recompile-current-palette>>
+
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
<p>(#111111)
(dark)</p>
@@ -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}]
(<<colour background>>)
<$palette.preview paletteTitle="MyPalette">
(<<colour background>>)
(<<colour classic>>)
</$palette.preview>
+
title: Actions
\import [subfilter{$:/core/config/GlobalImportFilter}]
<<actions-recompile-current-palette>>
+
title: $:/palette
MyPalette
+
title: MyPalette
tags: $:/tags/Palette
type: application/x-tiddler-dictionary
color-scheme: light
background: rgb(1, 2, 3)
classic: <<colour background>>
+
title: ExpectedResult
<p>(rgb(1, 2, 3))
(rgb(1, 2, 3))
(rgb(1, 2, 3))
</p>