-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
1. [PROJECT]::Add test cases for semtic check and ast.
- Loading branch information
Showing
22 changed files
with
244 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -24,4 +24,5 @@ protected void _dump(Dumper d) { | |
super._dump(d); | ||
d.printMember("raw",rawValue); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
12 changes: 12 additions & 0 deletions
12
ep20/src/main/java/org/teachfx/antlr4/ep20/pass/sematic/TypeChecker.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
package org.teachfx.antlr4.ep20.pass.sematic; | ||
|
||
import org.teachfx.antlr4.ep20.pass.ast.ASTBaseVisitor; | ||
|
||
public class TypeChecker extends ASTBaseVisitor | ||
{ | ||
public TypeChecker() | ||
{ | ||
|
||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,4 +9,6 @@ public interface Type { | |
|
||
public Type getFuncType(); | ||
public Type getPrimitiveType(); | ||
|
||
|
||
} |
14 changes: 14 additions & 0 deletions
14
ep20/src/test/java/org/teachfx/antlr4/ep20/ast/expr/BoolExprNodeTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
package org.teachfx.antlr4.ep20.ast.expr; | ||
|
||
import org.junit.jupiter.api.Test; | ||
|
||
import static org.junit.jupiter.api.Assertions.*; | ||
|
||
class BoolExprNodeTest { | ||
|
||
@Test | ||
void testToString() { | ||
var boolVal = new BoolExprNode(true,null); | ||
assertEquals("true",boolVal.getRawValue().toString()); | ||
} | ||
} |
16 changes: 16 additions & 0 deletions
16
ep20/src/test/java/org/teachfx/antlr4/ep20/ast/expr/FloatExprNodeTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
package org.teachfx.antlr4.ep20.ast.expr; | ||
|
||
import org.junit.jupiter.api.Test; | ||
|
||
import static org.junit.jupiter.api.Assertions.*; | ||
|
||
class FloatExprNodeTest { | ||
@Test | ||
void floatRawExtract() { | ||
|
||
var node = new FloatExprNode(1.2,null); | ||
assertEquals((double) 1.2, node.getRawValue()); | ||
} | ||
|
||
|
||
} |
14 changes: 14 additions & 0 deletions
14
ep20/src/test/java/org/teachfx/antlr4/ep20/ast/expr/StringExprNodeTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
package org.teachfx.antlr4.ep20.ast.expr; | ||
|
||
import org.junit.jupiter.api.Test; | ||
|
||
import static org.junit.jupiter.api.Assertions.*; | ||
|
||
class StringExprNodeTest { | ||
|
||
@Test | ||
void testRawVal() { | ||
var strNode = new StringExprNode("Hello",null); | ||
assertEquals("Hello",strNode.getRawValue()); | ||
} | ||
} |
15 changes: 15 additions & 0 deletions
15
ep20/src/test/java/org/teachfx/antlr4/ep20/ast/expr/UnaryExprNodeTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
package org.teachfx.antlr4.ep20.ast.expr; | ||
|
||
import org.junit.jupiter.api.Test; | ||
import static org.junit.jupiter.api.Assertions.*; | ||
import org.teachfx.antlr4.ep20.symtab.type.OperatorType; | ||
|
||
class UnaryExprNodeTest { | ||
@Test | ||
public void testNegInt() { | ||
var node = new UnaryExprNode(OperatorType.UnaryOpType.NEG, new IntExprNode(1, null),null); | ||
|
||
assertEquals(node.getOpType(),OperatorType.UnaryOpType.NEG); | ||
assertEquals(node.getValExpr(), new IntExprNode(1, null)); | ||
} | ||
} |
17 changes: 17 additions & 0 deletions
17
ep20/src/test/java/org/teachfx/antlr4/ep20/pass/sematic/TypeCheckerTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
package org.teachfx.antlr4.ep20.pass.sematic; | ||
|
||
import org.junit.jupiter.api.AfterEach; | ||
import org.junit.jupiter.api.BeforeEach; | ||
|
||
import static org.junit.jupiter.api.Assertions.*; | ||
|
||
class TypeCheckerTest { | ||
|
||
@BeforeEach | ||
void setUp() { | ||
} | ||
|
||
@AfterEach | ||
void tearDown() { | ||
} | ||
} |
33 changes: 33 additions & 0 deletions
33
ep20/src/test/java/org/teachfx/antlr4/ep20/pass/symtab/LocalDefineTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
package org.teachfx.antlr4.ep20.pass.symtab; | ||
|
||
import org.junit.jupiter.api.AfterEach; | ||
import org.junit.jupiter.api.BeforeEach; | ||
import org.junit.jupiter.api.Test; | ||
|
||
import static org.junit.jupiter.api.Assertions.*; | ||
|
||
class LocalDefineTest { | ||
@BeforeEach | ||
void setUp() { | ||
} | ||
|
||
@AfterEach | ||
void tearDown() { | ||
} | ||
|
||
@Test | ||
void stashScope() { | ||
} | ||
|
||
@Test | ||
void popScope() { | ||
} | ||
|
||
@Test | ||
void getTopScope() { | ||
} | ||
|
||
@Test | ||
void setTopScope() { | ||
} | ||
} |
Oops, something went wrong.