@@ -685,7 +685,20 @@ test "AST as expected for ThisLiteral node", ->
685
685
testExpression ' @' ,
686
686
type : ' ThisExpression'
687
687
shorthand : yes
688
- # TODO: `@prop` property access isn't covered yet in these tests.
688
+
689
+ testExpression ' @b' ,
690
+ type : ' MemberExpression'
691
+ object :
692
+ type : ' ThisExpression'
693
+ shorthand : yes
694
+ property : ID ' b'
695
+
696
+ testExpression ' this.b' ,
697
+ type : ' MemberExpression'
698
+ object :
699
+ type : ' ThisExpression'
700
+ shorthand : no
701
+ property : ID ' b'
689
702
690
703
test " AST as expected for UndefinedLiteral node" , ->
691
704
testExpression ' undefined' ,
@@ -769,25 +782,6 @@ test "AST as expected for AwaitReturn node", ->
769
782
argument : NUMBER 2
770
783
]
771
784
772
- # test "AST as expected for Value node", ->
773
- # testExpression 'for i in [] then i',
774
- # body:
775
- # type: 'Value'
776
- # isDefaultValue: no
777
- # base:
778
- # value: 'i'
779
- # properties: []
780
-
781
- # testExpression 'if 1 then 1 else 2',
782
- # body:
783
- # type: 'Value'
784
- # isDefaultValue: no
785
- # elseBody:
786
- # type: 'Value'
787
- # isDefaultValue: no
788
-
789
- # # TODO: Figgure out the purpose of `isDefaultValue`. It's not set in `Switch` either.
790
-
791
785
test " AST as expected for Call node" , ->
792
786
testExpression ' fn()' ,
793
787
type : ' CallExpression'
@@ -1329,28 +1323,6 @@ test "AST as expected for Range node", ->
1329
1323
to :
1330
1324
value : 2
1331
1325
1332
- # testExpression 'for x in [42...43] then',
1333
- # range: yes
1334
- # source:
1335
- # type: 'Range'
1336
- # exclusive: yes
1337
- # equals: ''
1338
- # from:
1339
- # value: '42'
1340
- # to:
1341
- # value: '43'
1342
-
1343
- # testExpression 'for x in [y..z] then',
1344
- # range: yes
1345
- # source:
1346
- # type: 'Range'
1347
- # exclusive: no
1348
- # equals: '='
1349
- # from:
1350
- # value: 'y'
1351
- # to:
1352
- # value: 'z'
1353
-
1354
1326
test " AST as expected for Slice node" , ->
1355
1327
testExpression ' x[..y]' ,
1356
1328
property :
@@ -1375,18 +1347,18 @@ test "AST as expected for Slice node", ->
1375
1347
from : null
1376
1348
to : null
1377
1349
1378
- # testExpression '"abc"[...2]',
1379
- # type: 'MemberExpression'
1380
- # property:
1381
- # type: 'Range'
1382
- # from: null
1383
- # to:
1384
- # type: 'NumericLiteral'
1385
- # value: 2
1386
- # exclusive: yes
1387
- # computed: yes
1388
- # optional: no
1389
- # shorthand: no
1350
+ testExpression ' "abc"[...2]' ,
1351
+ type : ' MemberExpression'
1352
+ property :
1353
+ type : ' Range'
1354
+ from : null
1355
+ to :
1356
+ type : ' NumericLiteral'
1357
+ value : 2
1358
+ exclusive : yes
1359
+ computed : yes
1360
+ optional : no
1361
+ shorthand : no
1390
1362
1391
1363
testExpression ' x[...][a..][b...][..c][...d]' ,
1392
1364
type : ' MemberExpression'
@@ -1562,10 +1534,6 @@ test "AST as expected for Obj node", ->
1562
1534
]
1563
1535
implicit : yes
1564
1536
1565
- # # TODO: Test destructuring.
1566
-
1567
- # # console.log JSON.stringify expression, ["type", "generated", "lhs", "value", "properties", "variable"], 2
1568
-
1569
1537
test " AST as expected for Arr node" , ->
1570
1538
testExpression ' []' ,
1571
1539
type : ' ArrayExpression'
@@ -1579,8 +1547,6 @@ test "AST as expected for Arr node", ->
1579
1547
{operator : ' !' }
1580
1548
]
1581
1549
1582
- # # TODO: Test destructuring.
1583
-
1584
1550
test " AST as expected for Class node" , ->
1585
1551
testStatement ' class Klass' ,
1586
1552
type : ' ClassDeclaration'
@@ -1998,7 +1964,18 @@ test "AST as expected for ExportNamedDeclaration node", ->
1998
1964
source : null
1999
1965
exportKind : ' value'
2000
1966
2001
- # testStatement 'export class A',
1967
+ testStatement ' export class A' ,
1968
+ type : ' ExportNamedDeclaration'
1969
+ declaration :
1970
+ type : ' ClassDeclaration'
1971
+ id : ID ' A' , declaration : yes
1972
+ superClass : null
1973
+ body :
1974
+ type : ' ClassBody'
1975
+ body : []
1976
+ specifiers : []
1977
+ source : null
1978
+ exportKind : ' value'
2002
1979
2003
1980
testStatement ' export {x as y, z as default}' ,
2004
1981
type : ' ExportNamedDeclaration'
@@ -2298,8 +2275,6 @@ test "AST as expected for Assign node", ->
2298
2275
operator : ' ?='
2299
2276
]
2300
2277
2301
- # # `FuncGlyph` node isn't exported.
2302
-
2303
2278
test " AST as expected for Code node" , ->
2304
2279
testExpression ' =>' ,
2305
2280
type : ' ArrowFunctionExpression'
@@ -2696,14 +2671,15 @@ test "AST as expected for Splat node", ->
2696
2671
postfix : no
2697
2672
]
2698
2673
2699
- # # TODO: Test object splats.
2700
-
2701
2674
test " AST as expected for Expansion node" , ->
2702
- # testExpression '(...) ->',
2703
- # type: 'Code'
2704
- # params: [
2705
- # {type: 'Expansion'}
2706
- # ]
2675
+ testExpression ' (..., b) ->' ,
2676
+ type : ' FunctionExpression'
2677
+ params : [
2678
+ type : ' RestElement'
2679
+ argument : null
2680
+ ,
2681
+ ID ' b'
2682
+ ]
2707
2683
2708
2684
testExpression ' [..., b] = c' ,
2709
2685
type : ' AssignmentExpression'
@@ -3180,21 +3156,20 @@ test "AST as expected for Existence node", ->
3180
3156
operator : ' ?'
3181
3157
prefix : no
3182
3158
3183
- # # NOTE: Soaking is covered in `Call` and `Access` nodes.
3184
-
3185
3159
test " AST as expected for Parens node" , ->
3186
3160
testExpression ' (hmmmmm)' ,
3187
3161
type : ' Identifier'
3188
3162
name : ' hmmmmm'
3189
3163
3190
- # testExpression '(a + b) / c',
3191
- # type: 'Op'
3192
- # operator: '/'
3193
- # first:
3194
- # type: 'Parens'
3195
- # body:
3196
- # type: 'Op'
3197
- # operator: '+'
3164
+ testExpression ' (a + b) / c' ,
3165
+ type : ' BinaryExpression'
3166
+ operator : ' /'
3167
+ left :
3168
+ type : ' BinaryExpression'
3169
+ operator : ' +'
3170
+ left : ID ' a'
3171
+ right : ID ' b'
3172
+ right : ID ' c'
3198
3173
3199
3174
testExpression ' (((1)))' ,
3200
3175
type : ' NumericLiteral'
@@ -3600,8 +3575,6 @@ test "AST as expected for For node", ->
3600
3575
name :
3601
3576
type : ' ArrayPattern'
3602
3577
3603
- # # TODO: Figure out the purpose of `pattern` and `returns`.
3604
-
3605
3578
test " AST as expected for Switch node" , ->
3606
3579
testStatement '''
3607
3580
switch x
@@ -3736,8 +3709,6 @@ test "AST as expected for Switch node", ->
3736
3709
]
3737
3710
]
3738
3711
3739
- # # TODO: File issue for compile error when using `then` or `;` where `\n` is rn.
3740
-
3741
3712
test " AST as expected for If node" , ->
3742
3713
testStatement ' if maybe then yes' ,
3743
3714
type : ' IfStatement'
0 commit comments