From a3a9fd71200074f7322352a1b6156506b48647d7 Mon Sep 17 00:00:00 2001 From: "Yang, Bo" Date: Tue, 31 Jan 2023 18:09:21 -0800 Subject: [PATCH] Generate tests from Scaladoc for Decl (#199) --- src/main/scala/com/thoughtworks/Example.scala | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/main/scala/com/thoughtworks/Example.scala b/src/main/scala/com/thoughtworks/Example.scala index 52c1a3a..156c0b3 100644 --- a/src/main/scala/com/thoughtworks/Example.scala +++ b/src/main/scala/com/thoughtworks/Example.scala @@ -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 @@ -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) =>