diff options
author | Felix Mulder <felix.mulder@gmail.com> | 2016-05-05 15:22:29 +0200 |
---|---|---|
committer | Felix Mulder <felix.mulder@gmail.com> | 2016-08-19 15:37:22 +0200 |
commit | 8e39b71b29afd7951745dbaf957eade0e9f51434 (patch) | |
tree | 720ab08f15936a8c0cd4cf5da5f792fcdab3150b /dottydoc/jvm/test/PackageStructure.scala | |
parent | bc594c81c6ce8c696dde2f7668132952e83b383a (diff) | |
download | dotty-8e39b71b29afd7951745dbaf957eade0e9f51434.tar.gz dotty-8e39b71b29afd7951745dbaf957eade0e9f51434.tar.bz2 dotty-8e39b71b29afd7951745dbaf957eade0e9f51434.zip |
Fix repeated traversal of packages when generating docs (5x speedup)
Diffstat (limited to 'dottydoc/jvm/test/PackageStructure.scala')
-rw-r--r-- | dottydoc/jvm/test/PackageStructure.scala | 89 |
1 files changed, 89 insertions, 0 deletions
diff --git a/dottydoc/jvm/test/PackageStructure.scala b/dottydoc/jvm/test/PackageStructure.scala new file mode 100644 index 000000000..af6e52184 --- /dev/null +++ b/dottydoc/jvm/test/PackageStructure.scala @@ -0,0 +1,89 @@ +package dotty.tools +package dottydoc + +import org.junit.Test +import org.junit.Assert._ + +import dotc.util.SourceFile +import model.internal._ + +class PackageStructure extends DottyTest { + @Test def multipleCompilationUnits = { + val source1 = new SourceFile( + "<test>", + """ + |package scala + | + |trait A + """.stripMargin + ) + + val source2 = new SourceFile( + "<test>", + """ + |package scala + | + |trait B + """.stripMargin + ) + + checkSources(source1 :: source2 :: Nil) { doc => + doc.packages("scala") match { + case PackageImpl(_, List(tA, tB), _, _) => + assert( + tA.name == "A" && tB.name == "B", + s"trait A had name '${tA.name}' and trait B had name '${tB.name}'" + ) + case _ => fail("Incorrect package structure after run") + } + } + } + + + @Test def multiplePackages = { + val source1 = new SourceFile( + "<test>", + """ + |package scala + |package collection + | + |trait A + """.stripMargin) + + val source2 = new SourceFile( + "<test>", + """ + |package scala + |package collection + | + |trait B + """.stripMargin) + + checkSources(source1 :: source2 :: Nil) { doc => + doc.packages("scala") match { + case PackageImpl( + "scala", + List(PackageImpl("scala.collection", List(tA, tB), _, _)), + _, _ + ) => + assert( + tA.name == "A" && tB.name == "B", + s"trait A had name '${tA.name}' and trait B had name '${tB.name}'" + ) + + case _ => + fail(s"""Incorrect package structure for 'scala' package: ${doc.packages("scala")}""") + } + + doc.packages("scala.collection") match { + case PackageImpl("scala.collection", List(tA, tB), _, _) => + assert( + tA.name == "A" && tB.name == "B", + s"trait A had name '${tA.name}' and trait B had name '${tB.name}'" + ) + + case _ => fail("Incorrect package structure for 'scala.collection' package") + } + } + } +} |