From 82d3887e90e255912c6f92e10d819d923c4f1940 Mon Sep 17 00:00:00 2001 From: Michael Williamson Date: Sun, 22 Oct 2023 22:36:50 +0100 Subject: Support parsing negative zero --- .../org/shedlang/compiler/parser/ParserIntLiteralTests.java | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) (limited to 'src/test/java') diff --git a/src/test/java/org/shedlang/compiler/parser/ParserIntLiteralTests.java b/src/test/java/org/shedlang/compiler/parser/ParserIntLiteralTests.java index f4865e1c..e45a51c7 100644 --- a/src/test/java/org/shedlang/compiler/parser/ParserIntLiteralTests.java +++ b/src/test/java/org/shedlang/compiler/parser/ParserIntLiteralTests.java @@ -8,8 +8,6 @@ import static org.shedlang.compiler.parser.ParserTesting.parseString; import static org.zwobble.precisely.AssertThat.assertThat; public class ParserIntLiteralTests { - // TODO: forbid negative zero? - @Test public void canParseZero() { var source = "0"; @@ -19,6 +17,15 @@ public class ParserIntLiteralTests { assertThat(node, isUntypedIntLiteralNode(0)); } + @Test + public void canParseNegativeZero() { + var source = "-0"; + + var node = parseString(source, Parser::parseTopLevelExpression); + + assertThat(node, isUntypedIntLiteralNode(0)); + } + @Test public void canParseSingleDigitPositiveInt() { var source = "7"; -- cgit v1.2.3