diff options
Diffstat (limited to 'test/junit')
-rw-r--r-- | test/junit/scala/reflect/internal/TreeGenTest.scala | 51 | ||||
-rw-r--r-- | test/junit/scala/tools/nsc/symtab/SymbolTableForUnitTesting.scala | 4 |
2 files changed, 54 insertions, 1 deletions
diff --git a/test/junit/scala/reflect/internal/TreeGenTest.scala b/test/junit/scala/reflect/internal/TreeGenTest.scala new file mode 100644 index 0000000000..db1ea5cf6a --- /dev/null +++ b/test/junit/scala/reflect/internal/TreeGenTest.scala @@ -0,0 +1,51 @@ +package scala.reflect.internal + +import org.junit.Assert._ +import org.junit.Test +import org.junit.runner.RunWith +import org.junit.runners.JUnit4 + +import scala.runtime.ScalaRunTime +import scala.tools.nsc.symtab.SymbolTableForUnitTesting + +@RunWith(classOf[JUnit4]) +class TreeGenTest { + object symbolTable extends SymbolTableForUnitTesting + + import symbolTable._ + + @Test + def attributedRefToTopLevelMemberNotPrefixedByThis_t9473_a(): Unit = { + val SomeClass = symbolOf[Some[_]] + val ref = gen.mkAttributedRef(SomeClass) + assertEquals("scala.Some", ref.toString) // was scala.this.Some + ref match { + case sel @ Select(pre @ Ident(preName), name) => + assertEquals(TermName("scala"), preName) + assertEquals(TypeName("Some"), name) + assertEquals(SomeClass, sel.symbol) + case _ => fail(showRaw(ref)) + } + } + + @Test + def attributedRefToTopLevelMemberNotPrefixedByThis_t9473_b(): Unit = { + val ScalaRuntimeModule = symbolOf[ScalaRunTime.type].sourceModule + val ref = gen.mkAttributedRef(ScalaRuntimeModule) + assertEquals("scala.runtime.ScalaRunTime", ref.toString) + ref match { + case sel @ Select(Select(Ident(TermName("scala")), TermName("runtime")), TermName("ScalaRunTime")) => + case _ => fail(showRaw(ref)) + } + } + @Test + def attributedRefToTopLevelMemberNotPrefixedByThis_t9473_c(): Unit = { + val DummyImplicitClass = symbolOf[Predef.DummyImplicit] + val ref = gen.mkAttributedRef(DummyImplicitClass) + assertEquals("scala.Predef.DummyImplicit", ref.toString) +// ref match { +// case sel @ Select(Select(Ident(TermName("scala")), TermName("runtime")), TermName("ScalaRunTime")) => +// case _ => fail(showRaw(ref)) +// } + } +} diff --git a/test/junit/scala/tools/nsc/symtab/SymbolTableForUnitTesting.scala b/test/junit/scala/tools/nsc/symtab/SymbolTableForUnitTesting.scala index f0f20acf07..365901c4d6 100644 --- a/test/junit/scala/tools/nsc/symtab/SymbolTableForUnitTesting.scala +++ b/test/junit/scala/tools/nsc/symtab/SymbolTableForUnitTesting.scala @@ -119,7 +119,9 @@ class SymbolTableForUnitTesting extends SymbolTable { } phasesArray } - lazy val treeInfo: scala.reflect.internal.TreeInfo{val global: SymbolTableForUnitTesting.this.type} = ??? + lazy val treeInfo = new scala.reflect.internal.TreeInfo { + val global: SymbolTableForUnitTesting.this.type = SymbolTableForUnitTesting.this + } val currentFreshNameCreator = new reflect.internal.util.FreshNameCreator |