@@ -584,4 +584,80 @@ public void StringLiteral_GetsTokenTypeString()
584584 }
585585
586586 #endregion
587+
588+ #region ModifiedArgument tokens
589+
590+ [ Fact ]
591+ public void ModifiedArgument_EmitsKeywordToken ( )
592+ {
593+ // Line 1: "def increment(x: ref int):"
594+ // Line 2: " x = x + 1"
595+ // Line 3: "def main():"
596+ // Line 4: " a: int = 5"
597+ // Line 5: " increment(ref a)"
598+ // The call-site "ref" in "increment(ref a)" should emit a TKeyword token.
599+ // Line 5: " increment(ref a)"
600+ // 123456789012345678
601+ // "ref" starts at column 15 (1-based) -> LSP (4, 14)
602+ var tokens = CollectTokensFrom (
603+ "def increment(x: ref int):\n x = x + 1\n def main():\n a: int = 5\n increment(ref a)" ) ;
604+ var keywords = tokens . Where ( t => t . TokenType == TKeyword && t . Line == 4 ) . ToList ( ) ;
605+ keywords . Should ( ) . Contain ( t => t . Length == 3 ,
606+ "'ref' at the call site should produce a keyword token with length 3" ) ;
607+ }
608+
609+ [ Fact ]
610+ public void ModifiedArgument_OutModifier_EmitsKeywordToken ( )
611+ {
612+ // Line 1: "def try_parse(s: str, result: out int) -> bool:"
613+ // Line 2: " result = int(s)"
614+ // Line 3: " return True"
615+ // Line 4: "def main():"
616+ // Line 5: " value: int = 0"
617+ // Line 6: " try_parse(\"42\", out value)"
618+ // The call-site "out" should emit a TKeyword token with length 3.
619+ var tokens = CollectTokensFrom (
620+ "def try_parse(s: str, result: out int) -> bool:\n " +
621+ " result = int(s)\n " +
622+ " return True\n " +
623+ "def main():\n " +
624+ " value: int = 0\n " +
625+ " try_parse(\" 42\" , out value)" ) ;
626+ var keywordsOnCallLine = tokens . Where ( t => t . TokenType == TKeyword && t . Line == 5 ) . ToList ( ) ;
627+ keywordsOnCallLine . Should ( ) . Contain ( t => t . Length == 3 ,
628+ "'out' at the call site should produce a keyword token with length 3" ) ;
629+ }
630+
631+ #endregion
632+
633+ #region LambdaExpression tokens
634+
635+ [ Fact ]
636+ public void LambdaExpression_EmitsParameterAndTypeTokens ( )
637+ {
638+ // "def main():" on line 1
639+ // " f = (x: int, y: str) -> x" on line 2
640+ // Lambda parameters x, y should produce TParameter tokens.
641+ // Type annotations int, str should produce TType tokens.
642+ // Line 2: " f = (x: int, y: str) -> x"
643+ // 123456789012345678901234567890
644+ // 'x' at col 10 (1-based) -> LSP (1, 9)
645+ // 'int' at col 13 (1-based) -> LSP (1, 12)
646+ // 'y' at col 18 (1-based) -> LSP (1, 17)
647+ // 'str' at col 21 (1-based) -> LSP (1, 20)
648+ var tokens = CollectTokensFrom ( "def main():\n f = (x: int, y: str) -> x" ) ;
649+ var paramTokens = tokens . Where ( t => t . TokenType == TParameter && t . Line == 1 ) . ToList ( ) ;
650+ paramTokens . Should ( ) . Contain ( t => t . Length == 1 && t . Col == 9 ,
651+ "'x' lambda parameter should produce a parameter token" ) ;
652+ paramTokens . Should ( ) . Contain ( t => t . Length == 1 && t . Col == 17 ,
653+ "'y' lambda parameter should produce a parameter token" ) ;
654+
655+ var typeTokens = tokens . Where ( t => t . TokenType == TType && t . Line == 1 ) . ToList ( ) ;
656+ typeTokens . Should ( ) . Contain ( t => t . Length == 3 && t . Col == 12 ,
657+ "'int' type annotation should produce a type token" ) ;
658+ typeTokens . Should ( ) . Contain ( t => t . Length == 3 && t . Col == 20 ,
659+ "'str' type annotation should produce a type token" ) ;
660+ }
661+
662+ #endregion
587663}
0 commit comments