@@ -413,6 +413,28 @@ describe('Lexer: First milestone', function() {
413
413
] ;
414
414
expect ( lexer ( input ) ) . to . deep . equal ( output ) ;
415
415
} ) ;
416
+
417
+ it ( 'should handle the reassignment of tuple items via dot notation' , function ( ) {
418
+ input = String . raw `var randNumString = (4, "hello"); randNumString.0 = 5` ;
419
+ output = [
420
+ { type : "DECLARATION_KEYWORD" , value : "var" } ,
421
+ { type : "IDENTIFIER" , value : "randNumString" } ,
422
+ { type : "OPERATOR" , value : "=" } ,
423
+ { type : "TUPLE_START" , value : "(" } ,
424
+ { type : "NUMBER" , value : "4" } ,
425
+ { type : "PUNCTUATION" , value : "," } ,
426
+ { type : "STRING" , value : "hello" } ,
427
+ { type : "TUPLE_END" , value : ")" } ,
428
+ { type : "PUNCTUATION" , value : ";" } ,
429
+ { type : "IDENTIFIER" , value : "randNumString" } ,
430
+ { type : "DOT_SYNTAX" , value : "." } ,
431
+ { type : "NUMBER" , value : "0" } ,
432
+ { type : "OPERATOR" , value : "=" } ,
433
+ { type : "NUMBER" , value : "5" } ,
434
+ { type : "TERMINATOR" , value : "EOF" }
435
+ ] ;
436
+ expect ( lexer ( input ) ) . to . deep . equal ( output ) ;
437
+ } ) ;
416
438
417
439
it ( 'should handle tuples with element names' , function ( ) {
418
440
input = String . raw `let http200Status = (statusCode: 200, description: "OK");` ;
@@ -435,6 +457,32 @@ describe('Lexer: First milestone', function() {
435
457
expect ( lexer ( input ) ) . to . deep . equal ( output ) ;
436
458
} ) ;
437
459
460
+ it ( 'should handle the reassignment of tuple items identified by element name via dot notation' , function ( ) {
461
+ input = String . raw `var randNumString = (num: 4, str: "hello"); randNumString.num = 5` ;
462
+ output = [
463
+ { type : "DECLARATION_KEYWORD" , value : "var" } ,
464
+ { type : "IDENTIFIER" , value : "randNumString" } ,
465
+ { type : "OPERATOR" , value : "=" } ,
466
+ { type : "TUPLE_START" , value : "(" } ,
467
+ { type : "TUPLE_ELEMENT_NAME" , value : "num" } ,
468
+ { type : "PUNCTUATION" , value : ":" } ,
469
+ { type : "NUMBER" , value : "4" } ,
470
+ { type : "PUNCTUATION" , value : "," } ,
471
+ { type : "TUPLE_ELEMENT_NAME" , value : "str" } ,
472
+ { type : "PUNCTUATION" , value : ":" } ,
473
+ { type : "STRING" , value : "hello" } ,
474
+ { type : "TUPLE_END" , value : ")" } ,
475
+ { type : "PUNCTUATION" , value : ";" } ,
476
+ { type : "IDENTIFIER" , value : "randNumString" } ,
477
+ { type : "DOT_SYNTAX" , value : "." } ,
478
+ { type : "TUPLE_ELEMENT_NAME" , value : "num" } ,
479
+ { type : "OPERATOR" , value : "=" } ,
480
+ { type : "NUMBER" , value : "5" } ,
481
+ { type : "TERMINATOR" , value : "EOF" }
482
+ ] ;
483
+ expect ( lexer ( input ) ) . to . deep . equal ( output ) ;
484
+ } ) ;
485
+
438
486
it ( 'should handle empty tuples' , function ( ) {
439
487
input = String . raw `var empty = ()` ;
440
488
output = [
0 commit comments