summaryrefslogtreecommitdiff
path: root/src/test
diff options
context:
space:
mode:
authordibyendumajumdar <mobile@majumdar.org.uk>2023-08-25 23:16:07 +0100
committerdibyendumajumdar <mobile@majumdar.org.uk>2023-08-25 23:16:07 +0100
commit9a2ab9bb803aa4da2a6007cc2e945d6bc1fe0b39 (patch)
tree05dcb2c2b972538dba2da0429ba9705e09dc8e96 /src/test
parentb6098a9b9166da962676e33de31e93ace260d686 (diff)
downloadSimple-9a2ab9bb803aa4da2a6007cc2e945d6bc1fe0b39.tar.gz
Simple-9a2ab9bb803aa4da2a6007cc2e945d6bc1fe0b39.zip
Reorganized the project as multi-maven module
Updated README Added language module with grammar Split the code into common and chapter01 modules. Removed a number of utility classes that were imported from AA. Added github workflow file.
Diffstat (limited to 'src/test')
-rw-r--r--src/test/java/com/seaofnodes/simple/lexer/TestLexer.java37
-rw-r--r--src/test/java/com/seaofnodes/simple/lexer/TestParser.java68
2 files changed, 0 insertions, 105 deletions
diff --git a/src/test/java/com/seaofnodes/simple/lexer/TestLexer.java b/src/test/java/com/seaofnodes/simple/lexer/TestLexer.java
deleted file mode 100644
index 18a4634d..00000000
--- a/src/test/java/com/seaofnodes/simple/lexer/TestLexer.java
+++ /dev/null
@@ -1,37 +0,0 @@
-/**
- * DO NOT REMOVE COPYRIGHT NOTICES OR THIS HEADER.
- *
- * Contributor(s):
- *
- * This file is part of the Sea Of Nodes Simple Programming language
- * implementation. See https://github.com/SeaOfNodes/Simple
- *
- * The contents of this file are subject to the terms of the
- * Apache License Version 2 (the "APL"). You may not use this
- * file except in compliance with the License. A copy of the
- * APL may be obtained from:
- * http://www.apache.org/licenses/LICENSE-2.0
- */
-
-package com.seaofnodes.simple.lexer;
-
-import com.seaofnodes.simple.common.ErrorListener;
-import com.seaofnodes.simple.lexer.ecstasy.Lexer;
-import com.seaofnodes.simple.lexer.ecstasy.Source;
-import com.seaofnodes.simple.lexer.ecstasy.Token;
-import org.junit.jupiter.api.Assertions;
-import org.junit.jupiter.api.Test;
-
-public class TestLexer {
-
- @Test
- public void testLexLineComment()
- {
- final String source = "//a comment\nx";
- Lexer lexer = new Lexer(new Source(source), new ErrorListener());
- Token token = lexer.next();
- Assertions.assertEquals(token.getId(), Token.Id.EOL_COMMENT);
- token = lexer.next();
- Assertions.assertEquals("x", token.getValueText());
- }
-}
diff --git a/src/test/java/com/seaofnodes/simple/lexer/TestParser.java b/src/test/java/com/seaofnodes/simple/lexer/TestParser.java
deleted file mode 100644
index 7d2f3752..00000000
--- a/src/test/java/com/seaofnodes/simple/lexer/TestParser.java
+++ /dev/null
@@ -1,68 +0,0 @@
-/**
- * DO NOT REMOVE COPYRIGHT NOTICES OR THIS HEADER.
- *
- * Contributor(s):
- *
- * This file is part of the Sea Of Nodes Simple Programming language
- * implementation. See https://github.com/SeaOfNodes/Simple
- *
- * The contents of this file are subject to the terms of the
- * Apache License Version 2 (the "APL"). You may not use this
- * file except in compliance with the License. A copy of the
- * APL may be obtained from:
- * http://www.apache.org/licenses/LICENSE-2.0
- */
-
-package com.seaofnodes.simple.lexer;
-
-import com.seaofnodes.simple.common.ErrorListener;
-import com.seaofnodes.simple.lexer.ecstasy.Lexer;
-import com.seaofnodes.simple.lexer.ecstasy.Source;
-import com.seaofnodes.simple.parser.Ast;
-import com.seaofnodes.simple.parser.Parser;
-import org.junit.jupiter.api.Assertions;
-import org.junit.jupiter.api.Test;
-
-public class TestParser {
-
- @Test
- public void testParseSingleDecl()
- {
- final String source = "var i: Int;";
- Lexer lexer = new Lexer(new Source(source), new ErrorListener());
- Parser parser = new Parser(lexer);
- var ast = parser.parse();
- Assertions.assertTrue(ast instanceof Ast.Block
- && ((Ast.Block) ast).stmtList.size() == 1);
- }
-
- @Test
- public void testParseTwoDecls() {
- final String source = "var i: Int;\nvar j: Int;";
- Lexer lexer = new Lexer(new Source(source), new ErrorListener());
- Parser parser = new Parser(lexer);
- var ast = parser.parse();
- Assertions.assertTrue(ast instanceof Ast.Block
- && ((Ast.Block) ast).stmtList.size() == 2);
- }
-
- @Test
- public void testIfAndWhile() {
- final String source =
- """
- var i: Int;
- var j: Int;
-
- i = 0;
- j = 100;
- while ( 1 ) {
- i = i + 1;
- j = j - 1;
- if ( i >= j ) break;
- }
- """;
- Lexer lexer = new Lexer(new Source(source), new ErrorListener());
- Parser parser = new Parser(lexer);
- var ast = parser.parse();
- }
-}