diff options
| author | dibyendumajumdar <mobile@majumdar.org.uk> | 2023-09-07 22:28:11 +0100 |
|---|---|---|
| committer | dibyendumajumdar <mobile@majumdar.org.uk> | 2023-09-07 22:28:11 +0100 |
| commit | dbd9798602c3b80bc00c93c797b942dcb0e234c1 (patch) | |
| tree | 5a32a60e3070347c99b4ee6fa572533f90d77085 /chapter01/src/test | |
| parent | 195ebcc0ce1fa2e0967182dfd10506135cff6ded (diff) | |
| download | Simple-dbd9798602c3b80bc00c93c797b942dcb0e234c1.tar.gz Simple-dbd9798602c3b80bc00c93c797b942dcb0e234c1.zip | |
Drop AST and parser and lexer
Diffstat (limited to 'chapter01/src/test')
| -rw-r--r-- | chapter01/src/test/java/com/seaofnodes/simple/parser/TestParser.java | 62 |
1 files changed, 0 insertions, 62 deletions
diff --git a/chapter01/src/test/java/com/seaofnodes/simple/parser/TestParser.java b/chapter01/src/test/java/com/seaofnodes/simple/parser/TestParser.java deleted file mode 100644 index 356420eb..00000000 --- a/chapter01/src/test/java/com/seaofnodes/simple/parser/TestParser.java +++ /dev/null @@ -1,62 +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.parser; - -import org.junit.Assert; -import org.junit.Test; - -public class TestParser { - - @Test - public void testParseSingleDecl() - { - final String source = "int i;"; - Lexer lexer = new Lexer(source); - Parser parser = new Parser(); - var ast = parser.parse(lexer); - Assert.assertEquals("{int i;}", ast.toString()); - } - - @Test - public void testParseTwoDecls() { - final String source = "int i;\nint j;"; - Lexer lexer = new Lexer(source); - Parser parser = new Parser(); - var ast = parser.parse(lexer); - Assert.assertEquals("{int i;int j;}", ast.toString()); - } - - @Test - public void testIfAndWhile() { - final String source = - """ - int i; - int j; - - i = 0; - j = 100; - while ( 1 ) { - i = i + 1; - j = j - 1; - if ( i >= j ) break; - } - """; - Lexer lexer = new Lexer(source); - Parser parser = new Parser(); - var ast = parser.parse(lexer); - Assert.assertEquals("{int i;int j;i=0;j=100;while(1) {i=(i+1);j=(j-1);if((i>=j)) break;}}", ast.toString()); - } -} |
