@@ -3,8 +3,8 @@ import test from 'node:test';
33import * as mr from './fp.js' ;
44import type { MIR , Range } from './fp.js' ;
55
6- test ( 'parse' , t => {
7- t . test ( 'no option' , ( ) => {
6+ test ( 'parse' , async t => {
7+ await t . test ( 'no option' , ( ) => {
88 assert . deepEqual ( mr . parse ( '' ) , [ ] ) ;
99 assert . deepEqual ( mr . parse ( '0' ) , [ [ 0 , 0 ] ] ) ;
1010 assert . deepEqual ( mr . parse ( '1-3,5,7-10' ) , [
@@ -16,7 +16,7 @@ test('parse', t => {
1616 assert . throws ( ( ) => mr . parse ( '(-10)' ) , SyntaxError ) ;
1717 } ) ;
1818
19- t . test ( 'parse negative' , ( ) => {
19+ await t . test ( 'parse negative' , ( ) => {
2020 assert . deepEqual ( mr . parse ( '(-5)' , { parseNegative : true } ) , [ [ - 5 , - 5 ] ] ) ;
2121 assert . deepEqual (
2222 mr . parse ( '(-10)-(-7),(-5),(-3)-(-1)' , { parseNegative : true } ) ,
@@ -28,7 +28,7 @@ test('parse', t => {
2828 ) ;
2929 } ) ;
3030
31- t . test ( 'parse unbounded' , ( ) => {
31+ await t . test ( 'parse unbounded' , ( ) => {
3232 assert . deepEqual ( mr . parse ( '10-' , { parseUnbounded : true } ) , [
3333 [ 10 , Infinity ]
3434 ] ) ;
@@ -41,15 +41,15 @@ test('parse', t => {
4141 ] ) ;
4242 } ) ;
4343
44- t . test ( 'strip spaces' , ( ) => {
44+ await t . test ( 'strip spaces' , ( ) => {
4545 assert . deepEqual ( mr . parse ( '1 -3, 5,\t7-10\n' ) , [
4646 [ 1 , 3 ] ,
4747 [ 5 , 5 ] ,
4848 [ 7 , 10 ]
4949 ] ) ;
5050 } ) ;
5151
52- t . test ( 'normalize' , ( ) => {
52+ await t . test ( 'normalize' , ( ) => {
5353 assert . deepEqual ( mr . parse ( '1,8,2-4,7,5-6,10-9' ) , [ [ 1 , 10 ] ] ) ;
5454 assert . deepEqual ( mr . parse ( '10-8,7-5,1-4' ) , [ [ 1 , 10 ] ] ) ;
5555 assert . deepEqual ( parseAll ( '8-10,(-5),100-, 0,7,(-1)-(-4),1-6' ) , [
@@ -58,7 +58,7 @@ test('parse', t => {
5858 ] ) ;
5959 } ) ;
6060
61- t . test ( 'throw SyntaxError for invalid input' , ( ) => {
61+ await t . test ( 'throw SyntaxError for invalid input' , ( ) => {
6262 assert . throws ( ( ) => mr . parse ( 'abc' ) , SyntaxError ) ;
6363 assert . throws ( ( ) => mr . parse ( '1.5' ) , SyntaxError ) ;
6464 assert . throws ( ( ) => mr . parse ( '2-5,8-10,*,99' ) , SyntaxError ) ;
@@ -69,7 +69,7 @@ test('parse', t => {
6969 assert . doesNotThrow ( ( ) => mr . parse ( '' ) ) ;
7070 } ) ;
7171
72- t . test ( 'throw RangeError for huge integer strings' , ( ) => {
72+ await t . test ( 'throw RangeError for huge integer strings' , ( ) => {
7373 assert . throws ( ( ) => mr . parse ( '1-900719925474099100' ) , RangeError ) ;
7474 assert . throws ( ( ) => parseAll ( '(-900719925474099100)' ) , RangeError ) ;
7575 } ) ;
@@ -139,10 +139,10 @@ const makeT2 =
139139 }
140140 } ;
141141
142- test ( 'append' , t => {
142+ test ( 'append' , async t => {
143143 const t2 = makeT2 ( mr . append , mr . stringify , true ) ;
144144
145- t . test ( 'positive' , ( ) => {
145+ await t . test ( 'positive' , ( ) => {
146146 t2 ( '5-10' , '5' , '5-10' ) ;
147147 t2 ( '5-10' , '8' , '5-10' ) ;
148148 t2 ( '5-10' , '10' , '5-10' ) ;
@@ -160,12 +160,12 @@ test('append', t => {
160160 t2 ( '1,8,10' , '2-3,4-5,6,7,9' , '1-10' ) ;
161161 } ) ;
162162
163- t . test ( 'negative' , ( ) => {
163+ await t . test ( 'negative' , ( ) => {
164164 t2 ( '(-5)-(-3)' , '(-6),(-2),4,5' , '(-6)-(-2),4-5' ) ;
165165 t2 ( '(-5)-(-3)' , '3' , '(-5)-(-3),3' ) ;
166166 } ) ;
167167
168- t . test ( 'unbounded' , ( ) => {
168+ await t . test ( 'unbounded' , ( ) => {
169169 t2 ( '5-' , '10' , '5-' ) ;
170170 t2 ( '5-' , '4' , '4-' ) ;
171171 t2 ( '5-' , '3' , '3,5-' ) ;
@@ -188,10 +188,10 @@ test('append', t => {
188188 } ) ;
189189} ) ;
190190
191- test ( 'subtract' , t => {
191+ test ( 'subtract' , async t => {
192192 const t2 = makeT2 ( mr . subtract , mr . stringify ) ;
193193
194- t . test ( 'positive' , ( ) => {
194+ await t . test ( 'positive' , ( ) => {
195195 t2 ( '1-10' , '100' , '1-10' ) ;
196196 t2 ( '1-10' , '0' , '1-10' ) ;
197197 t2 ( '1-10' , '11' , '1-10' ) ;
@@ -204,7 +204,7 @@ test('subtract', t => {
204204 t2 ( '1-100' , '1,3,5,7,9' , '2,4,6,8,10-100' ) ;
205205 } ) ;
206206
207- t . test ( 'negative' , ( ) => {
207+ await t . test ( 'negative' , ( ) => {
208208 t2 ( '(-10)-(-3)' , '5' , '(-10)-(-3)' ) ;
209209 t2 ( '(-10)-(-3)' , '(-10)' , '(-9)-(-3)' ) ;
210210 t2 ( '(-10)-(-3)' , '(-3)' , '(-10)-(-4)' ) ;
@@ -216,7 +216,7 @@ test('subtract', t => {
216216 ) ;
217217 } ) ;
218218
219- t . test ( 'unbounded' , ( ) => {
219+ await t . test ( 'unbounded' , ( ) => {
220220 t2 ( '10-20' , '15-' , '10-14' ) ;
221221 t2 ( '10-20' , '-15' , '16-20' ) ;
222222 t2 ( '10-20' , '-12,18-' , '13-17' ) ;
@@ -231,10 +231,10 @@ test('subtract', t => {
231231 } ) ;
232232} ) ;
233233
234- test ( 'intersect' , t => {
234+ test ( 'intersect' , async t => {
235235 const t2 = makeT2 ( mr . intersect , mr . stringify , true ) ;
236236
237- t . test ( 'positive' , ( ) => {
237+ await t . test ( 'positive' , ( ) => {
238238 t2 ( '1-5' , '8' , '' ) ;
239239 t2 ( '5-100' , '1,10,50,70,80,90,100,101' , '10,50,70,80,90,100' ) ;
240240 t2 ( '5-100' , '1-10,90-110' , '5-10,90-100' ) ;
@@ -247,7 +247,7 @@ test('intersect', t => {
247247 t2 ( '' , '' , '' ) ;
248248 } ) ;
249249
250- t . test ( 'negative' , ( ) => {
250+ await t . test ( 'negative' , ( ) => {
251251 t2 ( '0' , '0' , '0' ) ;
252252 t2 ( '(-50)-50' , '(-30)-30' , '(-30)-30' ) ;
253253 t2 ( '(-50)-50' , '5-30' , '5-30' ) ;
@@ -260,7 +260,7 @@ test('intersect', t => {
260260 ) ;
261261 } ) ;
262262
263- t . test ( 'unbounded' , ( ) => {
263+ await t . test ( 'unbounded' , ( ) => {
264264 t2 ( '1-' , '4-' , '4-' ) ;
265265 t2 ( '100-' , '-300' , '100-300' ) ;
266266 t2 ( '-5' , '-0' , '-0' ) ;
@@ -301,10 +301,10 @@ test('monkey test', () => {
301301 assert . strictEqual ( mr . intersect ( mirs [ 1 ] , mirs [ 2 ] ) . length , 0 ) ;
302302} ) ;
303303
304- test ( 'has' , t => {
304+ test ( 'has' , async t => {
305305 const t2 = makeT2 ( mr . has ) ;
306306
307- t . test ( 'bounded' , ( ) => {
307+ await t . test ( 'bounded' , ( ) => {
308308 t2 ( '5-20,25-100,150-300' , '7' , true ) ;
309309 t2 ( '5-20,25-100,150-300' , '25' , true ) ;
310310 t2 ( '5-20,25-100,150-300' , '300' , true ) ;
@@ -326,7 +326,7 @@ test('has', t => {
326326 t2 ( '(-300)-(-200),(-50)-(-30),20-25' , '(-40),(-100)' , false ) ;
327327 } ) ;
328328
329- t . test ( 'unbounded' , ( ) => {
329+ await t . test ( 'unbounded' , ( ) => {
330330 t2 ( '-' , '5' , true ) ;
331331 t2 ( '-20,40-' , '70' , true ) ;
332332 t2 ( '-20,40' , '10' , true ) ;
0 commit comments