squiffy-runtime 7.0.0-beta.3 → 7.0.0-beta.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/state.d.ts CHANGED
@@ -16,4 +16,6 @@ export declare class State {
16
16
  reset(): void;
17
17
  setSeen(sectionName: string): void;
18
18
  getSeen(sectionName: string): boolean;
19
+ getVisits(sectionName: string): number;
20
+ private getVisitsFrom;
19
21
  }
@@ -7,5 +7,13 @@ export declare class TextProcessor {
7
7
  getCurrentSection: () => Section;
8
8
  handlebars: typeof Handlebars;
9
9
  constructor(story: () => Story, state: State, currentSection: () => Section);
10
+ evaluate(expression: string): unknown;
11
+ goto: {
12
+ section: string;
13
+ after: number;
14
+ } | null;
15
+ private expressionCache;
16
+ private evaluated;
10
17
  process(text: string, inline: boolean): string;
11
18
  }
19
+ export declare function errorHtml(label: string, message: string): string;
package/dist/types.d.ts CHANGED
@@ -31,6 +31,7 @@ export interface SquiffyApi {
31
31
  clickLink: (link: HTMLElement) => Promise<boolean>;
32
32
  update: (story: Story) => void;
33
33
  goBack: () => void;
34
+ canGoBack: () => boolean;
34
35
  on<E extends keyof SquiffyEventMap>(event: E, handler: SquiffyEventHandler<E>): () => void;
35
36
  off<E extends keyof SquiffyEventMap>(event: E, handler: SquiffyEventHandler<E>): void;
36
37
  once<E extends keyof SquiffyEventMap>(event: E, handler: SquiffyEventHandler<E>): () => void;
@@ -44,6 +45,7 @@ interface SquiffyJsFunctionApi {
44
45
  story: {
45
46
  go: (section: string) => void;
46
47
  seen: (sectionOrPassage: string) => boolean;
48
+ visits: (sectionOrPassage: string) => number;
47
49
  };
48
50
  }
49
51
  export interface Story {
@@ -51,6 +53,7 @@ export interface Story {
51
53
  start: string;
52
54
  id?: string | null;
53
55
  uiJsIndex?: number;
56
+ expressions?: boolean;
54
57
  sections: Record<string, Section>;
55
58
  }
56
59
  export interface Section {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "squiffy-runtime",
3
- "version": "7.0.0-beta.3",
3
+ "version": "7.0.0-beta.5",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "git+https://github.com/textadventures/squiffy.git",
@@ -49,7 +49,7 @@
49
49
  "esbuild": "^0.28.2",
50
50
  "global-jsdom": "^31.0.0",
51
51
  "jsdom": "^31.0.1",
52
- "squiffy-compiler": "^7.0.0-beta.3",
52
+ "squiffy-compiler": "^7.0.0-beta.5",
53
53
  "typescript": "^6.0.3",
54
54
  "vite": "^8.3.8",
55
55
  "vite-plugin-dts": "^5.1.2"
@@ -59,5 +59,5 @@
59
59
  "handlebars": "^4.7.10",
60
60
  "marked": "^18.2.0"
61
61
  },
62
- "gitHead": "016f53cc52dc2cf504787ef8329740ca2cf8d481"
62
+ "gitHead": "9495ea44822999ad3e5c8fa305a88c5f5e43f1d8"
63
63
  }
@@ -2,12 +2,12 @@
2
2
 
3
3
  exports[`"Hello world" script should run 1`] = `
4
4
  "
5
- <div><div class="squiffy-output-section" data-section="_default" data-undo="{&quot;_section&quot;:null,&quot;_seen_sections&quot;:null,&quot;_turncount&quot;:null}"><div class="squiffy-output-block"><div data-source="[[_default]]"><p>Hello world</p></div></div></div></div>"
5
+ <div><div class="squiffy-output-section" data-section="_default" data-undo="{&quot;_section&quot;:null,&quot;_visits&quot;:null,&quot;_seen_sections&quot;:null,&quot;_turncount&quot;:null}"><div class="squiffy-output-block"><div data-source="[[_default]]"><p>Hello world</p></div></div></div></div>"
6
6
  `;
7
7
 
8
8
  exports[`Click a passage link 1`] = `
9
9
  "
10
- <div><div class="squiffy-output-section" data-section="Introduction" data-undo="{&quot;_section&quot;:null,&quot;_seen_sections&quot;:null,&quot;_turncount&quot;:null}"><div class="squiffy-output-block"><div data-source="[[Introduction]]"><h1>Squiffy Test</h1>
10
+ <div><div class="squiffy-output-section" data-section="Introduction" data-undo="{&quot;_section&quot;:null,&quot;_visits&quot;:null,&quot;_seen_sections&quot;:null,&quot;_turncount&quot;:null}"><div class="squiffy-output-block"><div data-source="[[Introduction]]"><h1>Squiffy Test</h1>
11
11
  <p>This is <a href="http://textadventures.co.uk">a website link</a>.</p>
12
12
  <p>This should be <a class="squiffy-link link-passage" data-passage="passage" role="link" tabindex="0">a link to a passage</a>. Here's <a class="squiffy-link link-passage" data-passage="passage2" role="link" tabindex="0">another one</a>.</p>
13
13
  <p>You don't need to specify a name - for example, this <a class="squiffy-link link-passage" data-passage="link" role="link" tabindex="0">link</a> and this <a class="squiffy-link link-section" data-section="section" role="link" tabindex="0">section</a>.</p>
@@ -19,21 +19,21 @@ exports[`Click a passage link 1`] = `
19
19
 
20
20
  exports[`Click a passage link 2`] = `
21
21
  "
22
- <div><div class="squiffy-output-section" data-section="Introduction" data-undo="{&quot;_section&quot;:null,&quot;_seen_sections&quot;:null,&quot;_turncount&quot;:null}"><div class="squiffy-output-block"><div data-source="[[Introduction]]"><h1>Squiffy Test</h1>
22
+ <div><div class="squiffy-output-section" data-section="Introduction" data-undo="{&quot;_section&quot;:null,&quot;_visits&quot;:null,&quot;_seen_sections&quot;:null,&quot;_turncount&quot;:null}"><div class="squiffy-output-block"><div data-source="[[Introduction]]"><h1>Squiffy Test</h1>
23
23
  <p>This is <a href="http://textadventures.co.uk">a website link</a>.</p>
24
24
  <p>This should be <a class="squiffy-link link-passage disabled" data-passage="passage" role="link" tabindex="-1">a link to a passage</a>. Here's <a class="squiffy-link link-passage" data-passage="passage2" role="link" tabindex="0">another one</a>.</p>
25
25
  <p>You don't need to specify a name - for example, this <a class="squiffy-link link-passage" data-passage="link" role="link" tabindex="0">link</a> and this <a class="squiffy-link link-section" data-section="section" role="link" tabindex="0">section</a>.</p>
26
26
  <p>And this goes to the <a class="squiffy-link link-section" data-section="section2" role="link" tabindex="0">next section</a>.</p>
27
27
  <p>This line has links to <a class="squiffy-link link-section" data-section="section 3" role="link" tabindex="0">section 3</a> and <a class="squiffy-link link-section" data-section="section four" role="link" tabindex="0">section 4</a>.</p>
28
28
  <p>This line has links to <a class="squiffy-link link-passage" data-passage="passage 3" role="link" tabindex="0">passage 3</a> and <a class="squiffy-link link-passage" data-passage="passage four" role="link" tabindex="0">passage 4</a>.</p>
29
- <p>Oh look - <a class="squiffy-link link-passage" data-passage="it's a passage with an apostrophe" role="link" tabindex="0">it's a passage with an apostrophe</a>.</p></div></div><div class="squiffy-output-passage" data-passage="passage" data-undo="{&quot;_turncount&quot;:0,&quot;_seen_sections&quot;:[&quot;Introduction&quot;]}"><div class="squiffy-output-block"><div data-source="[[Introduction]][passage]"><p>Here's some text for the passage.</p>
29
+ <p>Oh look - <a class="squiffy-link link-passage" data-passage="it's a passage with an apostrophe" role="link" tabindex="0">it's a passage with an apostrophe</a>.</p></div></div><div class="squiffy-output-passage" data-passage="passage" data-undo="{&quot;turns&quot;:0,&quot;_turncount&quot;:0,&quot;_visits&quot;:{&quot;Introduction&quot;:1},&quot;_seen_sections&quot;:[&quot;Introduction&quot;]}"><div class="squiffy-output-block"><div data-source="[[Introduction]][passage]"><p>Here's some text for the passage.</p>
30
30
  <p>This passage has a picture in it. It's by <a href="https://unsplash.com/@lmablankers?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">Lars Blankers</a> on <a href="https://unsplash.com/photos/brown-potato-lot-B0s3Xndk6tw?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">Unsplash</a>.</p>
31
31
  <p><img src="lars-blankers-B0s3Xndk6tw-unsplash.jpg" alt=""></p></div></div></div></div></div>"
32
32
  `;
33
33
 
34
34
  exports[`Click a passage link and go back 1`] = `
35
35
  "
36
- <div><div class="squiffy-output-section" data-section="Introduction" data-undo="{&quot;_section&quot;:null,&quot;_seen_sections&quot;:null,&quot;_turncount&quot;:null}"><div class="squiffy-output-block"><div data-source="[[Introduction]]"><h1>Squiffy Test</h1>
36
+ <div><div class="squiffy-output-section" data-section="Introduction" data-undo="{&quot;_section&quot;:null,&quot;_visits&quot;:null,&quot;_seen_sections&quot;:null,&quot;_turncount&quot;:null}"><div class="squiffy-output-block"><div data-source="[[Introduction]]"><h1>Squiffy Test</h1>
37
37
  <p>This is <a href="http://textadventures.co.uk">a website link</a>.</p>
38
38
  <p>This should be <a class="squiffy-link link-passage" data-passage="passage" role="link">a link to a passage</a>. Here's <a class="squiffy-link link-passage" data-passage="passage2" role="link" tabindex="0">another one</a>.</p>
39
39
  <p>You don't need to specify a name - for example, this <a class="squiffy-link link-passage" data-passage="link" role="link" tabindex="0">link</a> and this <a class="squiffy-link link-section" data-section="section" role="link" tabindex="0">section</a>.</p>
@@ -45,7 +45,7 @@ exports[`Click a passage link and go back 1`] = `
45
45
 
46
46
  exports[`Click a section link 1`] = `
47
47
  "
48
- <div><div class="squiffy-output-section" data-section="Introduction" data-undo="{&quot;_section&quot;:null,&quot;_seen_sections&quot;:null,&quot;_turncount&quot;:null}"><div class="squiffy-output-block"><div data-source="[[Introduction]]"><h1>Squiffy Test</h1>
48
+ <div><div class="squiffy-output-section" data-section="Introduction" data-undo="{&quot;_section&quot;:null,&quot;_visits&quot;:null,&quot;_seen_sections&quot;:null,&quot;_turncount&quot;:null}"><div class="squiffy-output-block"><div data-source="[[Introduction]]"><h1>Squiffy Test</h1>
49
49
  <p>This is <a href="http://textadventures.co.uk">a website link</a>.</p>
50
50
  <p>This should be <a class="squiffy-link link-passage" data-passage="passage" role="link" tabindex="0">a link to a passage</a>. Here's <a class="squiffy-link link-passage" data-passage="passage2" role="link" tabindex="0">another one</a>.</p>
51
51
  <p>You don't need to specify a name - for example, this <a class="squiffy-link link-passage" data-passage="link" role="link" tabindex="0">link</a> and this <a class="squiffy-link link-section" data-section="section" role="link" tabindex="0">section</a>.</p>
@@ -57,19 +57,19 @@ exports[`Click a section link 1`] = `
57
57
 
58
58
  exports[`Click a section link 2`] = `
59
59
  "
60
- <div><div class="squiffy-output-section" data-section="Introduction" data-undo="{&quot;_section&quot;:null,&quot;_seen_sections&quot;:null,&quot;_turncount&quot;:null}"><div class="squiffy-output-block"><div data-source="[[Introduction]]"><h1>Squiffy Test</h1>
60
+ <div><div class="squiffy-output-section" data-section="Introduction" data-undo="{&quot;_section&quot;:null,&quot;_visits&quot;:null,&quot;_seen_sections&quot;:null,&quot;_turncount&quot;:null}"><div class="squiffy-output-block"><div data-source="[[Introduction]]"><h1>Squiffy Test</h1>
61
61
  <p>This is <a href="http://textadventures.co.uk">a website link</a>.</p>
62
62
  <p>This should be <a class="squiffy-link link-passage" data-passage="passage" role="link" tabindex="0">a link to a passage</a>. Here's <a class="squiffy-link link-passage" data-passage="passage2" role="link" tabindex="0">another one</a>.</p>
63
63
  <p>You don't need to specify a name - for example, this <a class="squiffy-link link-passage" data-passage="link" role="link" tabindex="0">link</a> and this <a class="squiffy-link link-section" data-section="section" role="link" tabindex="0">section</a>.</p>
64
64
  <p>And this goes to the <a class="squiffy-link link-section" data-section="section2" role="link" tabindex="0">next section</a>.</p>
65
65
  <p>This line has links to <a class="squiffy-link link-section" data-section="section 3" role="link" tabindex="0">section 3</a> and <a class="squiffy-link link-section" data-section="section four" role="link" tabindex="0">section 4</a>.</p>
66
66
  <p>This line has links to <a class="squiffy-link link-passage" data-passage="passage 3" role="link" tabindex="0">passage 3</a> and <a class="squiffy-link link-passage" data-passage="passage four" role="link" tabindex="0">passage 4</a>.</p>
67
- <p>Oh look - <a class="squiffy-link link-passage" data-passage="it's a passage with an apostrophe" role="link" tabindex="0">it's a passage with an apostrophe</a>.</p></div></div></div><div class="squiffy-output-section" data-section="section 3" data-undo="{&quot;_section&quot;:&quot;Introduction&quot;,&quot;_seen_sections&quot;:[&quot;Introduction&quot;],&quot;_turncount&quot;:0}"><div class="squiffy-output-block"><div data-source="[[section 3]]"><p>Another section is here, with passages <a class="squiffy-link link-passage" data-passage="a" role="link" tabindex="0">a</a> and <a class="squiffy-link link-passage" data-passage="b" role="link" tabindex="0">b</a>.</p></div></div></div></div>"
67
+ <p>Oh look - <a class="squiffy-link link-passage" data-passage="it's a passage with an apostrophe" role="link" tabindex="0">it's a passage with an apostrophe</a>.</p></div></div></div><div class="squiffy-output-section" data-section="section 3" data-undo="{&quot;turns&quot;:0,&quot;_section&quot;:&quot;Introduction&quot;,&quot;_visits&quot;:{&quot;Introduction&quot;:1},&quot;_seen_sections&quot;:[&quot;Introduction&quot;],&quot;_turncount&quot;:0}"><div class="squiffy-output-block"><div data-source="[[section 3]]"><p>Another section is here, with passages <a class="squiffy-link link-passage" data-passage="a" role="link" tabindex="0">a</a> and <a class="squiffy-link link-passage" data-passage="b" role="link" tabindex="0">b</a>.</p></div></div></div></div>"
68
68
  `;
69
69
 
70
70
  exports[`Click a section link and go back 1`] = `
71
71
  "
72
- <div><div class="squiffy-output-section" data-section="Introduction" data-undo="{&quot;_section&quot;:null,&quot;_seen_sections&quot;:null,&quot;_turncount&quot;:null}"><div class="squiffy-output-block"><div data-source="[[Introduction]]"><h1>Squiffy Test</h1>
72
+ <div><div class="squiffy-output-section" data-section="Introduction" data-undo="{&quot;_section&quot;:null,&quot;_visits&quot;:null,&quot;_seen_sections&quot;:null,&quot;_turncount&quot;:null}"><div class="squiffy-output-block"><div data-source="[[Introduction]]"><h1>Squiffy Test</h1>
73
73
  <p>This is <a href="http://textadventures.co.uk">a website link</a>.</p>
74
74
  <p>This should be <a class="squiffy-link link-passage" data-passage="passage" role="link" tabindex="0">a link to a passage</a>. Here's <a class="squiffy-link link-passage" data-passage="passage2" role="link" tabindex="0">another one</a>.</p>
75
75
  <p>You don't need to specify a name - for example, this <a class="squiffy-link link-passage" data-passage="link" role="link" tabindex="0">link</a> and this <a class="squiffy-link link-section" data-section="section" role="link" tabindex="0">section</a>.</p>
@@ -81,60 +81,60 @@ exports[`Click a section link and go back 1`] = `
81
81
 
82
82
  exports[`Delete passage 1`] = `
83
83
  "
84
- <div><div class="squiffy-output-section" data-section="_default" data-undo="{&quot;_section&quot;:null,&quot;_seen_sections&quot;:null,&quot;_turncount&quot;:null}"><div class="squiffy-output-block"><div data-source="[[_default]]"><p>Click this: <a class="squiffy-link link-passage disabled" data-passage="a" role="link" tabindex="-1">a</a></p></div></div><div class="squiffy-output-passage" data-passage="a" data-undo="{&quot;_turncount&quot;:0,&quot;_seen_sections&quot;:[&quot;_default&quot;]}"><div class="squiffy-output-block"><div data-source="[[_default]][a]"><p>New passage</p></div></div></div></div></div>"
84
+ <div><div class="squiffy-output-section" data-section="_default" data-undo="{&quot;_section&quot;:null,&quot;_visits&quot;:null,&quot;_seen_sections&quot;:null,&quot;_turncount&quot;:null}"><div class="squiffy-output-block"><div data-source="[[_default]]"><p>Click this: <a class="squiffy-link link-passage disabled" data-passage="a" role="link" tabindex="-1">a</a></p></div></div><div class="squiffy-output-passage" data-passage="a" data-undo="{&quot;turns&quot;:0,&quot;_turncount&quot;:0,&quot;_visits&quot;:{&quot;_default&quot;:1},&quot;_seen_sections&quot;:[&quot;_default&quot;]}"><div class="squiffy-output-block"><div data-source="[[_default]][a]"><p>New passage</p></div></div></div></div></div>"
85
85
  `;
86
86
 
87
87
  exports[`Delete passage 2`] = `
88
88
  "
89
- <div><div class="squiffy-output-section" data-section="_default" data-undo="{&quot;_section&quot;:null,&quot;_seen_sections&quot;:null,&quot;_turncount&quot;:null}"><div class="squiffy-output-block"><div data-source="[[_default]]"><p>Click this: <a class="squiffy-link link-passage disabled" data-passage="a" role="link" tabindex="-1">a</a></p></div></div></div></div>"
89
+ <div><div class="squiffy-output-section" data-section="_default" data-undo="{&quot;_section&quot;:null,&quot;_visits&quot;:null,&quot;_seen_sections&quot;:null,&quot;_turncount&quot;:null}"><div class="squiffy-output-block"><div data-source="[[_default]]"><p>Click this: <a class="squiffy-link link-passage disabled" data-passage="a" role="link" tabindex="-1">a</a></p></div></div></div></div>"
90
90
  `;
91
91
 
92
92
  exports[`Delete section 1`] = `
93
93
  "
94
- <div><div class="squiffy-output-section" data-section="_default" data-undo="{&quot;_section&quot;:null,&quot;_seen_sections&quot;:null,&quot;_turncount&quot;:null}"><div class="squiffy-output-block"><div data-source="[[_default]]"><p>Click this: <a class="squiffy-link link-section" data-section="a" role="link" tabindex="0">a</a></p></div></div></div><div class="squiffy-output-section" data-section="a" data-undo="{&quot;_section&quot;:&quot;_default&quot;,&quot;_seen_sections&quot;:[&quot;_default&quot;],&quot;_turncount&quot;:0}"><div class="squiffy-output-block"><div data-source="[[a]]"><p>New section</p></div></div></div></div>"
94
+ <div><div class="squiffy-output-section" data-section="_default" data-undo="{&quot;_section&quot;:null,&quot;_visits&quot;:null,&quot;_seen_sections&quot;:null,&quot;_turncount&quot;:null}"><div class="squiffy-output-block"><div data-source="[[_default]]"><p>Click this: <a class="squiffy-link link-section" data-section="a" role="link" tabindex="0">a</a></p></div></div></div><div class="squiffy-output-section" data-section="a" data-undo="{&quot;turns&quot;:0,&quot;_section&quot;:&quot;_default&quot;,&quot;_visits&quot;:{&quot;_default&quot;:1},&quot;_seen_sections&quot;:[&quot;_default&quot;],&quot;_turncount&quot;:0}"><div class="squiffy-output-block"><div data-source="[[a]]"><p>New section</p></div></div></div></div>"
95
95
  `;
96
96
 
97
97
  exports[`Delete section 2`] = `
98
98
  "
99
- <div><div class="squiffy-output-section" data-section="_default" data-undo="{&quot;_section&quot;:null,&quot;_seen_sections&quot;:null,&quot;_turncount&quot;:null}"><div class="squiffy-output-block"><div data-source="[[_default]]"><p>Click this: <a class="squiffy-link link-section" data-section="a" role="link" tabindex="0">a</a></p></div></div></div></div>"
99
+ <div><div class="squiffy-output-section" data-section="_default" data-undo="{&quot;_section&quot;:null,&quot;_visits&quot;:null,&quot;_seen_sections&quot;:null,&quot;_turncount&quot;:null}"><div class="squiffy-output-block"><div data-source="[[_default]]"><p>Click this: <a class="squiffy-link link-section" data-section="a" role="link" tabindex="0">a</a></p></div></div></div></div>"
100
100
  `;
101
101
 
102
102
  exports[`Going back handling @clear and attribute changes 1`] = `
103
103
  "
104
- <div><div class="squiffy-clear-stack" style="display: none;"><div><div class="squiffy-output-section" data-section="_default" data-undo="{&quot;_section&quot;:null,&quot;_seen_sections&quot;:null,&quot;_turncount&quot;:null}"><div class="squiffy-output-block"><div data-source="[[_default]]"><p>Choose: <a class="squiffy-link link-passage" data-passage="a" role="link">a</a>, <a class="squiffy-link link-passage disabled" data-passage="b" role="link" tabindex="-1">b</a></p></div></div><div class="squiffy-output-passage" data-passage="b" data-undo="{&quot;_turncount&quot;:0,&quot;_seen_sections&quot;:[&quot;_default&quot;],&quot;test&quot;:null}"><div class="squiffy-output-block"><div data-source="[[_default]][b]"><p>You chose b. Now <a class="squiffy-link link-section" data-section="continue" role="link" tabindex="0">continue</a></p></div></div></div></div><div class="squiffy-output-section" data-section="continue" data-undo="{&quot;_section&quot;:&quot;_default&quot;,&quot;_seen_sections&quot;:[&quot;_default&quot;,&quot;b&quot;],&quot;test&quot;:456,&quot;_turncount&quot;:1}"><div class="squiffy-output-block"><div data-source="[[continue]]"><p>Now choose: <a class="squiffy-link link-passage disabled" data-passage="c" role="link" tabindex="-1">c</a>, <a class="squiffy-link link-passage" data-passage="d" role="link" tabindex="0">d</a></p></div></div></div></div></div><div class="squiffy-output-section" data-section="continue" data-clear="true"><div class="squiffy-output-passage" data-passage="c" data-undo="{&quot;_turncount&quot;:0,&quot;_seen_sections&quot;:[&quot;_default&quot;,&quot;b&quot;,&quot;continue&quot;],&quot;test&quot;:789}"><div class="squiffy-output-block"><div data-source="[[continue]][c]"><p>You chose c. Now <a class="squiffy-link link-section" data-section="finish" role="link" tabindex="0">finish</a></p></div></div></div></div></div>"
104
+ <div><div class="squiffy-clear-stack" style="display: none;"><div><div class="squiffy-output-section" data-section="_default" data-undo="{&quot;_section&quot;:null,&quot;_visits&quot;:null,&quot;_seen_sections&quot;:null,&quot;_turncount&quot;:null}"><div class="squiffy-output-block"><div data-source="[[_default]]"><p>Choose: <a class="squiffy-link link-passage" data-passage="a" role="link">a</a>, <a class="squiffy-link link-passage disabled" data-passage="b" role="link" tabindex="-1">b</a></p></div></div><div class="squiffy-output-passage" data-passage="b" data-undo="{&quot;turns&quot;:0,&quot;_turncount&quot;:0,&quot;_visits&quot;:{&quot;_default&quot;:1},&quot;_seen_sections&quot;:[&quot;_default&quot;],&quot;test&quot;:null}"><div class="squiffy-output-block"><div data-source="[[_default]][b]"><p>You chose b. Now <a class="squiffy-link link-section" data-section="continue" role="link" tabindex="0">continue</a></p></div></div></div></div><div class="squiffy-output-section" data-section="continue" data-undo="{&quot;turns&quot;:1,&quot;_section&quot;:&quot;_default&quot;,&quot;_visits&quot;:{&quot;_default&quot;:1,&quot;b&quot;:1},&quot;_seen_sections&quot;:[&quot;_default&quot;,&quot;b&quot;],&quot;test&quot;:456,&quot;_turncount&quot;:1}"><div class="squiffy-output-block"><div data-source="[[continue]]"><p>Now choose: <a class="squiffy-link link-passage disabled" data-passage="c" role="link" tabindex="-1">c</a>, <a class="squiffy-link link-passage" data-passage="d" role="link" tabindex="0">d</a></p></div></div></div></div></div><div class="squiffy-output-section" data-section="continue" data-clear="true"><div class="squiffy-output-passage" data-passage="c" data-undo="{&quot;turns&quot;:2,&quot;_turncount&quot;:0,&quot;_visits&quot;:{&quot;_default&quot;:1,&quot;b&quot;:1,&quot;continue&quot;:1},&quot;_seen_sections&quot;:[&quot;_default&quot;,&quot;b&quot;,&quot;continue&quot;],&quot;test&quot;:789}"><div class="squiffy-output-block"><div data-source="[[continue]][c]"><p>You chose c. Now <a class="squiffy-link link-section" data-section="finish" role="link" tabindex="0">finish</a></p></div></div></div></div></div>"
105
105
  `;
106
106
 
107
107
  exports[`Going back handling @clear and attribute changes 2`] = `
108
108
  "
109
- <div><div class="squiffy-clear-stack" style="display: none;"></div><div class="squiffy-output-section" data-section="_default" data-undo="{&quot;_section&quot;:null,&quot;_seen_sections&quot;:null,&quot;_turncount&quot;:null}"><div class="squiffy-output-block"><div data-source="[[_default]]"><p>Choose: <a class="squiffy-link link-passage" data-passage="a" role="link">a</a>, <a class="squiffy-link link-passage disabled" data-passage="b" role="link" tabindex="-1">b</a></p></div></div><div class="squiffy-output-passage" data-passage="b" data-undo="{&quot;_turncount&quot;:0,&quot;_seen_sections&quot;:[&quot;_default&quot;],&quot;test&quot;:null}"><div class="squiffy-output-block"><div data-source="[[_default]][b]"><p>You chose b. Now <a class="squiffy-link link-section" data-section="continue" role="link" tabindex="0">continue</a></p></div></div></div></div><div class="squiffy-output-section" data-section="continue" data-undo="{&quot;_section&quot;:&quot;_default&quot;,&quot;_seen_sections&quot;:[&quot;_default&quot;,&quot;b&quot;],&quot;test&quot;:456,&quot;_turncount&quot;:1}"><div class="squiffy-output-block"><div data-source="[[continue]]"><p>Now choose: <a class="squiffy-link link-passage" data-passage="c" role="link">c</a>, <a class="squiffy-link link-passage" data-passage="d" role="link" tabindex="0">d</a></p></div></div></div></div>"
109
+ <div><div class="squiffy-clear-stack" style="display: none;"></div><div class="squiffy-output-section" data-section="_default" data-undo="{&quot;_section&quot;:null,&quot;_visits&quot;:null,&quot;_seen_sections&quot;:null,&quot;_turncount&quot;:null}"><div class="squiffy-output-block"><div data-source="[[_default]]"><p>Choose: <a class="squiffy-link link-passage" data-passage="a" role="link">a</a>, <a class="squiffy-link link-passage disabled" data-passage="b" role="link" tabindex="-1">b</a></p></div></div><div class="squiffy-output-passage" data-passage="b" data-undo="{&quot;turns&quot;:0,&quot;_turncount&quot;:0,&quot;_visits&quot;:{&quot;_default&quot;:1},&quot;_seen_sections&quot;:[&quot;_default&quot;],&quot;test&quot;:null}"><div class="squiffy-output-block"><div data-source="[[_default]][b]"><p>You chose b. Now <a class="squiffy-link link-section" data-section="continue" role="link" tabindex="0">continue</a></p></div></div></div></div><div class="squiffy-output-section" data-section="continue" data-undo="{&quot;turns&quot;:1,&quot;_section&quot;:&quot;_default&quot;,&quot;_visits&quot;:{&quot;_default&quot;:1,&quot;b&quot;:1},&quot;_seen_sections&quot;:[&quot;_default&quot;,&quot;b&quot;],&quot;test&quot;:456,&quot;_turncount&quot;:1}"><div class="squiffy-output-block"><div data-source="[[continue]]"><p>Now choose: <a class="squiffy-link link-passage" data-passage="c" role="link">c</a>, <a class="squiffy-link link-passage" data-passage="d" role="link" tabindex="0">d</a></p></div></div></div></div>"
110
110
  `;
111
111
 
112
112
  exports[`Update default section output 1`] = `
113
113
  "
114
- <div><div class="squiffy-output-section" data-section="_default" data-undo="{&quot;_section&quot;:null,&quot;_seen_sections&quot;:null,&quot;_turncount&quot;:null}"><div class="squiffy-output-block"><div data-source="[[_default]]"><p>Hello world</p></div></div></div></div>"
114
+ <div><div class="squiffy-output-section" data-section="_default" data-undo="{&quot;_section&quot;:null,&quot;_visits&quot;:null,&quot;_seen_sections&quot;:null,&quot;_turncount&quot;:null}"><div class="squiffy-output-block"><div data-source="[[_default]]"><p>Hello world</p></div></div></div></div>"
115
115
  `;
116
116
 
117
117
  exports[`Update default section output 2`] = `
118
118
  "
119
- <div><div class="squiffy-output-section" data-section="_default" data-undo="{&quot;_section&quot;:null,&quot;_seen_sections&quot;:null,&quot;_turncount&quot;:null}"><div class="squiffy-output-block"><div data-source="[[_default]]"><p>Updated content</p></div></div></div></div>"
119
+ <div><div class="squiffy-output-section" data-section="_default" data-undo="{&quot;_section&quot;:null,&quot;_visits&quot;:null,&quot;_seen_sections&quot;:null,&quot;_turncount&quot;:null}"><div class="squiffy-output-block"><div data-source="[[_default]]"><p>Updated content</p></div></div></div></div>"
120
120
  `;
121
121
 
122
122
  exports[`Update passage output - passage name "a" 1`] = `
123
123
  "
124
- <div><div class="squiffy-output-section" data-section="_default" data-undo="{&quot;_section&quot;:null,&quot;_seen_sections&quot;:null,&quot;_turncount&quot;:null}"><div class="squiffy-output-block"><div data-source="[[_default]]"><p>Click this: <a class="squiffy-link link-passage disabled" data-passage="a" role="link" tabindex="-1">a</a></p></div></div><div class="squiffy-output-passage" data-passage="a" data-undo="{&quot;_turncount&quot;:0,&quot;_seen_sections&quot;:[&quot;_default&quot;]}"><div class="squiffy-output-block"><div data-source="[[_default]][a]"><p>Passage a content</p></div></div></div></div></div>"
124
+ <div><div class="squiffy-output-section" data-section="_default" data-undo="{&quot;_section&quot;:null,&quot;_visits&quot;:null,&quot;_seen_sections&quot;:null,&quot;_turncount&quot;:null}"><div class="squiffy-output-block"><div data-source="[[_default]]"><p>Click this: <a class="squiffy-link link-passage disabled" data-passage="a" role="link" tabindex="-1">a</a></p></div></div><div class="squiffy-output-passage" data-passage="a" data-undo="{&quot;turns&quot;:0,&quot;_turncount&quot;:0,&quot;_visits&quot;:{&quot;_default&quot;:1},&quot;_seen_sections&quot;:[&quot;_default&quot;]}"><div class="squiffy-output-block"><div data-source="[[_default]][a]"><p>Passage a content</p></div></div></div></div></div>"
125
125
  `;
126
126
 
127
127
  exports[`Update passage output - passage name "a" 2`] = `
128
128
  "
129
- <div><div class="squiffy-output-section" data-section="_default" data-undo="{&quot;_section&quot;:null,&quot;_seen_sections&quot;:null,&quot;_turncount&quot;:null}"><div class="squiffy-output-block"><div data-source="[[_default]]"><p>Click this: <a class="squiffy-link link-passage disabled" data-passage="a" role="link" tabindex="-1">a</a></p></div></div><div class="squiffy-output-passage" data-passage="a" data-undo="{&quot;_turncount&quot;:0,&quot;_seen_sections&quot;:[&quot;_default&quot;]}"><div class="squiffy-output-block"><div data-source="[[_default]][a]"><p>Updated passage content</p></div></div></div></div></div>"
129
+ <div><div class="squiffy-output-section" data-section="_default" data-undo="{&quot;_section&quot;:null,&quot;_visits&quot;:null,&quot;_seen_sections&quot;:null,&quot;_turncount&quot;:null}"><div class="squiffy-output-block"><div data-source="[[_default]]"><p>Click this: <a class="squiffy-link link-passage disabled" data-passage="a" role="link" tabindex="-1">a</a></p></div></div><div class="squiffy-output-passage" data-passage="a" data-undo="{&quot;turns&quot;:0,&quot;_turncount&quot;:0,&quot;_visits&quot;:{&quot;_default&quot;:1},&quot;_seen_sections&quot;:[&quot;_default&quot;]}"><div class="squiffy-output-block"><div data-source="[[_default]][a]"><p>Updated passage content</p></div></div></div></div></div>"
130
130
  `;
131
131
 
132
132
  exports[`Update passage output - passage name "a'1" 1`] = `
133
133
  "
134
- <div><div class="squiffy-output-section" data-section="_default" data-undo="{&quot;_section&quot;:null,&quot;_seen_sections&quot;:null,&quot;_turncount&quot;:null}"><div class="squiffy-output-block"><div data-source="[[_default]]"><p>Click this: <a class="squiffy-link link-passage disabled" data-passage="a'1" role="link" tabindex="-1">a'1</a></p></div></div><div class="squiffy-output-passage" data-passage="a'1" data-undo="{&quot;_turncount&quot;:0,&quot;_seen_sections&quot;:[&quot;_default&quot;]}"><div class="squiffy-output-block"><div data-source="[[_default]][a'1]"><p>Passage a content</p></div></div></div></div></div>"
134
+ <div><div class="squiffy-output-section" data-section="_default" data-undo="{&quot;_section&quot;:null,&quot;_visits&quot;:null,&quot;_seen_sections&quot;:null,&quot;_turncount&quot;:null}"><div class="squiffy-output-block"><div data-source="[[_default]]"><p>Click this: <a class="squiffy-link link-passage disabled" data-passage="a'1" role="link" tabindex="-1">a'1</a></p></div></div><div class="squiffy-output-passage" data-passage="a'1" data-undo="{&quot;turns&quot;:0,&quot;_turncount&quot;:0,&quot;_visits&quot;:{&quot;_default&quot;:1},&quot;_seen_sections&quot;:[&quot;_default&quot;]}"><div class="squiffy-output-block"><div data-source="[[_default]][a'1]"><p>Passage a content</p></div></div></div></div></div>"
135
135
  `;
136
136
 
137
137
  exports[`Update passage output - passage name "a'1" 2`] = `
138
138
  "
139
- <div><div class="squiffy-output-section" data-section="_default" data-undo="{&quot;_section&quot;:null,&quot;_seen_sections&quot;:null,&quot;_turncount&quot;:null}"><div class="squiffy-output-block"><div data-source="[[_default]]"><p>Click this: <a class="squiffy-link link-passage disabled" data-passage="a'1" role="link" tabindex="-1">a'1</a></p></div></div><div class="squiffy-output-passage" data-passage="a'1" data-undo="{&quot;_turncount&quot;:0,&quot;_seen_sections&quot;:[&quot;_default&quot;]}"><div class="squiffy-output-block"><div data-source="[[_default]][a'1]"><p>Updated passage content</p></div></div></div></div></div>"
139
+ <div><div class="squiffy-output-section" data-section="_default" data-undo="{&quot;_section&quot;:null,&quot;_visits&quot;:null,&quot;_seen_sections&quot;:null,&quot;_turncount&quot;:null}"><div class="squiffy-output-block"><div data-source="[[_default]]"><p>Click this: <a class="squiffy-link link-passage disabled" data-passage="a'1" role="link" tabindex="-1">a'1</a></p></div></div><div class="squiffy-output-passage" data-passage="a'1" data-undo="{&quot;turns&quot;:0,&quot;_turncount&quot;:0,&quot;_visits&quot;:{&quot;_default&quot;:1},&quot;_seen_sections&quot;:[&quot;_default&quot;]}"><div class="squiffy-output-block"><div data-source="[[_default]][a'1]"><p>Updated passage content</p></div></div></div></div></div>"
140
140
  `;
@@ -1,5 +1,5 @@
1
1
  import { expect, test, describe } from "vitest";
2
- import { rewriteInfixCondition, rewriteInfixExpressions } from "./infixExpressions.js";
2
+ import { rewriteDisplayExpression, rewriteInfixArguments, rewriteInfixCondition, rewriteInfixExpressions, rewriteValueExpression, splitSetters } from "./infixExpressions.js";
3
3
 
4
4
  describe("rewriteInfixCondition", () => {
5
5
  test.each([
@@ -123,6 +123,83 @@ describe("rewriteInfixCondition", () => {
123
123
  expect(() => rewriteInfixCondition(input)).toThrow(message);
124
124
  });
125
125
 
126
+ test.each([
127
+ ["a + b > 1", "(gt (add a b) 1)"],
128
+ ["a - b > 1", "(gt (sub a b) 1)"],
129
+ ["a * b > 1", "(gt (mul a b) 1)"],
130
+ ["a / b > 1", "(gt (div a b) 1)"],
131
+ ["a % b = 1", "(eq (mod a b) 1)"],
132
+ ["-a < 0", "(lt (sub 0 a) 0)"],
133
+ ["- a < 0", "(lt (sub 0 a) 0)"],
134
+ ["gold >= price * 2", "(gte gold (mul price 2))"],
135
+ ])("arithmetic operator: %s", (input, expected) => {
136
+ expect(rewriteInfixCondition(input)).toBe(expected);
137
+ });
138
+
139
+ test.each([
140
+ ["a + b * c = 1", "(eq (add a (mul b c)) 1)"],
141
+ ["a * b + c = 1", "(eq (add (mul a b) c) 1)"],
142
+ ["a - b - c = 1", "(eq (sub (sub a b) c) 1)"],
143
+ ["a / b / c = 1", "(eq (div (div a b) c) 1)"],
144
+ ["a % b * c = 1", "(eq (mul (mod a b) c) 1)"],
145
+ ["(a + b) * c = 1", "(eq (mul (add a b) c) 1)"],
146
+ ["a * (b + c) = 1", "(eq (mul a (add b c)) 1)"],
147
+ ["-a * b = 1", "(eq (mul (sub 0 a) b) 1)"],
148
+ ["-(a + b) = 1", "(eq (sub 0 (add a b)) 1)"],
149
+ ["a - -b = 1", "(eq (sub a (sub 0 b)) 1)"],
150
+ ["a + b > c and not d - 1 = 0", "(and (gt (add a b) c) (not (eq (sub d 1) 0)))"],
151
+ ["a > b + 1 or c", "(or (gt a (add b 1)) c)"],
152
+ ["(length \"items\") * 2 > 3", "(gt (mul (length \"items\") 2) 3)"],
153
+ ])("arithmetic precedence: %s", (input, expected) => {
154
+ expect(rewriteInfixCondition(input)).toBe(expected);
155
+ });
156
+
157
+ test.each([
158
+ ["a+b>1", "(gt (add a b) 1)"],
159
+ ["a*b>1", "(gt (mul a b) 1)"],
160
+ ["a%b>1", "(gt (mod a b) 1)"],
161
+ ["a -1 > 0", "(gt (sub a 1) 0)"],
162
+ ["a - 1 > 0", "(gt (sub a 1) 0)"],
163
+ ["a -b > 0", "(gt (sub a b) 0)"],
164
+ ["a /b > 0", "(gt (div a b) 0)"],
165
+ ["a * -1 > 0", "(gt (mul a -1) 0)"],
166
+ ["a > -1", "(gt a -1)"],
167
+ ["1.5 * a > 0", "(gt (mul 1.5 a) 0)"],
168
+ ])("arithmetic spacing: %s", (input, expected) => {
169
+ expect(rewriteInfixCondition(input)).toBe(expected);
170
+ });
171
+
172
+ test.each([
173
+ ["my-score > 1", "(gt my-score 1)"],
174
+ ["a-b > 1", "(gt a-b 1)"],
175
+ ["../score > 1", "(gt ../score 1)"],
176
+ ["player/score > 1", "(gt player/score 1)"],
177
+ ["[gold + silver] > 1", "(gt [gold + silver] 1)"],
178
+ ["name = \"a + b\"", "(eq name \"a + b\")"],
179
+ ])("- and / inside names and paths: %s", (input, expected) => {
180
+ expect(rewriteInfixCondition(input)).toBe(expected);
181
+ });
182
+
183
+ test.each([
184
+ "my-score",
185
+ "(gt x -1)",
186
+ "(foo a -1)",
187
+ "(x -1)",
188
+ ])("passes through prefix syntax with -: %s", (input) => {
189
+ expect(rewriteInfixCondition(input)).toBeNull();
190
+ });
191
+
192
+ test.each([
193
+ ["a +", "expected a value after '+'"],
194
+ ["a * > 1", "expected a value before '>'"],
195
+ ["* a", "expected a value before '*'"],
196
+ ["a + + b", "expected a value before '+'"],
197
+ ["-", "expected a value after '-'"],
198
+ ["(a + b", "expected ')' but found end of expression"],
199
+ ])("arithmetic error: %s", (input, message) => {
200
+ expect(() => rewriteInfixCondition(input)).toThrow(message);
201
+ });
202
+
126
203
  test("error message includes the condition", () => {
127
204
  expect(() => rewriteInfixCondition(" score > ")).toThrow("Invalid condition \"score >\": expected a value after '>'");
128
205
  });
@@ -134,6 +211,65 @@ describe("rewriteInfixCondition", () => {
134
211
  });
135
212
  });
136
213
 
214
+ describe("rewriteInfixArguments", () => {
215
+ test.each([
216
+ ["\"gold\" gold + price * 2", "\"gold\" (add gold (mul price 2))"],
217
+ ["\"gold\" (gold + price) * 2", "\"gold\" (mul (add gold price) 2)"],
218
+ ["\"name\" name + \" the Brave\"", "\"name\" (add name \" the Brave\")"],
219
+ ["\"x\" -y", "\"x\" (sub 0 y)"],
220
+ ["\"x\" a > b", "\"x\" (gt a b)"],
221
+ ["\"x\" a and b", "\"x\" (and a b)"],
222
+ ["\"x\" (length \"items\") - 1", "\"x\" (sub (length \"items\") 1)"],
223
+ ])("%s", (input, expected) => {
224
+ expect(rewriteInfixArguments(input)).toBe(expected);
225
+ });
226
+
227
+ test.each([
228
+ "\"score\" 100",
229
+ "\"score\" -1",
230
+ "\"name\" \"Alice\"",
231
+ "\"items\" (array \"a\" \"b\")",
232
+ "\"x\" (add a b)",
233
+ "\"counter\"",
234
+ "\"x\" my-score",
235
+ ])("passes through prefix syntax: %s", (input) => {
236
+ expect(rewriteInfixArguments(input)).toBeNull();
237
+ });
238
+
239
+ test.each([
240
+ ["\"gold\" gold +", "Invalid expression \"\"gold\" gold +\": expected a value after '+'"],
241
+ ["\"gold\" gold + 1 x", "unexpected 'x'"],
242
+ ["\"gold\" + 1", "expected a value before '+'"],
243
+ ])("error: %s", (input, message) => {
244
+ expect(() => rewriteInfixArguments(input)).toThrow(message);
245
+ });
246
+ });
247
+
248
+ describe("rewriteDisplayExpression", () => {
249
+ test.each([
250
+ ["price * 2", "mul price 2"],
251
+ ["gold + price * 2", "add gold (mul price 2)"],
252
+ ["a > b", "gt a b"],
253
+ ["gold", "gold"],
254
+ [" (gold) ", "gold"],
255
+ ["(length \"items\")", "length \"items\""],
256
+ ["-gold", "sub 0 gold"],
257
+ ])("%s", (input, expected) => {
258
+ expect(rewriteDisplayExpression(input)).toBe(expected);
259
+ });
260
+
261
+ test.each([
262
+ ["", "expected a value"],
263
+ ["a +", "expected a value after '+'"],
264
+ ["a b", "unexpected 'b'"],
265
+ ["5", "expected an attribute or a calculation"],
266
+ ["\"text\"", "expected an attribute or a calculation"],
267
+ ["\"unterminated", "unterminated string"],
268
+ ])("error: %s", (input, message) => {
269
+ expect(() => rewriteDisplayExpression(input)).toThrow(message);
270
+ });
271
+ });
272
+
137
273
  describe("rewriteInfixExpressions", () => {
138
274
  test("#if", () => {
139
275
  expect(rewriteInfixExpressions("{{#if score > 100 and has_key}}yes{{/if}}"))
@@ -184,4 +320,60 @@ describe("rewriteInfixExpressions", () => {
184
320
  test("throws for malformed infix", () => {
185
321
  expect(() => rewriteInfixExpressions("{{#if score >}}x{{/if}}")).toThrow("Invalid condition \"score >\"");
186
322
  });
323
+
324
+ test("{{set}}, {{inc}} and {{dec}}", () => {
325
+ expect(rewriteInfixExpressions("{{set \"gold\" gold + price * 2}}{{inc \"gold\" price * 2}}{{dec \"hp\" dmg - armour}}"))
326
+ .toBe("{{set \"gold\" (add gold (mul price 2))}}{{inc \"gold\" (mul price 2)}}{{dec \"hp\" (sub dmg armour)}}");
327
+ });
328
+
329
+ test("{{set}} with prefix syntax is untouched", () => {
330
+ const text = "{{set \"score\" 100}}{{inc \"x\"}}{{set \"items\" (array \"a\")}}{{settings}}{{inc}}";
331
+ expect(rewriteInfixExpressions(text)).toBe(text);
332
+ });
333
+
334
+ test("{{= expression}}", () => {
335
+ expect(rewriteInfixExpressions("Cost: {{= price * 2}}, {{~= a + b ~}} and {{= gold}}."))
336
+ .toBe("Cost: {{mul price 2}}, {{~add a b~}} and {{gold}}.");
337
+ });
338
+
339
+ test("escaped {{= }} is untouched", () => {
340
+ expect(rewriteInfixExpressions("\\{{= a + b}}")).toBe("\\{{= a + b}}");
341
+ });
342
+
343
+ test("throws for malformed {{set}} and {{= }}", () => {
344
+ expect(() => rewriteInfixExpressions("{{set \"x\" a +}}")).toThrow("Invalid expression \"\"x\" a +\"");
345
+ expect(() => rewriteInfixExpressions("{{= a +}}")).toThrow("Invalid expression \"a +\"");
346
+ });
347
+ });
348
+
349
+ describe("rewriteValueExpression", () => {
350
+ test.each([
351
+ ["gold", "gold"],
352
+ ["10", "10"],
353
+ ['"sword"', '"sword"'],
354
+ ["true", "true"],
355
+ ["gold + price * 2", "(add gold (mul price 2))"],
356
+ ["gold > 100", "(gt gold 100)"],
357
+ ["not has_key", "(not has_key)"],
358
+ ['(seen "intro")', '(seen "intro")'],
359
+ ])("%s -> %s", (input, expected) => {
360
+ expect(rewriteValueExpression(input)).toBe(expected);
361
+ });
362
+
363
+ test.each(["", "gold +", "gold price", "(gold"])("rejects %j", input => {
364
+ expect(() => rewriteValueExpression(input)).toThrow(/Invalid expression/);
365
+ });
366
+ });
367
+
368
+ describe("splitSetters", () => {
369
+ test.each([
370
+ ["a = 1, b += 2", ["a = 1", "b += 2"]],
371
+ [' message = "Hi, there", done', ['message = "Hi, there"', "done"]],
372
+ ["name = 'Bob, the Brave', x", ["name = 'Bob, the Brave'", "x"]],
373
+ ['a = "say \\"hi, there\\"", b', ['a = "say \\"hi, there\\""', "b"]],
374
+ ["a = (add b 1), c", ["a = (add b 1)", "c"]],
375
+ ["a = 1,, b = 2,", ["a = 1", "b = 2"]],
376
+ ])("%j", (input, expected) => {
377
+ expect(splitSetters(input)).toEqual(expected);
378
+ });
187
379
  });