aboutsummaryrefslogtreecommitdiff
path: root/src/test/java
diff options
context:
space:
mode:
Diffstat (limited to 'src/test/java')
-rw-r--r--src/test/java/org/shedlang/compiler/parser/ParserIntLiteralTests.java20
1 files changed, 19 insertions, 1 deletions
diff --git a/src/test/java/org/shedlang/compiler/parser/ParserIntLiteralTests.java b/src/test/java/org/shedlang/compiler/parser/ParserIntLiteralTests.java
index 61908772..bc0dcad9 100644
--- a/src/test/java/org/shedlang/compiler/parser/ParserIntLiteralTests.java
+++ b/src/test/java/org/shedlang/compiler/parser/ParserIntLiteralTests.java
@@ -7,7 +7,7 @@ import static org.shedlang.compiler.parser.ParserTesting.parseString;
import static org.zwobble.precisely.AssertThat.assertThat;
public class ParserIntLiteralTests {
- // TODO: negatives
+ // TODO: forbid negative zero?
// TODO: forbid leading zeroes?
@Test
@@ -36,4 +36,22 @@ public class ParserIntLiteralTests {
assertThat(node, isUntypedIntLiteralNode(723));
}
+
+ @Test
+ public void canParseSingleDigitNegativeInt() {
+ var source = "-7";
+
+ var node = parseString(source, Parser::parseTopLevelExpression);
+
+ assertThat(node, isUntypedIntLiteralNode(-7));
+ }
+
+ @Test
+ public void canParseManyDigitNegativeInt() {
+ var source = "-723";
+
+ var node = parseString(source, Parser::parseTopLevelExpression);
+
+ assertThat(node, isUntypedIntLiteralNode(-723));
+ }
}