package Ġru . au . kotlin fu z zer Ċ Ċ import Ġorg . junit . Ignore Ċ import Ġorg . junit . Test Ċ import Ġorg . junit . runner . RunWith Ċ import Ġorg . junit . runners . Suite Ċ import Ġru . au . kotlin fu z zer . ast .* Ċ import Ġru . au . kotlin fu z zer . ast . builders . build AST FromFile Ċ import Ġru . au . kotlin fu z zer . ast . builders . unit Type Ċ import Ġru . au . kotlin fu z zer . ast . entities .* Ċ import Ġru . au . kotlin fu z zer . mutation . get Typed Node Ċ import Ġru . au . kotlin fu z zer . util . get Compiler TestData Full name Ċ import Ġru . au . kotlin fu z zer . util . get My TestData Full name Ċ import Ġkotlin . test .* ĊĊ Ċ @ RunWith ( Suite :: class ) Ċ @ Suite . Suite Classes ( ĊĠĠĠ ĠBuilder S moke Tests :: class , ĊĠĠĠ ĠBuilder Features Test :: class Ċ ) Ċ class ĠAST Builder TestSuite Ġ{ Ċ Ċ } Ċ Ċ class ĠBuilder S moke Tests Ġ{ ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun ĠAST is AST Node () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġast Ġ= Ġbuild AST FromFile ( get Compiler TestData Full name (" codegen / box / super / enc losed Fun . kt ")) ĊĠĠĠĠĠĠĠ ĠassertTrue ( ast Ġis ĠAST Node ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġno Exceptions On Unknown File () Ġ{ ĊĠĠĠĠĠĠĠ Ġ// ĠAssume Ġthat Ġnot Ġall Ġfeatures Ġfrom Ġthe Ġfile Ġare Ġsupported ĊĠĠĠĠĠĠĠ Ġval Ġast Ġ= Ġbuild AST FromFile ( get Compiler TestData Full name (" codegen / box / super / trait property . kt ")) ĊĠĠĠĠĠĠĠ ĠassertTrue ( ast Ġis ĠAST Node ) ĊĠĠĠ Ġ} Ċ } ĊĊ Ċ class ĠBuilder Features Test Ġ{ ĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġparse P reamble () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġast Ġ= Ġbuild AST FromFile ( get My TestData Full name (" pre amble . kt ")) ĊĊĠĠĠĠĠĠĠ Ġval Ġchildren List Ġ= Ġast . members Typed . children ĊĊĠĠĠĠĠĠĠ ĠassertEquals ( 5 , Ġchildren List . size ) ĊĊĠĠĠĠĠĠĠ ĠassertTrue ( children List [ 0 ] Ġis ĠPackage Node ) ĊĠĠĠĠĠĠĠ ĠassertEquals (" a . b . c ", Ġ( children List [ 0 ] Ġas ĠPackage Node ). name ) ĊĊĠĠĠĠĠĠĠ ĠassertTrue ( children List [ 1 ] Ġis ĠImport Node ) ĊĠĠĠĠĠĠĠ ĠassertEquals (" x . y . z . j ", Ġ( children List [ 1 ] Ġas ĠImport Node ). name ) ĊĠĠĠĠĠĠĠ ĠassertNull (( children List [ 1 ] Ġas ĠImport Node ). alias ) ĊĊĠĠĠĠĠĠĠ ĠassertTrue ( children List [ 2 ] Ġis ĠImport Node ) ĊĠĠĠĠĠĠĠ ĠassertEquals (" a ", Ġ( children List [ 2 ] Ġas ĠImport Node ). name ) ĊĠĠĠĠĠĠĠ ĠassertNull (( children List [ 2 ] Ġas ĠImport Node ). alias ) ĊĊĠĠĠĠĠĠĠ ĠassertTrue ( children List [ 3 ] Ġis ĠImport Node ) ĊĠĠĠĠĠĠĠ ĠassertEquals (" all ", Ġ( children List [ 3 ] Ġas ĠImport Node ). name ) ĊĠĠĠĠĠĠĠ ĠassertNull (( children List [ 3 ] Ġas ĠImport Node ). alias ) ĊĊĠĠĠĠĠĠĠ ĠassertTrue ( children List [ 4 ] Ġis ĠImport Node ) ĊĠĠĠĠĠĠĠ ĠassertEquals (" abc . io ", Ġ( children List [ 4 ] Ġas ĠImport Node ). name ) ĊĠĠĠĠĠĠĠ ĠassertEquals (" cool ", Ġ( children List [ 4 ] Ġas ĠImport Node ). alias ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġparse Function Headers Without Types () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġast Ġ= Ġbuild AST FromFile ( get My TestData Full name (" functions _ simple . kt ")) ĊĊĠĠĠĠĠĠĠ Ġval Ġchildren List Ġ= Ġast . members Typed . children ĊĊĠĠĠĠĠĠĠ ĠassertEquals ( 4 , Ġchildren List . size ) ĊĊĠĠĠĠĠĠĠ Ġval Ġfunc Typed Ġ= Ġchildren List [ 0 ] Ġas ĠFunction Declaration Node ĊĠĠĠĠĠĠĠ ĠassertEquals (" func _ typed ", Ġfunc Typed . name ) ĊĠĠĠĠĠĠĠ ĠassertNull ( func Typed . receiver Type ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( 0 , Ġfunc Typed . arguments . size ) ĊĊĠĠĠĠĠĠĠ Ġval Ġfunc Block Ġ= Ġchildren List [ 1 ] Ġas ĠFunction Declaration Node ĊĠĠĠĠĠĠĠ ĠassertEquals (" func _ block ", Ġfunc Block . name ) ĊĠĠĠĠĠĠĠ ĠassertNull ( func Block . receiver Type ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( 0 , Ġfunc Block . arguments . size ) ĊĊĠĠĠĠĠĠĠ Ġval Ġfunc Args Ġ= Ġchildren List [ 2 ] Ġas ĠFunction Declaration Node ĊĠĠĠĠĠĠĠ ĠassertEquals (" func _ args ", Ġfunc Args . name ) ĊĠĠĠĠĠĠĠ ĠassertNull ( func Args . receiver Type ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( 2 , Ġfunc Args . arguments . size ) ĊĠĠĠĠĠĠĠ ĠassertEquals (" x ", Ġfunc Args . arguments Typed [ 0 ]. var Decl Typed . name ) ĊĠĠĠĠĠĠĠ ĠassertEquals (" y ", Ġfunc Args . arguments Typed [ 1 ]. var Decl Typed . name ) ĊĊĠĠĠĠĠĠĠ Ġval Ġfunc Receiver Ġ= Ġchildren List [ 3 ] Ġas ĠFunction Declaration Node ĊĠĠĠĠĠĠĠ ĠassertEquals (" func _ receiver ", Ġfunc Receiver . name ) ĊĠĠĠĠĠĠĠ ĠassertNotNull ( func Receiver . receiver Type ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( 0 , Ġfunc Receiver . arguments . size ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġparse Function Headers With Types () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġast Ġ= Ġbuild AST FromFile ( get My TestData Full name (" functions _ medium . kt ")) ĊĠĠĠĠĠĠĠ Ġval Ġstring Type Ġ= ĠSimple Type (" String ") ĊĠĠĠĠĠĠĠ Ġval Ġint Type Ġ= ĠSimple Type (" Int ") ĊĊĠĠĠĠĠĠĠ Ġval Ġchildren List Ġ= Ġast . members Typed . children ĊĊĠĠĠĠĠĠĠ Ġval Ġfunc Nullable Ġ= Ġchildren List [ 0 ] Ġas ĠFunction Declaration Node ĊĠĠĠĠĠĠĠ ĠassertEquals (" f 1 ", Ġfunc Nullable . name ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( 0 , Ġfunc Nullable . arguments . size ) ĊĠĠĠĠĠĠĠ ĠassertTrue ( func Nullable . returnType Ġis ĠNullable Type ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( Nullable Type ( string Type ), Ġfunc Nullable . returnType ) ĊĊĠĠĠĠĠĠĠ Ġval Ġfunc Receiver And Args Ġ= Ġchildren List [ 1 ] Ġas ĠFunction Declaration Node ĊĠĠĠĠĠĠĠ ĠassertEquals (" f 2 ", Ġfunc Receiver And Args . name ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( int Type , Ġfunc Receiver And Args . receiver Type ) ĊĠĠĠĠĠĠĠ ĠassertTrue ( func Receiver And Args . returnType Ġis ĠDynamic Type ) ĊĠĠĠĠĠĠĠ Ġval Ġargs Ġ= Ġfunc Receiver And Args . arguments ĊĠĠĠĠĠĠĠ ĠassertEquals ( Function Argument ( Variable Declaration (" x ", Ġunit Type ), Ġnull ), Ġargs [ 0 ]) ĊĠĠĠĠĠĠĠ ĠassertEquals ( Function Argument ( Variable Declaration (" y ", ĠSimple Type (" Nothing ")), Ġnull ), Ġargs [ 1 ]) ĊĊĠĠĠĠĠĠĠ Ġval Ġfunc Function Receiver Ġ= Ġchildren List [ 2 ] Ġas ĠFunction Declaration Node ĊĠĠĠĠĠĠĠ ĠassertEquals (" f 3 ", Ġfunc Function Receiver . name ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( unit Type , Ġfunc Function Receiver . returnType ) ĊĠĠĠĠĠĠĠ ĠassertTrue ( func Function Receiver . receiver Type Ġis ĠFunction Type ) ĊĠĠĠĠĠĠĠ Ġval Ġrec Type Ġ= Ġfunc Function Receiver . receiver Type Ġas ĠFunction Type ĊĠĠĠĠĠĠĠ ĠassertNull ( rec Type . receiver Type ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( 2 , Ġrec Type . params . size ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( string Type , Ġrec Type . returnType ) ĊĠĠĠĠĠĠĠ Ġval Ġrec Type Param 0 Ġ= Ġrec Type . params [ 0 ] Ġas ĠFunction Type Parameter ĊĠĠĠĠĠĠĠ ĠassertEquals ( Dot ted Type ( lhs = Dot ted Type ( lhs = Simple Type ( name =" a "), Ġrhs = Simple Type ( name =" b ")), Ġrhs = Simple Type ( name =" Double ")), Ġrec Type Param 0 . type ) ĊĠĠĠĠĠĠĠ Ġval Ġsecond Param Type Ġ= Ġ( rec Type . params [ 1 ] Ġas ĠFunction Type Parameter ). type Ġas ĠFunction Type ĊĠĠĠĠĠĠĠ ĠassertEquals ( unit Type , Ġsecond Param Type . returnType ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( 1 , Ġsecond Param Type . params . size ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( string Type , Ġ( second Param Type . params [ 0 ] Ġas ĠFunction Type Parameter ). type ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( int Type , Ġsecond Param Type . receiver Type ) ĊĠĠĠĠĠĠĠ Ġval Ġfunc Ret Func Ġ= Ġchildren List [ 3 ] Ġas ĠFunction Declaration Node ĊĠĠĠĠĠĠĠ ĠassertEquals (" f 4 ", Ġfunc Ret Func . name ) ĊĠĠĠĠĠĠĠ ĠassertTrue ( func Ret Func . arguments Typed [ 0 ]. var Decl Typed . type Ġis ĠDynamic Type ) ĊĠĠĠĠĠĠĠ ĠassertEquals (" x ", Ġfunc Ret Func . arguments Typed [ 0 ]. var Decl Typed . name ) ĊĠĠĠĠĠĠĠ ĠassertTrue ( func Ret Func . returnType Ġis ĠFunction Type ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( int Type , Ġ( func Ret Func . returnType Ġas ĠFunction Type ). params Typed [ 0 ]. type ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( Simple Type (" Long "), Ġ( func Ret Func . returnType Ġas ĠFunction Type ). returnType ) ĊĊĠĠĠĠĠĠĠ Ġval Ġfunc Named Fun ctype Ġ= Ġchildren List [ 4 ] Ġas ĠFunction Declaration Node ĊĠĠĠĠĠĠĠ Ġval Ġfunc Named Fun ctype Args Ġ= Ġfunc Named Fun ctype . arguments Typed ĊĠĠĠĠĠĠĠ ĠassertEquals (" f 5 ", Ġfunc Named Fun ctype . name ) ĊĠĠĠĠĠĠĠ ĠassertTrue ( func Named Fun ctype Args [ 0 ]. var Decl Typed . type Ġis ĠFunction Type ) ĊĠĠĠĠĠĠĠ ĠassertEquals (" name ", Ġfunc Named Fun ctype Args [ 0 ]. var Decl Typed . name ) ĊĠĠĠĠĠĠĠ Ġval Ġnamed Params Ġ= Ġ( func Named Fun ctype Args [ 0 ]. var Decl Typed . type Ġas ĠFunction Type ). params Typed ĊĠĠĠĠĠĠĠ ĠassertEquals (" p 1 ", Ġnamed Params [ 0 ]. name ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( int Type , Ġnamed Params [ 0 ]. type ) ĊĠĠĠĠĠĠĠ ĠassertNull ( named Params [ 1 ]. name ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( unit Type , Ġnamed Params [ 1 ]. type ) ĊĠĠĠĠĠĠĠ ĠassertEquals (" p 3 ", Ġnamed Params [ 2 ]. name ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( int Type , Ġnamed Params [ 2 ]. type ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( Simple Type (" Byte "), Ġ( func Named Fun ctype Args [ 0 ]. var Decl Typed . type Ġas ĠFunction Type ). returnType ) ĊĊĠĠĠĠĠĠĠ Ġval Ġfunc Receiver Null Ġ= Ġchildren List [ 5 ] Ġas ĠFunction Declaration Node ĊĠĠĠĠĠĠĠ ĠassertEquals (" f 6 ", Ġfunc Receiver Null . name ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( Nullable Type ( unit Type ), Ġfunc Receiver Null . receiver Type ) ĊĊĠĠĠĠĠĠĠ Ġval Ġfunc Arg No Ret Fun ctype Ġ= Ġchildren List [ 6 ] Ġas ĠFunction Declaration Node ĊĠĠĠĠĠĠĠ ĠassertEquals (" f 7 ", Ġfunc Arg No Ret Fun ctype . name ) ĊĠĠĠĠĠĠĠ Ġval Ġfun Arg No Ret Arguments Ġ= Ġfunc Arg No Ret Fun ctype . arguments Typed ĊĠĠĠĠĠĠĠ ĠassertTrue ( fun Arg No Ret Arguments [ 0 ]. var Decl Typed . type Ġis ĠFunction Type ) ĊĠĠĠĠĠĠĠ Ġval Ġno Ret F unt ype Ġ= Ġfun Arg No Ret Arguments [ 0 ]. var Decl Typed . type Ġas ĠFunction Type ĊĠĠĠĠĠĠĠ ĠassertEquals ( unit Type , Ġno Ret F unt ype . returnType ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( int Type , Ġno Ret F unt ype . params Typed [ 0 ]. type ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġparse Atomic Expressions () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġast Ġ= Ġbuild AST FromFile ( get My TestData Full name (" atomic _ expression . kt ")) ĊĊĠĠĠĠĠĠĠ Ġval Ġchildren List Ġ= Ġast . members Typed . children ĊĊĠĠĠĠĠĠĠ Ġval Ġexpressions Ġ= Ġchildren List . map Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ( it Ġas ĠFunction Declaration Node ). body Ġas ĠExpression Node ĊĠĠĠĠĠĠĠ Ġ} ĊĊĠĠĠĠĠĠĠ ĠassertTrue ( expressions [ 0 ] Ġis ĠP aren th ized Expression Node ) ĊĠĠĠĠĠĠĠ Ġfor Ġ( i Ġin Ġ 1 .. 9 ) Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ ĠassertTrue ( expressions [ i ] Ġis ĠLiteral Constant Node ) ĊĠĠĠĠĠĠĠ Ġ} ĊĊĠĠĠĠĠĠĠ ĠassertTrue ( expressions [ 1 0 ] Ġis ĠThis Node ) ĊĠĠĠĠĠĠĠ ĠassertTrue ( expressions [ 1 1 ] Ġis ĠThis Node ) ĊĊĠĠĠĠĠĠĠ ĠassertTrue ( expressions [ 1 2 ] Ġis ĠSuper Node ) ĊĠĠĠĠĠĠĠ ĠassertTrue ( expressions [ 1 3 ] Ġis ĠSuper Node ) ĊĠĠĠĠĠĠĠ ĠassertTrue ( expressions [ 1 4 ] Ġis ĠSuper Node ) ĊĊĠĠĠĠĠĠĠ ĠassertTrue ( expressions [ 1 5 ] Ġis ĠIf Node ) ĊĠĠĠĠĠĠĠ ĠassertTrue ( expressions [ 1 6 ] Ġis ĠIf Node ) ĊĊĠĠĠĠĠĠĠ ĠassertTrue ( expressions [ 1 7 ] Ġis ĠWhen Node ) ĊĠĠĠĠĠĠĠ ĠassertTrue ( expressions [ 1 8 ] Ġis ĠWhen Node ) ĊĊĠĠĠĠĠĠĠ ĠassertTrue ( expressions [ 1 9 ] Ġis ĠTry Node ) ĊĊĠĠĠĠĠĠĠ ĠassertTrue ( expressions [ 2 0 ] Ġis ĠObject Literal Node ) ĊĊĠĠĠĠĠĠĠ ĠassertTrue ( expressions [ 2 1 ] Ġis ĠThrow Node ) ĊĊĠĠĠĠĠĠĠ ĠassertTrue ( expressions [ 2 2 ] Ġis ĠReturn Node ) ĊĠĠĠĠĠĠĠ ĠassertTrue ( expressions [ 2 3 ] Ġis ĠReturn Node ) ĊĊĠĠĠĠĠĠĠ ĠassertTrue ( expressions [ 2 4 ] Ġis ĠLoop Jump Node ) ĊĠĠĠĠĠĠĠ ĠassertTrue ( expressions [ 2 5 ] Ġis ĠLoop Jump Node ) ĊĊĠĠĠĠĠĠĠ ĠassertTrue ( expressions [ 2 6 ] Ġis ĠFor Loop Node ) ĊĠĠĠĠĠĠĠ ĠassertTrue ( expressions [ 2 7 ] Ġis ĠWhile Loop Node ) ĊĠĠĠĠĠĠĠ ĠassertTrue ( expressions [ 2 8 ] Ġis ĠWhile Loop Node ) ĊĊĠĠĠĠĠĠĠ ĠassertTrue ( expressions [ 2 9 ] Ġis ĠVariable Usage Node ) ĊĊĠĠĠĠĠĠĠ ĠassertTrue ( expressions [ 3 0 ] Ġis ĠFunction Literal Node ) ĊĊĠĠĠĠĠĠĠ ĠassertTrue ( expressions [ 3 1 ] Ġis ĠFor Loop Node ) ĊĊĠĠĠĠĠĠĠ ĠassertTrue ( expressions [ 3 2 ] Ġis ĠFunction Literal Node ) ĊĠĠĠĠĠĠĠ ĠassertTrue ( expressions [ 3 3 ] Ġis ĠFunction Literal Node ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġparse Declaration Headers () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġast Ġ= Ġbuild AST FromFile ( get My TestData Full name (" declaration _ simple . kt ")) ĊĊĠĠĠĠĠĠĠ Ġval Ġtop Level Ġ= Ġast . members Typed . children ĊĠĠĠĠĠĠĠ ĠassertTrue ( top Level [ 0 ] Ġis ĠFunction Declaration Node ) ĊĠĠĠĠĠĠĠ Ġval Ġfun Body Ġ= Ġ( top Level [ 0 ] Ġas ĠFunction Declaration Node ). body ĊĠĠĠĠĠĠĠ ĠassertTrue ( fun Body Ġis ĠState ments Node ) ĊĊĠĠĠĠĠĠĠ Ġval Ġstatements Ġ= Ġ( fun Body Ġas ĠState ments Node ). children ĊĊĠĠĠĠĠĠĠ ĠassertTrue ( statements [ 0 ] Ġis ĠFunction Declaration Node ) ĊĊĠĠĠĠĠĠĠ ĠassertTrue ( statements [ 1 ] Ġis ĠProperty Declaration Node ) ĊĠĠĠĠĠĠĠ Ġval Ġstatement 1 Typed Ġ= Ġstatements [ 1 ] Ġas ĠProperty Declaration Node ĊĠĠĠĠĠĠĠ ĠassertEquals ( PropertyType . VAL , Ġstatement 1 Typed . prop Type ) ĊĠĠĠĠĠĠĠ Ġval Ġvar Decl Statement 1 Ġ= Ġstatement 1 Typed . var Decl Typed [ 0 ] ĊĠĠĠĠĠĠĠ ĠassertEquals ( Simple Type (" String "), Ġvar Decl Statement 1 . type ) ĊĠĠĠĠĠĠĠ ĠassertEquals (" prop ", Ġvar Decl Statement 1 . name ) ĊĊĠĠĠĠĠĠĠ ĠassertTrue ( statements [ 2 ] Ġis ĠProperty Declaration Node ) ĊĠĠĠĠĠĠĠ Ġval Ġstatements 2 Cast ed Ġ= Ġstatements [ 2 ] Ġas ĠProperty Declaration Node ĊĠĠĠĠĠĠĠ ĠassertEquals ( PropertyType . VAL , Ġstatements 2 Cast ed . prop Type ) ĊĠĠĠĠĠĠĠ Ġval Ġvar Decl Statement 2 Ġ= Ġstatements 2 Cast ed . var Decl Typed [ 0 ] ĊĠĠĠĠĠĠĠ ĠassertEquals ( unit Type , Ġvar Decl Statement 2 . type ) ĊĠĠĠĠĠĠĠ ĠassertEquals (" prop _ 2 ", Ġvar Decl Statement 2 . name ) ĊĊĠĠĠĠĠĠĠ ĠassertTrue ( statements [ 3 ] Ġis ĠProperty Declaration Node ) ĊĠĠĠĠĠĠĠ Ġval Ġstatements 3 Cast ed Ġ= Ġstatements [ 3 ] Ġas ĠProperty Declaration Node ĊĠĠĠĠĠĠĠ ĠassertEquals ( PropertyType . VAR , Ġstatements 3 Cast ed . prop Type ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( 3 , Ġstatements 3 Cast ed . var Decl . size ) ĊĊĠĠĠĠĠĠĠ ĠassertTrue ( statements [ 4 ] Ġis ĠProperty Declaration Node ) ĊĠĠĠĠĠĠĠ Ġval Ġstatements 4 Cast ed Ġ= Ġstatements [ 4 ] Ġas ĠProperty Declaration Node ĊĠĠĠĠĠĠĠ ĠassertEquals ( PropertyType . VAL , Ġstatements 4 Cast ed . prop Type ) ĊĠĠĠĠĠĠĠ Ġval Ġvar Decl Statement 4 Ġ= Ġstatements 4 Cast ed . var Decl Typed [ 0 ] ĊĠĠĠĠĠĠĠ ĠassertEquals ( Simple Type (" Int "), Ġvar Decl Statement 4 . type ) ĊĠĠĠĠĠĠĠ ĠassertEquals (" t ", Ġvar Decl Statement 4 . name ) ĊĊĠĠĠĠĠĠĠ ĠassertTrue ( statements [ 5 ] Ġis ĠClass Declaration Node ) ĊĠĠĠĠĠĠĠ Ġval Ġstatements 5 Cast ed Ġ= Ġstatements [ 5 ] Ġas ĠClass Declaration Node ĊĠĠĠĠĠĠĠ ĠassertEquals (" A ", Ġstatements 5 Cast ed . name ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( Class NodeType . CLASS , Ġstatements 5 Cast ed . nodeType ) ĊĊĠĠĠĠĠĠĠ ĠassertTrue ( statements [ 6 ] Ġis ĠClass Declaration Node ) ĊĠĠĠĠĠĠĠ Ġval Ġstatements 6 Cast ed Ġ= Ġstatements [ 6 ] Ġas ĠClass Declaration Node ĊĠĠĠĠĠĠĠ ĠassertEquals (" B ", Ġstatements 6 Cast ed . name ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( Class NodeType . INTERFACE , Ġstatements 6 Cast ed . nodeType ) ĊĊĠĠĠĠĠĠĠ ĠassertTrue ( statements [ 7 ] Ġis ĠType alias Node ) ĊĠĠĠĠĠĠĠ Ġval Ġstatements 7 Cast ed Ġ= Ġstatements [ 7 ] Ġas ĠType alias Node ĊĠĠĠĠĠĠĠ ĠassertEquals (" bl a ", Ġstatements 7 Cast ed . name ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( Simple Type (" Int "), Ġstatements 7 Cast ed . type ) ĊĊĠĠĠĠĠĠĠ ĠassertTrue ( statements [ 8 ] Ġis ĠObject Node ) ĊĠĠĠĠĠĠĠ ĠassertEquals (" x ", Ġ( statements [ 8 ] Ġas ĠObject Node ). name ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Ignore Ġ// Ġoperator Ġprecedence Ġis Ġbroken Ġright Ġnow ĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġtest Binary Operations () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġast Ġ= Ġbuild AST FromFile ( get My TestData Full name (" binary _ ops . kt ")) ĊĊĠĠĠĠĠĠĠ Ġval Ġtop Level Ġ= Ġast . members Typed . children ĊĊĠĠĠĠĠĠĠ Ġval Ġequals 3 Ġ= Ġtop Level [ 0 ] Ġas ĠFunction Declaration Node ĊĠĠĠĠĠĠĠ Ġval Ġeq 3 body Ġ= Ġequals 3 . body Ġas ĠBinary Op Node ĊĠĠĠĠĠĠĠ ĠassertEquals ( Binary Op Type . OR , Ġeq 3 body . type ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( Binary Op Type . GE , Ġ( eq 3 body . right Ġas ĠBinary Op Node ). type ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( Binary Op Type . AND , Ġ( eq 3 body . left Ġas ĠBinary Op Node ). type ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( Binary Op Type . NOT _ EQ , Ġ(( eq 3 body . left Ġas ĠBinary Op Node ). left Ġas ĠBinary Op Node ). type ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( Binary Op Type . AND , Ġ(( eq 3 body . left Ġas ĠBinary Op Node ). right Ġas ĠBinary Op Node ). type ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( Binary Op Type . EQ , Ġ((( eq 3 body . left Ġas ĠBinary Op Node ). right Ġas ĠBinary Op Node ). right Ġas ĠBinary Op Node ). type ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġtest Calls () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġast Ġ= Ġbuild AST FromFile ( get My TestData Full name (" calls . kt ")) ĊĊĠĠĠĠĠĠĠ Ġval Ġtop Level Ġ= Ġast . members Typed . children ĊĊĠĠĠĠĠĠĠ Ġval Ġin fix Call Ġ= Ġtop Level [ 0 ] Ġas ĠFunction Declaration Node ĊĠĠĠĠĠĠĠ Ġval Ġin fix Call Body Ġ= Ġin fix Call . body Ġas ĠIn fix Call Node ĊĠĠĠĠĠĠĠ ĠassertEquals (" xor ", Ġin fix Call Body . func Name ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( Literal Constant Node (" 1 "), Ġin fix Call Body . arg Left ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( Literal Constant Node (" 2 "), Ġin fix Call Body . arg Right ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġtest Unary Prefix Ops () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġast Ġ= Ġbuild AST FromFile ( get My TestData Full name (" unary _ ops . kt ")) ĊĊĠĠĠĠĠĠĠ Ġval Ġprefix Ops Ġ= Ġ( get Typed Node < Function Declaration Node >( ast . members Typed . children [ 0 ]). body Ġas ĠState ments Node ). children ĊĊĠĠĠĠĠĠĠ ĠassertEquals ( 5 , Ġprefix Ops . size ) ĊĠĠĠĠĠĠĠ Ġfor Ġ( op Ġin Ġprefix Ops ) Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ ĠassertTrue ( op Ġis ĠFunction Declaration Node ) ĊĠĠĠĠĠĠĠĠĠĠĠ ĠassertTrue ( get Typed Node < Function Declaration Node >( op ). body Ġis ĠPrefix Unary Op Node ) ĊĠĠĠĠĠĠĠ Ġ} ĊĊĠĠĠĠĠĠĠ Ġval Ġprefix Ops Typed Ġ= Ġprefix Ops . map Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġget Typed Node < Prefix Unary Op Node >( get Typed Node < Function Declaration Node >( it ). body !! ) ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠĠĠĠĠ ĠassertEquals ( Prefix Unary Op Type . NEG , Ġprefix Ops Typed [ 0 ]. type ) ĊĠĠĠĠĠĠĠ ĠassertTrue ( prefix Ops Typed [ 0 ]. expr Ġis ĠLiteral Constant Node ) ĊĊĠĠĠĠĠĠĠ ĠassertEquals ( Prefix Unary Op Type . LABEL , Ġprefix Ops Typed [ 1 ]. type ) ĊĠĠĠĠĠĠĠ ĠassertNotNull ( prefix Ops Typed [ 1 ]. label Name ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( Prefix Unary Op Type . INCREMENT , ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġget Typed Node < Prefix Unary Op Node >( prefix Ops Typed [ 1 ]. expr ). type ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( Prefix Unary Op Type . NOT , ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġget Typed Node < Prefix Unary Op Node >( get Typed Node < Prefix Unary Op Node >( prefix Ops Typed [ 1 ]. expr ). expr ). type ) ĊĊĠĠĠĠĠĠĠ ĠassertEquals ( Prefix Unary Op Type . AN NOT ATION , Ġprefix Ops Typed [ 2 ]. type ) ĊĠĠĠĠĠĠĠ ĠassertNotNull ( prefix Ops Typed [ 2 ]. annotations ) ĊĊĠĠĠĠĠĠĠ ĠassertEquals ( Prefix Unary Op Type . AN NOT ATION , Ġprefix Ops Typed [ 3 ]. type ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( Prefix Unary Op Type . POS , Ġget Typed Node < Prefix Unary Op Node >( prefix Ops Typed [ 3 ]. expr ). type ) ĊĠĠĠĠĠĠĠ ĠassertNotNull ( prefix Ops Typed [ 3 ]. annotations ) ĊĊĠĠĠĠĠĠĠ ĠassertEquals ( Prefix Unary Op Type . DECRE MENT , Ġprefix Ops Typed [ 4 ]. type ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġtest Unary Post fix Ops () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġast Ġ= Ġbuild AST FromFile ( get My TestData Full name (" unary _ ops . kt ")) ĊĊĠĠĠĠĠĠĠ Ġval Ġpostfix Ops Ġ= Ġget Typed Node < Statements Node >( get Typed Node < Function Declaration Node >( ast . members Typed . children [ 1 ]). body !! ). children . map Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ( it Ġas ĠFunction Declaration Node ). body Ġas ĠExpression Node ĊĠĠĠĠĠĠĠ Ġ} ĊĊĠĠĠĠĠĠĠ Ġfor Ġ( i Ġin Ġ 0 .. 2 ) Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ ĠassertTrue ( postfix Ops [ i ] Ġis ĠCallable Reference Node ) ĊĠĠĠĠĠĠĠ Ġ} ĊĊĠĠĠĠĠĠĠ ĠassertEquals ( Post fix Unary Op Type . INCREMENT , Ġget Typed Node < Post fix Unary Node >( postfix Ops [ 3 ]). type ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( Post fix Unary Op Type . DECRE MENT , Ġget Typed Node < Post fix Unary Node >( postfix Ops [ 4 ]). type ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( Post fix Unary Op Type . NOT _ NULL , Ġget Typed Node < Post fix Unary Node >( postfix Ops [ 5 ]). type ) ĊĊĠĠĠĠĠĠĠ Ġval Ġlambda Chain Ġ= Ġget Typed Node < Member Access Node >( postfix Ops [ 6 ]) ĊĠĠĠĠĠĠĠ ĠassertEquals ( Member AccessType . SAFE , Ġlambda Chain . type ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( Variable Usage Node (" a "), Ġlambda Chain . obj ) ĊĠĠĠĠĠĠĠ Ġval Ġmap Member Ġ= Ġget Typed Node < Member Access Node >( lambda Chain . member ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( Member AccessType . DOT , Ġmap Member . type ) ĊĠĠĠĠĠĠĠ Ġval Ġmap Call Ġ= Ġget Typed Node < Function Call Node >( map Member . obj ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( Variable Usage Node (" map "), Ġmap Call . func ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( 1 , Ġmap Call . type Args . size ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( 1 , Ġmap Call . args . size ) ĊĠĠĠĠĠĠĠ ĠassertTrue ( map Call . args [ 0 ] Ġis ĠFunction Literal Node ) ĊĠĠĠĠĠĠĠ Ġval Ġfilter Call Ġ= Ġget Typed Node < Function Call Node >( map Member . member ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( Variable Usage Node (" filter "), Ġfilter Call . func ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( 0 , Ġfilter Call . type Args . size ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( 1 , Ġfilter Call . args . size ) ĊĊĊĠĠĠĠĠĠĠ Ġval Ġcall Chain Ġ= Ġget Typed Node < Function Call Node >( postfix Ops [ 7 ]) ĊĠĠĠĠĠĠĠ ĠassertEquals ( 3 , Ġcall Chain . args . size ) ĊĠĠĠĠĠĠĠ ĠassertTrue ( call Chain . args Typed VA [ 1 ]. need Unpack ) ĊĠĠĠĠĠĠĠ ĠassertFalse ( call Chain . args Typed VA [ 0 ]. need Unpack ) ĊĠĠĠĠĠĠĠ ĠassertFalse ( call Chain . args Typed VA [ 2 ]. need Unpack ) ĊĠĠĠĠĠĠĠ ĠassertNull ( call Chain . args Typed VA [ 0 ]. name ) ĊĠĠĠĠĠĠĠ ĠassertNull ( call Chain . args Typed VA [ 1 ]. name ) ĊĠĠĠĠĠĠĠ ĠassertEquals (" x ", Ġcall Chain . args Typed VA [ 2 ]. name ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( 2 , Ġcall Chain . type Args . size ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( Variable Usage Node (" bar "), Ġget Typed Node < Function Call Node >( call Chain . func ). func ) ĊĊĠĠĠĠĠĠĠ Ġval Ġarr Sub Ġ= Ġget Typed Node < Array Access Node >( postfix Ops [ 8 ]) ĊĠĠĠĠĠĠĠ ĠassertEquals ( 1 , Ġarr Sub . expressions . size ) ĊĠĠĠĠĠĠĠ Ġval Ġinner Arr Ġ= Ġget Typed Node < Array Access Node >( arr Sub . arr ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( 3 , Ġinner Arr . expressions . size ) ĊĠĠĠĠĠĠĠ ĠassertTrue ( inner Arr . arr Ġis ĠCallable Reference Node ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġparse Generic Types () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġast Ġ= Ġbuild AST FromFile ( get My TestData Full name (" generic _ types . kt ")) ĊĊĠĠĠĠĠĠĠ Ġval Ġtop Level Ġ= Ġast . members Typed . children ĊĊĠĠĠĠĠĠĠ Ġval Ġfunc Ġ= Ġget Typed Node < Function Declaration Node >( top Level [ 0 ]) ĊĠĠĠĠĠĠĠ Ġval Ġfunc Generic Params Ġ= Ġget Typed Node < GenericType Params >( func . generic Params !! ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( 2 , Ġfunc Generic Params . types . size ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( Simple Type (" T "), Ġfunc Generic Params . types [ 0 ]) ĊĠĠĠĠĠĠĠ ĠassertEquals ( Simple Type (" R "), Ġget Typed Node < Type Projection >( func Generic Params . types [ 1 ]). type ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( listOf (" re ified ", Ġ" in "), Ġget Typed Node < Type Projection >( func Generic Params . types [ 1 ]). modifiers Typed . raw Modifiers Annotations ) ĊĊĠĠĠĠĠĠĠ Ġval Ġfunc Receiver Type Ġ= Ġget Typed Node < Dot ted Type >( func . receiver Type !! ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( Simple Type (" List "), Ġget Typed Node < Project ed GenericType >( func Receiver Type . rhs ). inner Type ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( Simple Type (" T "), Ġget Typed Node < Project ed GenericType >( func Receiver Type . rhs ). projection s Typed [ 0 ]. type ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( 0 , Ġget Typed Node < Project ed GenericType >( func Receiver Type . rhs ). projection s Typed [ 0 ]. modifiers Typed . raw Modifiers Annotations . size ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( 1 , Ġget Typed Node < Project ed GenericType >( func Receiver Type . rhs ). projection s Typed . size ) ĊĠĠĠĠĠĠĠ Ġval Ġfunc Rec Type L hs Ġ= Ġget Typed Node < Dot ted Type >( func Receiver Type . lhs ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( Simple Type (" b "), Ġget Typed Node < Project ed GenericType >( func Rec Type L hs . rhs ). inner Type ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( listOf ("* "), Ġget Typed Node < Project ed GenericType >( func Rec Type L hs . rhs ). projection s Typed [ 0 ]. modifiers Typed . raw Modifiers Annotations ) ĊĠĠĠĠĠĠĠ ĠassertNull ( get Typed Node < Project ed GenericType >( func Rec Type L hs . rhs ). projection s Typed [ 0 ]. type ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( 1 , Ġget Typed Node < Project ed GenericType >( func Rec Type L hs . rhs ). projection s Typed . size ) ĊĠĠĠĠĠĠĠ Ġval Ġfunc Rec Type L hs L hs Ġ= Ġget Typed Node < Dot ted Type >( func Rec Type L hs . lhs ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( 2 , Ġget Typed Node < Project ed GenericType >( func Rec Type L hs L hs . rhs ). projection s Typed . size ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( Simple Type (" lang "), Ġget Typed Node < Project ed GenericType >( func Rec Type L hs L hs . rhs ). inner Type ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( listOf (" in "), Ġget Typed Node < Project ed GenericType >( func Rec Type L hs L hs . rhs ). projection s Typed [ 0 ]. modifiers Typed . raw Modifiers Annotations ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( Simple Type (" R "), Ġget Typed Node < Project ed GenericType >( func Rec Type L hs L hs . rhs ). projection s Typed [ 0 ]. type ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( listOf (" out "), Ġget Typed Node < Project ed GenericType >( func Rec Type L hs L hs . rhs ). projection s Typed [ 1 ]. modifiers Typed . raw Modifiers Annotations ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( Simple Type (" U "), Ġget Typed Node < Project ed GenericType >( func Rec Type L hs L hs . rhs ). projection s Typed [ 1 ]. type ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( Simple Type (" java "), Ġfunc Rec Type L hs L hs . lhs ) ĊĊĠĠĠĠĠĠĠ Ġval Ġcls Ġ= Ġget Typed Node < Class Declaration Node >( top Level [ 1 ]) ĊĠĠĠĠĠĠĠ ĠassertEquals ( 2 , Ġget Typed Node < GenericType Params >( cls . type Params !! ). types . size ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( listOf (" out "), Ġget Typed Node < Type Projection >( get Typed Node < GenericType Params >( cls . type Params !! ). types [ 0 ]). modifiers Typed . raw Modifiers Annotations ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( Simple Type (" R "), Ġget Typed Node < Type Projection >( get Typed Node < GenericType Params >( cls . type Params !! ). types [ 0 ]). type ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( listOf (" in "), Ġget Typed Node < Type Projection >( get Typed Node < GenericType Params >( cls . type Params !! ). types [ 1 ]). modifiers Typed . raw Modifiers Annotations ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( Simple Type (" D "), Ġget Typed Node < Type Projection >( get Typed Node < GenericType Params >( cls . type Params !! ). types [ 1 ]). type ) ĊĊĠĠĠĠĠĠĠ Ġval Ġalias Ġ= Ġget Typed Node < Type alias Node >( top Level [ 2 ]) ĊĠĠĠĠĠĠĠ ĠassertEquals ( 1 , Ġget Typed Node < GenericType Params >( alias . generic Params !! ). types . size ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( Simple Type (" T "), Ġget Typed Node < GenericType Params >( alias . generic Params !! ). types [ 0 ]) ĊĊĠĠĠĠĠĠĠ Ġval Ġprop Ġ= Ġget Typed Node < Property Declaration Node >( top Level [ 3 ]) ĊĠĠĠĠĠĠĠ ĠassertEquals ( 1 , Ġget Typed Node < GenericType Params >( prop . generic Params !! ). types . size ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( Simple Type (" T "), Ġget Typed Node < GenericType Params >( prop . generic Params !! ). types [ 0 ]) ĊĠĠĠ Ġ} Ċ }