Skip to content

Commit

Permalink
Generate tests from Scaladoc for Decl (#199)
Browse files Browse the repository at this point in the history
  • Loading branch information
Atry authored Feb 1, 2023
1 parent 32e5028 commit a3a9fd7
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion src/main/scala/com/thoughtworks/Example.scala
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,9 @@ object Example extends AutoPlugin {
defnTestTree(name, template.early ::: template.stats)
}
def leafTestTree(name: Name) = {
val title = name.value
titledTestTree(name.value)
}
def titledTestTree(title: String) = {
val trees = scaladocTestTree(comments.leading(tree))
if (trees.isEmpty) {
Nil
Expand All @@ -290,6 +292,15 @@ object Example extends AutoPlugin {
}
case Pkg.Object(_, name, template: Template) =>
templateTestTree(name, template)
case declTree: Decl =>
declTree match {
case declDef: Decl.Def =>
leafTestTree(declDef.name)
case Decl.Val(_, pats, _) =>
titledTestTree(pats.toString())
case Decl.Var(_, pats, _) =>
titledTestTree(pats.toString())
}
case defnTree: Defn =>
defnTree match {
case Defn.Object(_, name, template: Template) =>
Expand Down

0 comments on commit a3a9fd7

Please sign in to comment.