diff options
Diffstat (limited to 'compiler/test/dotty/tools/dotc/ast/TreeInfoTest.scala')
-rw-r--r-- | compiler/test/dotty/tools/dotc/ast/TreeInfoTest.scala | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/compiler/test/dotty/tools/dotc/ast/TreeInfoTest.scala b/compiler/test/dotty/tools/dotc/ast/TreeInfoTest.scala new file mode 100644 index 000000000..a55973c43 --- /dev/null +++ b/compiler/test/dotty/tools/dotc/ast/TreeInfoTest.scala @@ -0,0 +1,30 @@ +package dotty.tools +package dotc +package ast + +import org.junit.Test +import core.Names._ +import core.Types._ +import core.Symbols._ +import org.junit.Assert._ + +class TreeInfoTest extends DottyTest { + + import tpd._ + + @Test + def testDefPath = checkCompile("frontend", "class A { def bar = { val x = { val z = 0; 0} }} ") { + (tree, context) => + implicit val ctx = context + val xTree = tree.find(tree => tree.symbol.name == termName("x")).get + val path = defPath(xTree.symbol, tree) + assertEquals(List( + ("PackageDef", EMPTY_PACKAGE), + ("TypeDef", typeName("A")), + ("Template", termName("<local A>")), + ("DefDef", termName("bar")), + ("Block", NoSymbol.name), + ("ValDef", termName("x")) + ), path.map(x => (x.productPrefix, x.symbol.name))) + } +} |