package io.trygvis.ld; import io.trygvis.ld.antlr.GnuLdLexer; import io.trygvis.ld.antlr.GnuLdParser; import org.antlr.v4.runtime.ANTLRInputStream; import org.antlr.v4.runtime.CommonTokenStream; import org.junit.Test; import static org.junit.Assert.assertEquals; public class NameTest { @Test public void testName1() throws Exception { a("foo", "foo"); } @Test public void testName2() throws Exception { a("\"foo bar\"", "foo bar"); } // TODO: not really expected @Test public void testName3() throws Exception { a("\"foo bar\"", "foo bar"); } private void a(String input, String expected) { /* CommonTokenStream tokens = new CommonTokenStream(new GnuLdLexer(new ANTLRInputStream(input))); tokens.fill(); for (Object tok : tokens.getTokens()) { System.out.println(tok); } GnuLdParser parser = new GnuLdParser(tokens); // StringGnuLdVisitor visitor = new StringGnuLdVisitor(); GnuLdParser.NameContext name = parser.name(); System.out.println("Input : |" + input + "|"); System.out.println("String tree: " + name.toStringTree(parser)); // visitor.visit(name); String actual = StringGnuLdVisitor.parseName(name); parser.setTrace(true); assertEquals(input + "\n" + name.toStringTree(), expected, actual); */ } }