Commits

Gigih Aji Ibrahim  committed 2d5ce9b

fix unittest

  • Participants
  • Parent commits c026f7a

Comments (0)

Files changed (1)

File src/unittest/test_parser4.py

 
 
     def testClosure1(self):
-        data = "#(a Int, b Int) -> Int:a+b"
+        data = ":|a Int, b Int -> Int| a+b"
         node   = init(data).pExpr()
         assertAST(node, ClosureExpr)
         assertASTValue(node.returnType, NameType, name="Int")
         assertASTValue(node.params[0].type, NameType, name="Int")
         assertASTValue(node.params[1].type, NameType, name="Int")
 
-        data = "#(a Int, b Int):a+b"
+        data = ":|a Int, b Int| a+b"
         node   = init(data).pExpr()
         assertAST(node, ClosureExpr)
         assertAST(node.returnType, AutoType)
         assertASTValue(node.params[0].type, NameType, name="Int")
         assertASTValue(node.params[1].type, NameType, name="Int")
         
-        data = "#(a, b):a+b"
+        data = ":|a, b| a+b"
         node   = init(data).pExpr()
         assertAST(node, ClosureExpr)
         assertAST(node.returnType, AutoType)
         assertAST(node.params[0].type, AutoType)
         assertAST(node.params[1].type, AutoType)
 
-        data = "#:a+b"
+        data = ":||a+b"
         node   = init(data).pExpr()
         assertAST(node, ClosureExpr)
         assertAST(node.returnType, AutoType)
 
 
     def testClosure2(self):
-        data = "call(#:a+b)"
+        data = "call(:a+b)"
         node   = init(data).pExpr()
         assertAST(node.args[0], ClosureExpr)
         assertAST(node.args[0].returnType, AutoType)
         assert len(node.args) == 1
         assert len(node.args[0].params) == 0
         
-        data = "array[#:a+b]"
+        data = "array[:a+b]"
         node   = init(data).pExpr()
         assertAST(node.exprs[0], ClosureExpr)
         assertAST(node.exprs[0].returnType, AutoType)
 
         ## class with extends & type params
         data  = r"""
-class Foo!T (Bar, Baz):
+class Foo!T < Bar, Baz:
     var bar Int
     def baz -> Int:
         return 24
 
         node   = init(data).pDecl()
         assertASTValue(node, ClassDecl, name="Foo")
-        assertASTValue(node.extends[0], NameType, name="Bar")
-        assertASTValue(node.extends[1], NameType, name="Baz")
+
+        assertAST(node.extends[0], ExtendDecl)
+        assertASTValue(node.extends[0].name, NameType, name="Bar")
+
+        assertAST(node.extends[1], ExtendDecl)
+        assertASTValue(node.extends[1].name, NameType, name="Baz")
+        
         assertASTValue(node.typeParams[0], TypeParamDecl, name="T")
         assertASTValue(node.vars[0], VarDecl, name="bar")
         assertASTValue(node.defs[0], DefDecl, name="baz")
         assertASTValue(node.typeArgs[0].typeArgs[0].typeArgs[0], NameType, name='Int')
 
     def testDef(self):
-        data = r"""#"""
+        data = r"""||"""
         node   = init(data).pType()
         assertAST(node, DefType)
 
-        data = r"""#Int"""
+        data = r"""|Int|"""
         node   = init(data).pType()
         assertAST(node, DefType)
         assertASTValue(node.paramTypes[0].type, NameType, name='Int')
 
-        data = r"""#(Int,Str)"""
+        data = r"""|Int,Str|"""
         node   = init(data).pType()
         assertAST(node, DefType)
         assertASTValue(node.paramTypes[0].type, NameType, name='Int')
         assertASTValue(node.paramTypes[1].type, NameType, name='Str')
 
-        data = r"""#(Int,Str)->Int"""
+        data = r"""|Int,Str->Int|"""
         node   = init(data).pType()
         assertAST(node, DefType)
         assertASTValue(node.paramTypes[0].type, NameType, name='Int')
         assertASTValue(node.paramTypes[1].type, NameType, name='Str')
         assertASTValue(node.returnType, NameType, name='Int')
 
-        data = r"""#->Int"""
+        data = r"""|->Int|"""
         node   = init(data).pType()
         assertAST(node, DefType)
         assertASTValue(node.returnType, NameType, name='Int')
         assertASTValue(node.rightExpr, LitExpr, value=200)
 
     def testDecl(self):
-        data = r"""ok := 200"""
+        data = r"""val ok = 200"""
         node   = init(data).pStmt()
         assertASTValue(node, LocalVarStmt, name="ok")
         assertASTValue(node.init, LitExpr, value=200)