forked from jasder/antlr
Remove files which were unintentionally duplicated in commit 0c7df237
This commit is contained in:
parent
4455d526fe
commit
6865fd6869
|
@ -1,12 +0,0 @@
|
|||
package org.antlr.v4.test.runtime.java;
|
||||
|
||||
public class AbstractParserTestMethod extends JUnitTestMethod {
|
||||
|
||||
public String startRule;
|
||||
|
||||
public AbstractParserTestMethod(String name, String grammarName, String startRule) {
|
||||
super(name, grammarName, null, null, null, null);
|
||||
this.startRule = startRule;
|
||||
}
|
||||
|
||||
}
|
|
@ -1,35 +0,0 @@
|
|||
package org.antlr.v4.test.runtime.java;
|
||||
|
||||
import org.stringtemplate.v4.STGroup;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
public class CompositeLexerTestMethod extends LexerTestMethod {
|
||||
|
||||
public Grammar[] slaveGrammars;
|
||||
|
||||
public CompositeLexerTestMethod(String name, String grammarName,
|
||||
String input, String expectedOutput,
|
||||
String expectedErrors, String ... slaves) {
|
||||
super(name, grammarName, input, expectedOutput, expectedErrors, null);
|
||||
this.slaveGrammars = new Grammar[slaves.length];
|
||||
for(int i=0;i<slaves.length;i++)
|
||||
this.slaveGrammars[i] = new Grammar(name + "_" + slaves[i], slaves[i]);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void loadGrammars(File grammarDir, String testFileName) throws Exception {
|
||||
for(Grammar slave : slaveGrammars)
|
||||
slave.load(new File(grammarDir, testFileName));
|
||||
super.loadGrammars(grammarDir, testFileName);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void generateGrammars(STGroup group) {
|
||||
for(Grammar slave : slaveGrammars)
|
||||
slave.generate(group);
|
||||
super.generateGrammars(group);
|
||||
}
|
||||
|
||||
}
|
|
@ -1,36 +0,0 @@
|
|||
package org.antlr.v4.test.runtime.java;
|
||||
|
||||
import org.stringtemplate.v4.STGroup;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
public class CompositeParserTestMethod extends ParserTestMethod {
|
||||
|
||||
public Grammar[] slaveGrammars;
|
||||
public boolean slaveIsLexer = false;
|
||||
|
||||
public CompositeParserTestMethod(String name, String grammarName,
|
||||
String startRule, String input, String expectedOutput,
|
||||
String expectedErrors, String ... slaves) {
|
||||
super(name, grammarName, startRule, input, expectedOutput, expectedErrors);
|
||||
this.slaveGrammars = new Grammar[slaves.length];
|
||||
for(int i=0;i<slaves.length;i++)
|
||||
this.slaveGrammars[i] = new Grammar(name + "_" + slaves[i], slaves[i]);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void loadGrammars(File grammarDir, String testFileName) throws Exception {
|
||||
for(Grammar slave : slaveGrammars)
|
||||
slave.load(new File(grammarDir, testFileName));
|
||||
super.loadGrammars(grammarDir, testFileName);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void generateGrammars(STGroup group) {
|
||||
for(Grammar slave : slaveGrammars)
|
||||
slave.generate(group);
|
||||
super.generateGrammars(group);
|
||||
}
|
||||
|
||||
}
|
|
@ -1,25 +0,0 @@
|
|||
package org.antlr.v4.test.runtime.java;
|
||||
|
||||
import org.stringtemplate.v4.STGroup;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
public class ConcreteParserTestMethod extends JUnitTestMethod {
|
||||
|
||||
public String baseName;
|
||||
|
||||
public ConcreteParserTestMethod(String name, String input, String expectedOutput,
|
||||
String expectedErrors, Integer index) {
|
||||
super(name, null, input, expectedOutput, expectedErrors, index);
|
||||
this.baseName = name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void loadGrammars(File grammarDir, String testFileName) throws Exception {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void generateGrammars(STGroup group) {
|
||||
}
|
||||
|
||||
}
|
File diff suppressed because it is too large
Load Diff
|
@ -1,51 +0,0 @@
|
|||
package org.antlr.v4.test.runtime.java;
|
||||
|
||||
import org.stringtemplate.v4.ST;
|
||||
import org.stringtemplate.v4.STGroup;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.InputStream;
|
||||
|
||||
public class Grammar {
|
||||
|
||||
public String fileName;
|
||||
public String grammarName;
|
||||
public String[] lines;
|
||||
public ST template;
|
||||
|
||||
public Grammar(String fileName, String grammarName) {
|
||||
this.fileName = fileName;
|
||||
this.grammarName = grammarName;
|
||||
}
|
||||
|
||||
public void load(File grammarDir) throws Exception {
|
||||
template = loadGrammar(grammarDir, fileName);
|
||||
}
|
||||
|
||||
protected ST loadGrammar(File grammarDir, String grammarFileName) throws Exception {
|
||||
File file = new File(grammarDir, grammarFileName + ".st");
|
||||
InputStream input = new FileInputStream(file);
|
||||
try {
|
||||
byte[] data = new byte[(int)file.length()];
|
||||
int next = 0;
|
||||
while(input.available()>0) {
|
||||
int read = input.read(data, next, data.length - next);
|
||||
next += read;
|
||||
}
|
||||
String s = new String(data);
|
||||
return new ST(s);
|
||||
} finally {
|
||||
input.close();
|
||||
}
|
||||
}
|
||||
|
||||
public void generate(STGroup group) {
|
||||
template.add("grammarName", grammarName);
|
||||
template.groupThatCreatedThisInstance = group; // so templates get interpreted
|
||||
lines = template.render().split("\n");
|
||||
for(int i=0;i<lines.length;i++)
|
||||
lines[i] = Generator.escape(lines[i]);
|
||||
}
|
||||
|
||||
}
|
|
@ -1,101 +0,0 @@
|
|||
package org.antlr.v4.test.runtime.java;
|
||||
|
||||
import org.stringtemplate.v4.ST;
|
||||
import org.stringtemplate.v4.STGroup;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class JUnitTestFile {
|
||||
|
||||
List<JUnitTestMethod> unitTests = new ArrayList<JUnitTestMethod>();
|
||||
public String name;
|
||||
public List<String> tests = new ArrayList<String>();
|
||||
public boolean importErrorQueue = false;
|
||||
public boolean importGrammar = false;
|
||||
|
||||
public JUnitTestFile(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public ParserTestMethod addParserTest(File grammarDir, String name, String grammarName, String methodName,
|
||||
String input, String expectedOutput, String expectedErrors) throws Exception {
|
||||
ParserTestMethod tm = new ParserTestMethod(name, grammarName, methodName, input, expectedOutput, expectedErrors);
|
||||
tm.loadGrammars(grammarDir, this.name);
|
||||
unitTests.add(tm);
|
||||
return tm;
|
||||
}
|
||||
|
||||
public AbstractParserTestMethod addParserTests(File grammarDir, String name, String grammarName, String methodName,
|
||||
String ... inputsAndOuputs) throws Exception {
|
||||
AbstractParserTestMethod tm = new AbstractParserTestMethod(name, grammarName, methodName);
|
||||
tm.loadGrammars(grammarDir, this.name);
|
||||
unitTests.add(tm);
|
||||
for(int i=0; i<inputsAndOuputs.length; i+=2) {
|
||||
ConcreteParserTestMethod cm = new ConcreteParserTestMethod(name,
|
||||
inputsAndOuputs[i], inputsAndOuputs[i+1], null,
|
||||
1 + (i/2));
|
||||
unitTests.add(cm);
|
||||
}
|
||||
return tm;
|
||||
}
|
||||
|
||||
public AbstractParserTestMethod addParserTestsWithErrors(File grammarDir, String name, String grammarName, String methodName,
|
||||
String ... inputsOuputsAndErrors) throws Exception {
|
||||
AbstractParserTestMethod tm = new AbstractParserTestMethod(name, grammarName, methodName);
|
||||
tm.loadGrammars(grammarDir, this.name);
|
||||
unitTests.add(tm);
|
||||
for(int i=0; i<inputsOuputsAndErrors.length; i+=3) {
|
||||
ConcreteParserTestMethod cm = new ConcreteParserTestMethod(name,
|
||||
inputsOuputsAndErrors[i], inputsOuputsAndErrors[i+1], inputsOuputsAndErrors[i+2],
|
||||
1 + (i/3));
|
||||
unitTests.add(cm);
|
||||
}
|
||||
return tm;
|
||||
}
|
||||
|
||||
public CompositeParserTestMethod addCompositeParserTest(File grammarDir, String name, String grammarName, String methodName,
|
||||
String input, String expectedOutput, String expectedErrors, String ... slaves) throws Exception {
|
||||
CompositeParserTestMethod tm = new CompositeParserTestMethod(name, grammarName, methodName, input, expectedOutput, expectedErrors, slaves);
|
||||
tm.loadGrammars(grammarDir, this.name);
|
||||
unitTests.add(tm);
|
||||
return tm;
|
||||
}
|
||||
|
||||
public LexerTestMethod addLexerTest(File grammarDir, String name, String grammarName,
|
||||
String input, String expectedOutput, String expectedErrors) throws Exception {
|
||||
return addLexerTest(grammarDir, name, grammarName, input, expectedOutput, expectedErrors, null);
|
||||
}
|
||||
|
||||
public LexerTestMethod addLexerTest(File grammarDir, String name, String grammarName,
|
||||
String input, String expectedOutput, String expectedErrors, Integer index) throws Exception {
|
||||
LexerTestMethod tm = new LexerTestMethod(name, grammarName, input, expectedOutput, expectedErrors, index);
|
||||
tm.loadGrammars(grammarDir, this.name);
|
||||
unitTests.add(tm);
|
||||
return tm;
|
||||
}
|
||||
|
||||
public CompositeLexerTestMethod addCompositeLexerTest(File grammarDir, String name, String grammarName,
|
||||
String input, String expectedOutput, String expectedErrors, String ... slaves) throws Exception {
|
||||
CompositeLexerTestMethod tm = new CompositeLexerTestMethod(name, grammarName, input, expectedOutput, expectedErrors, slaves);
|
||||
tm.loadGrammars(grammarDir, this.name);
|
||||
unitTests.add(tm);
|
||||
return tm;
|
||||
}
|
||||
|
||||
public void generateUnitTests(STGroup group) {
|
||||
for(JUnitTestMethod tm : unitTests) {
|
||||
tm.generateGrammars(group);
|
||||
String name = tm.getClass().getSimpleName();
|
||||
ST template = group.getInstanceOf(name);
|
||||
template.add("test", tm);
|
||||
tests.add(template.render());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -1,34 +0,0 @@
|
|||
package org.antlr.v4.test.runtime.java;
|
||||
|
||||
import org.stringtemplate.v4.STGroup;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
public abstract class JUnitTestMethod {
|
||||
|
||||
public String name;
|
||||
public Grammar grammar;
|
||||
public String afterGrammar;
|
||||
public String input;
|
||||
public String expectedOutput;
|
||||
public String expectedErrors;
|
||||
public boolean debug = false;
|
||||
|
||||
protected JUnitTestMethod(String name, String grammarName, String input,
|
||||
String expectedOutput, String expectedErrors, Integer index) {
|
||||
this.name = name + (index==null ? "" : "_" + index);
|
||||
this.grammar = new Grammar(name, grammarName);
|
||||
this.input = Generator.escape(input);
|
||||
this.expectedOutput = Generator.escape(expectedOutput);
|
||||
this.expectedErrors = Generator.escape(expectedErrors);
|
||||
}
|
||||
|
||||
public void loadGrammars(File grammarDir, String testFileName) throws Exception {
|
||||
grammar.load(new File(grammarDir, testFileName));
|
||||
}
|
||||
|
||||
public void generateGrammars(STGroup group) {
|
||||
grammar.generate(group);
|
||||
}
|
||||
|
||||
}
|
|
@ -1,17 +0,0 @@
|
|||
package org.antlr.v4.test.runtime.java;
|
||||
|
||||
public class LexerTestMethod extends JUnitTestMethod {
|
||||
|
||||
public String[] outputLines;
|
||||
public boolean lexerOnly = true;
|
||||
public boolean showDFA = false;
|
||||
|
||||
public LexerTestMethod(String name, String grammarName, String input,
|
||||
String expectedOutput, String expectedErrors, Integer index) {
|
||||
super(name, grammarName, input, expectedOutput, expectedErrors, index);
|
||||
outputLines = expectedOutput.split("\n");
|
||||
for(int i=0;i<outputLines.length;i++)
|
||||
outputLines[i] = Generator.escape(outputLines[i]);
|
||||
}
|
||||
|
||||
}
|
|
@ -1,13 +0,0 @@
|
|||
package org.antlr.v4.test.runtime.java;
|
||||
|
||||
public class ParserTestMethod extends JUnitTestMethod {
|
||||
|
||||
public String startRule;
|
||||
|
||||
public ParserTestMethod(String name, String grammarName, String startRule,
|
||||
String input, String expectedOutput, String expectedErrors) {
|
||||
super(name, grammarName, input, expectedOutput, expectedErrors, null);
|
||||
this.startRule = startRule;
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue