@@ -104,13 +104,13 @@ const c = keyword('c')
104104const colon = token ( ':' )
105105const comma = token ( ',' )
106106const number = type ( '<number>' )
107+ const plus = token ( '+' )
107108
108109describe ( 'symbols' , ( ) => {
109110 it ( "parses and serializes '+' (delimiter)" , ( ) => {
110111 const input = "'+'"
111- const parsed = token ( '+' )
112- expect ( parse ( "'+'" ) ) . toEqual ( parsed )
113- expect ( serialize ( parsed ) ) . toBe ( input )
112+ expect ( parse ( "'+'" ) ) . toEqual ( plus )
113+ expect ( serialize ( plus ) ) . toBe ( input )
114114 } )
115115 it ( 'parses and serializes a (keyword)' , ( ) => {
116116 const input = 'a'
@@ -366,10 +366,17 @@ describe('multipliers', () => {
366366 expect ( parse ( input ) ) . toEqual ( parsed )
367367 expect ( serialize ( parsed ) ) . toBe ( input )
368368 } )
369- it ( "parses and serializes ','?'" , ( ) => {
369+ it ( "parses and serializes ,?" , ( ) => {
370+ const input = ',?'
370371 const parsed = optional ( comma )
372+ expect ( parse ( input ) ) . toEqual ( parsed )
371373 expect ( parse ( "','?" ) ) . toEqual ( parsed )
372- expect ( serialize ( parsed ) ) . toBe ( ',?' )
374+ expect ( serialize ( parsed ) ) . toBe ( input )
375+ } )
376+ it ( "parses and serializes '+'?'" , ( ) => {
377+ const parsed = optional ( plus )
378+ expect ( parse ( "'+'?" ) ) . toEqual ( parsed )
379+ expect ( serialize ( parsed ) ) . toBe ( "'+'?" )
373380 } )
374381 it ( 'parses and serializes <number>?' , ( ) => {
375382 const input = '<number>?'
@@ -538,7 +545,7 @@ describe('context rules', () => {
538545 expect ( parse ( "[['+' | '-'] <calc-product>]*" , production ) ) . toEqual (
539546 repeat (
540547 sequence (
541- alternation ( token ( '+' ) , token ( '-' ) ) ,
548+ alternation ( plus , token ( '-' ) ) ,
542549 type ( '<calc-product>' ) ) ,
543550 0 ,
544551 31 ) )
0 commit comments