@@ -4,7 +4,7 @@ import fc from 'fast-check';
44import { readFileSync } from 'node:fs' ;
55import { grammars , grammar } from 'ohm-js-legacy/v18' ;
66
7- import { scriptRel , toWasmGrammar } from './_helpers.js' ;
7+ import { scriptRel , legacyGrammarToWasm } from './_helpers.js' ;
88
99const grammarSource = readFileSync ( scriptRel ( 'data/liquid-html.ohm' ) , 'utf8' ) ;
1010const ns = grammars ( grammarSource ) ;
@@ -79,7 +79,7 @@ function sameFailurePos(wasmGrammar) {
7979}
8080
8181test ( 'failure pos (fast-check)' , async t => {
82- const g = await toWasmGrammar ( ns . LiquidHTML ) ;
82+ const g = await legacyGrammarToWasm ( ns . LiquidHTML ) ;
8383 const details = fc . check ( sameFailurePos ( g ) , {
8484 includeErrorInReport : true ,
8585 interruptAfterTimeLimit : 1000 ,
@@ -94,7 +94,7 @@ test('failure pos: basic 1', async t => {
9494 Start = number+
9595 number = digit+
9696 }` ) ;
97- const wasmGrammar = await toWasmGrammar ( g ) ;
97+ const wasmGrammar = await legacyGrammarToWasm ( g ) ;
9898
9999 t . is ( failurePos ( g , 'a' ) , 0 ) ;
100100 t . is ( failurePos ( wasmGrammar , 'a' ) , 0 ) ;
@@ -113,7 +113,7 @@ test('failure pos: basic 2', async t => {
113113 | number
114114 number = digit+
115115 }` ) ;
116- const wasmGrammar = await toWasmGrammar ( g ) ;
116+ const wasmGrammar = await legacyGrammarToWasm ( g ) ;
117117
118118 t . is ( failurePos ( g , '99 + 66' ) , 7 ) ;
119119 t . is ( failurePos ( wasmGrammar , '99 + 66' ) , 7 ) ;
@@ -125,7 +125,7 @@ test('failure pos: basic 3', async t => {
125125 Start = letter letter
126126 space := "/*" (~"*/" any)* "*/"
127127 }` ) ;
128- const wasmGrammar = await toWasmGrammar ( g ) ;
128+ const wasmGrammar = await legacyGrammarToWasm ( g ) ;
129129
130130 t . is ( failurePos ( wasmGrammar , '99' ) , 0 ) ;
131131} ) ;
@@ -137,7 +137,7 @@ test('failure pos: lookahead', async t => {
137137 start = ~(anyTwo "!") "a" "b"
138138 anyTwo = any any
139139 }` ) ;
140- const wasmGrammar = await toWasmGrammar ( g ) ;
140+ const wasmGrammar = await legacyGrammarToWasm ( g ) ;
141141
142142 // Original Ohm behaviour is to ignore failures inside the lookahead, so
143143 // it produces 'Expected "a"' at pos 0.
@@ -153,7 +153,7 @@ test('failure pos: memoization', async t => {
153153 start = ~anyTwo anyTwo
154154 anyTwo = any any
155155 }` ) ;
156- const wasmGrammar = await toWasmGrammar ( g ) ;
156+ const wasmGrammar = await legacyGrammarToWasm ( g ) ;
157157
158158 // Original Ohm behaviour is to ignore failures inside the lookahead, so
159159 // it produces 'Expected "a"' at pos 0.
@@ -168,7 +168,7 @@ test('failure pos: space skipping', async t => {
168168 Start = digit digit
169169 space += "/*" (~"*/" any)* "*/" -- comment
170170 }` ) ;
171- const wasmGrammar = await toWasmGrammar ( g ) ;
171+ const wasmGrammar = await legacyGrammarToWasm ( g ) ;
172172
173173 // Failure inside space skipping should be ignored.
174174 t . is ( failurePos ( g , '9 /* bad' ) , 2 ) ;
@@ -183,7 +183,7 @@ test('failure pos is always after space skipping', async t => {
183183 | "3." twice<"b">
184184 twice<x> = x x
185185 }` ) ;
186- const wasmGrammar = await toWasmGrammar ( g ) ;
186+ const wasmGrammar = await legacyGrammarToWasm ( g ) ;
187187
188188 // Regular terminal
189189 t . is ( failurePos ( g , '1. c' ) , 3 ) ;
@@ -204,7 +204,7 @@ test('failure pos is always after space skipping', async t => {
204204} ) ;
205205
206206test ( 'fast-check zoo' , async t => {
207- const wasmGrammar = await toWasmGrammar ( ns . LiquidHTML ) ;
207+ const wasmGrammar = await legacyGrammarToWasm ( ns . LiquidHTML ) ;
208208
209209 const input = '< {% if swatch_value %}' ;
210210 t . is ( failurePos ( wasmGrammar , input ) , failurePos ( ns . LiquidHTML , input ) ) ;
0 commit comments