@@ -12,15 +12,15 @@ const p = (code) => parser.parse(code, -1);
1212
1313describe ( 'mondo tokenizer' , ( ) => {
1414 const parser = new MondoParser ( ) ;
15- it ( 'should tokenize with locations ' , ( ) =>
15+ it ( 'should tokenize with loangleions ' , ( ) =>
1616 expect (
1717 parser
1818 . tokenize ( '(one two three)' )
1919 . map ( ( t ) => t . value + '=' + t . loc . join ( '-' ) )
2020 . join ( ' ' ) ,
2121 ) . toEqual ( '(=0-1 one=1-4 two=5-8 three=9-14 )=14-15' ) ) ;
22- // it('should parse with locations ', () => expect(parser.parse('(one two three)')).toEqual());
23- it ( 'should get locations ' , ( ) =>
22+ // it('should parse with loangleions ', () => expect(parser.parse('(one two three)')).toEqual());
23+ it ( 'should get loangleions ' , ( ) =>
2424 expect ( parser . get_locations ( 's bd rim' ) ) . toEqual ( [
2525 [ 2 , 4 ] ,
2626 [ 5 , 8 ] ,
@@ -73,39 +73,41 @@ let desguar = (a) => {
7373} ;
7474
7575describe ( 'mondo sugar' , ( ) => {
76- it ( 'should desugar []' , ( ) => expect ( desguar ( '[a b c]' ) ) . toEqual ( '(seq a b c)' ) ) ;
77- it ( 'should desugar [] nested' , ( ) => expect ( desguar ( '[a [b c] d]' ) ) . toEqual ( '(seq a (seq b c) d)' ) ) ;
78- it ( 'should desugar <>' , ( ) => expect ( desguar ( '<a b c>' ) ) . toEqual ( '(cat a b c)' ) ) ;
79- it ( 'should desugar <> nested' , ( ) => expect ( desguar ( '<a <b c> d>' ) ) . toEqual ( '(cat a (cat b c) d)' ) ) ;
80- it ( 'should desugar mixed [] <>' , ( ) => expect ( desguar ( '[a <b c>]' ) ) . toEqual ( '(seq a (cat b c))' ) ) ;
81- it ( 'should desugar mixed <> []' , ( ) => expect ( desguar ( '<a [b c]>' ) ) . toEqual ( '(cat a (seq b c))' ) ) ;
76+ it ( 'should desugar []' , ( ) => expect ( desguar ( '[a b c]' ) ) . toEqual ( '(square a b c)' ) ) ;
77+ it ( 'should desugar [] nested' , ( ) => expect ( desguar ( '[a [b c] d]' ) ) . toEqual ( '(square a (square b c) d)' ) ) ;
78+ it ( 'should desugar <>' , ( ) => expect ( desguar ( '<a b c>' ) ) . toEqual ( '(angle a b c)' ) ) ;
79+ it ( 'should desugar <> nested' , ( ) => expect ( desguar ( '<a <b c> d>' ) ) . toEqual ( '(angle a (angle b c) d)' ) ) ;
80+ it ( 'should desugar mixed [] <>' , ( ) => expect ( desguar ( '[a <b c>]' ) ) . toEqual ( '(square a (angle b c))' ) ) ;
81+ it ( 'should desugar mixed <> []' , ( ) => expect ( desguar ( '<a [b c]>' ) ) . toEqual ( '(angle a (square b c))' ) ) ;
8282
8383 it ( 'should desugar .' , ( ) => expect ( desguar ( 's jazz . fast 2' ) ) . toEqual ( '(fast (s jazz) 2)' ) ) ;
84- it ( 'should desugar . seq ' , ( ) => expect ( desguar ( '[bd cp . fast 2]' ) ) . toEqual ( '(fast (seq bd cp) 2)' ) ) ;
84+ it ( 'should desugar . square ' , ( ) => expect ( desguar ( '[bd cp . fast 2]' ) ) . toEqual ( '(fast (square bd cp) 2)' ) ) ;
8585 it ( 'should desugar . twice' , ( ) => expect ( desguar ( 's jazz . fast 2 . slow 2' ) ) . toEqual ( '(slow (fast (s jazz) 2) 2)' ) ) ;
8686 it ( 'should desugar . nested' , ( ) => expect ( desguar ( '(s cp . fast 2)' ) ) . toEqual ( '(fast (s cp) 2)' ) ) ;
87- it ( 'should desugar . within []' , ( ) => expect ( desguar ( '[bd cp . fast 2]' ) ) . toEqual ( '(fast (seq bd cp) 2)' ) ) ;
87+ it ( 'should desugar . within []' , ( ) => expect ( desguar ( '[bd cp . fast 2]' ) ) . toEqual ( '(fast (square bd cp) 2)' ) ) ;
8888 it ( 'should desugar . within , within []' , ( ) =>
89- expect ( desguar ( '[bd cp . fast 2, x]' ) ) . toEqual ( '(stack (fast (seq bd cp) 2) x)' ) ) ;
89+ expect ( desguar ( '[bd cp . fast 2, x]' ) ) . toEqual ( '(stack (fast (square bd cp) 2) x)' ) ) ;
9090
91- it ( 'should desugar . ()' , ( ) => expect ( desguar ( '[jazz hh.(fast 2)]' ) ) . toEqual ( '(seq jazz (fast hh 2))' ) ) ;
91+ it ( 'should desugar . ()' , ( ) => expect ( desguar ( '[jazz hh.(fast 2)]' ) ) . toEqual ( '(square jazz (fast hh 2))' ) ) ;
9292
93- it ( 'should desugar , seq' , ( ) => expect ( desguar ( '[bd, hh]' ) ) . toEqual ( '(stack bd hh)' ) ) ;
94- it ( 'should desugar , seq 2' , ( ) => expect ( desguar ( '[bd, hh oh]' ) ) . toEqual ( '(stack bd (seq hh oh))' ) ) ;
95- it ( 'should desugar , seq 3' , ( ) => expect ( desguar ( '[bd cp, hh oh]' ) ) . toEqual ( '(stack (seq bd cp) (seq hh oh))' ) ) ;
96- it ( 'should desugar , cat' , ( ) => expect ( desguar ( '<bd, hh>' ) ) . toEqual ( '(stack bd hh)' ) ) ;
97- it ( 'should desugar , cat 2' , ( ) => expect ( desguar ( '<bd, hh oh>' ) ) . toEqual ( '(stack bd (cat hh oh))' ) ) ;
98- it ( 'should desugar , cat 3' , ( ) => expect ( desguar ( '<bd cp, hh oh>' ) ) . toEqual ( '(stack (cat bd cp) (cat hh oh))' ) ) ;
93+ it ( 'should desugar , square' , ( ) => expect ( desguar ( '[bd, hh]' ) ) . toEqual ( '(stack bd hh)' ) ) ;
94+ it ( 'should desugar , square 2' , ( ) => expect ( desguar ( '[bd, hh oh]' ) ) . toEqual ( '(stack bd (square hh oh))' ) ) ;
95+ it ( 'should desugar , square 3' , ( ) =>
96+ expect ( desguar ( '[bd cp, hh oh]' ) ) . toEqual ( '(stack (square bd cp) (square hh oh))' ) ) ;
97+ it ( 'should desugar , angle' , ( ) => expect ( desguar ( '<bd, hh>' ) ) . toEqual ( '(stack bd hh)' ) ) ;
98+ it ( 'should desugar , angle 2' , ( ) => expect ( desguar ( '<bd, hh oh>' ) ) . toEqual ( '(stack bd (angle hh oh))' ) ) ;
99+ it ( 'should desugar , angle 3' , ( ) =>
100+ expect ( desguar ( '<bd cp, hh oh>' ) ) . toEqual ( '(stack (angle bd cp) (angle hh oh))' ) ) ;
99101 it ( 'should desugar , ()' , ( ) => expect ( desguar ( '(s bd, s cp)' ) ) . toEqual ( '(stack (s bd) (s cp))' ) ) ;
100- it ( 'should desugar * /' , ( ) => expect ( desguar ( '[a b*2 c d/3 e]' ) ) . toEqual ( '(seq a (* b 2) c (/ d 3) e)' ) ) ;
101- it ( 'should desugar []*x' , ( ) => expect ( desguar ( '[a [b c]*3]' ) ) . toEqual ( '(seq a (* (seq b c) 3))' ) ) ;
102+ it ( 'should desugar * /' , ( ) => expect ( desguar ( '[a b*2 c d/3 e]' ) ) . toEqual ( '(square a (* b 2) c (/ d 3) e)' ) ) ;
103+ it ( 'should desugar []*x' , ( ) => expect ( desguar ( '[a [b c]*3]' ) ) . toEqual ( '(square a (* (square b c) 3))' ) ) ;
102104 it ( 'should desugar x:y' , ( ) => expect ( desguar ( 'x:y' ) ) . toEqual ( '(: x y)' ) ) ;
103105 it ( 'should desugar x:y:z' , ( ) => expect ( desguar ( 'x:y:z' ) ) . toEqual ( '(: (: x y) z)' ) ) ;
104106 it ( 'should desugar x:y*x' , ( ) => expect ( desguar ( 'bd:0*2' ) ) . toEqual ( '(* (: bd 0) 2)' ) ) ;
105107 it ( 'should desugar a..b' , ( ) => expect ( desguar ( '0..2' ) ) . toEqual ( '(.. 0 2)' ) ) ;
106108
107109 it ( 'should desugar README example' , ( ) =>
108110 expect ( desguar ( 's [bd hh*2 cp.(crush 4) <mt ht lt>] . speed .8' ) ) . toEqual (
109- '(speed (s (seq bd (* hh 2) (crush cp 4) (cat mt ht lt))) .8)' ,
111+ '(speed (s (square bd (* hh 2) (crush cp 4) (angle mt ht lt))) .8)' ,
110112 ) ) ;
111113} ) ;
0 commit comments