aboutsummaryrefslogblamecommitdiff
path: root/dottydoc/test/WhitelistedStdLib.scala
blob: 48697ea7f17b4ac6a8aeae6fc010c19786bd3550 (plain) (tree)
1
2
3
4
5
6
7


                   

                         
 
                                                    












                                                                           
                                   


                                   

                                                             
 

                                               

                                            


                                   









                                                                 
 
package dotty.tools
package dottydoc

import org.junit.Test
import org.junit.Assert._

class TestWhitelistedCollections extends DottyTest {
  val files: List[String] = {
    val whitelist = "./test/dotc/scala-collections.whitelist"

    scala.io.Source.fromFile(whitelist, "UTF8")
      .getLines()
      .map(_.trim) // allow identation
      .filter(!_.startsWith("#")) // allow comment lines prefixed by #
      .map(_.takeWhile(_ != '#').trim) // allow comments in the end of line
      .filter(_.nonEmpty)
      .filterNot(_.endsWith("package.scala"))
      .toList
  }

  @Test def arrayHasDocumentation =
    checkFiles(files) { packages =>
      val array =
        packages("scala")
        .children.find(_.path.mkString(".") == "scala.Array")
        .get

      assert(array.comment.get.body.length > 0)
    }

  @Test def traitImmutableHasDocumentation =
    checkFiles(files) { packages =>
      val imm =
        packages("scala")
        .children.find(_.path.mkString(".") == "scala.Immutable")
        .get

      assert(
        imm.kind == "trait" && imm.name == "Immutable",
        "Found wrong `Immutable`")
      assert(
        imm.comment.map(_.body).get.length > 0,
        "Imm did not have a comment with length > 0")
    }
}