You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@groovy.apache.org by su...@apache.org on 2026/09/12 03:31:46 UTC
(groovy) 04/04: GROOVY-12398: Add tests for invalid octal number parsing
This is an automated email from the ASF dual-hosted git repository.
asf-gitbox-commits pushed a commit to branch GROOVY-12398
in repository https://gitbox.apache.org/repos/asf/groovy.git
commit b133ca5f6234753ffec96e10ca1d87978e8a3c24
Author: Daniel Sun <su...@apache.org>
AuthorDate: Sat Sep 12 12:31:06 2026 +0900
GROOVY-12398: Add tests for invalid octal number parsing
---
.../parser/antlr4/ParserNegativeSyntaxTest.groovy | 22 ++++++++++++++++++++++
1 file changed, 22 insertions(+)
diff --git a/src/test/groovy/org/apache/groovy/parser/antlr4/ParserNegativeSyntaxTest.groovy b/src/test/groovy/org/apache/groovy/parser/antlr4/ParserNegativeSyntaxTest.groovy
index f4fee8e19e..527fb31846 100644
--- a/src/test/groovy/org/apache/groovy/parser/antlr4/ParserNegativeSyntaxTest.groovy
+++ b/src/test/groovy/org/apache/groovy/parser/antlr4/ParserNegativeSyntaxTest.groovy
@@ -3450,6 +3450,28 @@ final class ParserNegativeSyntaxTest {
expectContainsOnce 'def n = 08', 'Invalid octal number'
}
+ @Test
+ void 'invalid octal number caret is the digit not a drifted count'() {
+ expectParseError 'def n = 08', '''\
+ |Invalid octal number @ line 1, column 9.
+ | def n = 08
+ | ^
+ |
+ |1 error
+ |'''.stripMargin()
+ }
+
+ @Test
+ void 'invalid octal with suffix caret is still the token start'() {
+ expectParseError 'def n = 08L', '''\
+ |Invalid octal number @ line 1, column 9.
+ | def n = 08L
+ | ^
+ |
+ |1 error
+ |'''.stripMargin()
+ }
+
@Test
void 'shebang not on the first line'() {
expectContainsOnce 'x = 1\n#!/usr/bin/env groovy', 'Shebang comment should appear at the first line'