From 5d8dcf019d5dd6343454f966ddccea224b0033b0 Mon Sep 17 00:00:00 2001 From: Marco Hunsicker Date: Mon, 14 Nov 2016 00:37:41 +0100 Subject: [PATCH] Adds unit tests for the dependency management --- antlr4-maven-plugin/pom.xml | 66 +++- .../org/antlr/mojo/antlr4/Antlr4MojoTest.java | 319 ++++++++++++++++++ .../src/test/projects/importTokens/pom.xml | 27 ++ .../main/antlr4/imports/SimpleLexer.tokens | 3 + .../src/main/antlr4/test/SimpleParser.g4 | 8 + .../src/test/projects/importsCustom/pom.xml | 42 +++ .../importsCustom/src/main/antlr4/Hello.g4 | 4 + .../src/main/antlr4/TestLexer.g4 | 6 + .../src/main/antlr4/TestParser.g4 | 5 + .../src/main/antlr4/imports/TestBaseLexer.g4 | 16 + .../src/test/projects/importsStandard/pom.xml | 27 ++ .../src/main/antlr4/imports/TestBaseLexer.g4 | 16 + .../src/main/antlr4/test/Hello.g4 | 4 + .../src/main/antlr4/test/TestLexer.g4 | 6 + .../src/main/antlr4/test/TestParser.g4 | 5 + 15 files changed, 543 insertions(+), 11 deletions(-) create mode 100644 antlr4-maven-plugin/src/test/java/org/antlr/mojo/antlr4/Antlr4MojoTest.java create mode 100644 antlr4-maven-plugin/src/test/projects/importTokens/pom.xml create mode 100644 antlr4-maven-plugin/src/test/projects/importTokens/src/main/antlr4/imports/SimpleLexer.tokens create mode 100644 antlr4-maven-plugin/src/test/projects/importTokens/src/main/antlr4/test/SimpleParser.g4 create mode 100644 antlr4-maven-plugin/src/test/projects/importsCustom/pom.xml create mode 100644 antlr4-maven-plugin/src/test/projects/importsCustom/src/main/antlr4/Hello.g4 create mode 100644 antlr4-maven-plugin/src/test/projects/importsCustom/src/main/antlr4/TestLexer.g4 create mode 100644 antlr4-maven-plugin/src/test/projects/importsCustom/src/main/antlr4/TestParser.g4 create mode 100644 antlr4-maven-plugin/src/test/projects/importsCustom/src/main/antlr4/imports/TestBaseLexer.g4 create mode 100644 antlr4-maven-plugin/src/test/projects/importsStandard/pom.xml create mode 100644 antlr4-maven-plugin/src/test/projects/importsStandard/src/main/antlr4/imports/TestBaseLexer.g4 create mode 100644 antlr4-maven-plugin/src/test/projects/importsStandard/src/main/antlr4/test/Hello.g4 create mode 100644 antlr4-maven-plugin/src/test/projects/importsStandard/src/main/antlr4/test/TestLexer.g4 create mode 100644 antlr4-maven-plugin/src/test/projects/importsStandard/src/main/antlr4/test/TestParser.g4 diff --git a/antlr4-maven-plugin/pom.xml b/antlr4-maven-plugin/pom.xml index b3dfd37e9..4c7eecbb5 100644 --- a/antlr4-maven-plugin/pom.xml +++ b/antlr4-maven-plugin/pom.xml @@ -48,6 +48,11 @@ 2009 + + 3.3.9 + 1.12.2 + + ' ; +CDSect : '' ; + +fragment +Whitespace : ' ' | '\n' | '\t' | '\r' ; + +fragment +Hexdigit : [a-fA-F0-9] ; + +fragment +Digit : [0-9] ; diff --git a/antlr4-maven-plugin/src/test/projects/importsStandard/pom.xml b/antlr4-maven-plugin/src/test/projects/importsStandard/pom.xml new file mode 100644 index 000000000..6d532b781 --- /dev/null +++ b/antlr4-maven-plugin/src/test/projects/importsStandard/pom.xml @@ -0,0 +1,27 @@ + + 4.0.0 + imports.standard + importsStandard + 1.0-SNAPSHOT + jar + Test importing, standard layout + + + junit + junit + 4.11 + test + + + + + + antlr4-maven-plugin + + + + + + diff --git a/antlr4-maven-plugin/src/test/projects/importsStandard/src/main/antlr4/imports/TestBaseLexer.g4 b/antlr4-maven-plugin/src/test/projects/importsStandard/src/main/antlr4/imports/TestBaseLexer.g4 new file mode 100644 index 000000000..5fcc6d353 --- /dev/null +++ b/antlr4-maven-plugin/src/test/projects/importsStandard/src/main/antlr4/imports/TestBaseLexer.g4 @@ -0,0 +1,16 @@ +lexer grammar TestBaseLexer; + +tokens { Name } + +// Default "mode": Everything OUTSIDE of a tag +Comment : '' ; +CDSect : '' ; + +fragment +Whitespace : ' ' | '\n' | '\t' | '\r' ; + +fragment +Hexdigit : [a-fA-F0-9] ; + +fragment +Digit : [0-9] ; diff --git a/antlr4-maven-plugin/src/test/projects/importsStandard/src/main/antlr4/test/Hello.g4 b/antlr4-maven-plugin/src/test/projects/importsStandard/src/main/antlr4/test/Hello.g4 new file mode 100644 index 000000000..e38ac8781 --- /dev/null +++ b/antlr4-maven-plugin/src/test/projects/importsStandard/src/main/antlr4/test/Hello.g4 @@ -0,0 +1,4 @@ +grammar Hello; +r : 'hello' ID ; +ID : [a-z]+ ; +WS : [ \r\t\n]+ -> skip ; \ No newline at end of file diff --git a/antlr4-maven-plugin/src/test/projects/importsStandard/src/main/antlr4/test/TestLexer.g4 b/antlr4-maven-plugin/src/test/projects/importsStandard/src/main/antlr4/test/TestLexer.g4 new file mode 100644 index 000000000..668b76496 --- /dev/null +++ b/antlr4-maven-plugin/src/test/projects/importsStandard/src/main/antlr4/test/TestLexer.g4 @@ -0,0 +1,6 @@ +lexer grammar TestLexer; + +import TestBaseLexer; + +WS : Whitespace+ -> skip; +TEXT : ~[<&]+ ; // match any 16 bit char other than < and & \ No newline at end of file diff --git a/antlr4-maven-plugin/src/test/projects/importsStandard/src/main/antlr4/test/TestParser.g4 b/antlr4-maven-plugin/src/test/projects/importsStandard/src/main/antlr4/test/TestParser.g4 new file mode 100644 index 000000000..5c25961e1 --- /dev/null +++ b/antlr4-maven-plugin/src/test/projects/importsStandard/src/main/antlr4/test/TestParser.g4 @@ -0,0 +1,5 @@ +parser grammar TestParser; + +options { tokenVocab=TestLexer; } + +document : (Comment | Name) EOF ; \ No newline at end of file