package scotch.compiler.parser; import static org.hamcrest.Matchers.is; import static org.junit.Assert.assertThat; import static scotch.symbol.Symbol.qualified; import org.antlr.v4.runtime.ParserRuleContext; import org.junit.Test; public class SymbolTransformerTest extends ScotchParserBaseTest { @Test public void shouldTransformQualifiedName() { ParserRuleContext ctx = parseTree(ScotchParser::qualifiedName, "scotch.test.name"); assertThat(new SymbolTransformer().getSymbol(ctx), is(qualified("scotch.test", "name"))); } @Test public void shouldTransformQualifiedType() { ParserRuleContext ctx = parseTree(ScotchParser::qualifiedType, "scotch.test.Type"); assertThat(new SymbolTransformer().getSymbol(ctx), is(qualified("scotch.test", "Type"))); } @Test(expected = TransformException.class) public void shouldThrow_whenTransformingOtherTree() { ParserRuleContext ctx = parseTree(ScotchParser::expression, "(1, 2, 3)"); new SymbolTransformer().getSymbol(ctx); } }