summaryrefslogtreecommitdiff
path: root/tool-testsuite/test/org/antlr/v4/test/tool/TestATNInterpreter.java
diff options
context:
space:
mode:
Diffstat (limited to 'tool-testsuite/test/org/antlr/v4/test/tool/TestATNInterpreter.java')
-rw-r--r--tool-testsuite/test/org/antlr/v4/test/tool/TestATNInterpreter.java48
1 files changed, 15 insertions, 33 deletions
diff --git a/tool-testsuite/test/org/antlr/v4/test/tool/TestATNInterpreter.java b/tool-testsuite/test/org/antlr/v4/test/tool/TestATNInterpreter.java
index 2309a1c..14e82ae 100644
--- a/tool-testsuite/test/org/antlr/v4/test/tool/TestATNInterpreter.java
+++ b/tool-testsuite/test/org/antlr/v4/test/tool/TestATNInterpreter.java
@@ -1,31 +1,7 @@
/*
- * [The "BSD license"]
- * Copyright (c) 2012 Terence Parr
- * Copyright (c) 2012 Sam Harwell
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. The name of the author may not be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * Copyright (c) 2012-2016 The ANTLR Project. All rights reserved.
+ * Use of this file is governed by the BSD 3-clause license that
+ * can be found in the LICENSE.txt file in the project root.
*/
package org.antlr.v4.test.tool;
@@ -39,11 +15,11 @@ import org.antlr.v4.runtime.atn.BlockStartState;
import org.antlr.v4.runtime.atn.LexerATNSimulator;
import org.antlr.v4.runtime.dfa.DFA;
import org.antlr.v4.runtime.misc.IntegerList;
-import org.antlr.v4.test.runtime.java.BaseTest;
import org.antlr.v4.tool.DOTGenerator;
import org.antlr.v4.tool.Grammar;
import org.antlr.v4.tool.LexerGrammar;
import org.antlr.v4.tool.Rule;
+import org.junit.Before;
import org.junit.Test;
import static org.junit.Assert.assertEquals;
@@ -52,7 +28,13 @@ import static org.junit.Assert.assertEquals;
// NOTICE: TOKENS IN LEXER, PARSER MUST BE SAME OR TOKEN TYPE MISMATCH
// NOTICE: TOKENS IN LEXER, PARSER MUST BE SAME OR TOKEN TYPE MISMATCH
-public class TestATNInterpreter extends BaseTest {
+public class TestATNInterpreter extends BaseJavaToolTest {
+ @Before
+ @Override
+ public void testSetUp() throws Exception {
+ super.testSetUp();
+ }
+
@Test public void testSimpleNoBlock() throws Exception {
LexerGrammar lg = new LexerGrammar(
"lexer grammar L;\n" +
@@ -384,7 +366,7 @@ public class TestATNInterpreter extends BaseTest {
ATN lexatn = createATN(lg, true);
LexerATNSimulator lexInterp = new LexerATNSimulator(lexatn,new DFA[] { new DFA(lexatn.modeToStartState.get(Lexer.DEFAULT_MODE)) },null);
IntegerList types = getTokenTypesViaATN(inputString, lexInterp);
- System.out.println(types);
+// System.out.println(types);
g.importVocab(lg);
@@ -392,7 +374,7 @@ public class TestATNInterpreter extends BaseTest {
ATN atn = f.createATN();
IntTokenStream input = new IntTokenStream(types);
- System.out.println("input="+input.types);
+// System.out.println("input="+input.types);
ParserInterpreterForTesting interp = new ParserInterpreterForTesting(g, input);
ATNState startState = atn.ruleToStartState[g.getRule("a").index];
if ( startState.transition(0).target instanceof BlockStartState ) {
@@ -400,9 +382,9 @@ public class TestATNInterpreter extends BaseTest {
}
DOTGenerator dot = new DOTGenerator(g);
- System.out.println(dot.getDOT(atn.ruleToStartState[g.getRule("a").index]));
+// System.out.println(dot.getDOT(atn.ruleToStartState[g.getRule("a").index]));
Rule r = g.getRule("e");
- if ( r!=null ) System.out.println(dot.getDOT(atn.ruleToStartState[r.index]));
+// if ( r!=null ) System.out.println(dot.getDOT(atn.ruleToStartState[r.index]));
int result = interp.matchATN(input, startState);
assertEquals(expected, result);