Skip to content

Commit

Permalink
Generate example test in test dialect (#185)
Browse files Browse the repository at this point in the history
  • Loading branch information
Atry authored Jan 9, 2023
1 parent ff6141e commit 7d1d8a2
Show file tree
Hide file tree
Showing 6 changed files with 37 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/main/scala/com/thoughtworks/Example.scala
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,7 @@ object Example extends AutoPlugin {

def testTree(tree: Tree): Seq[Stat] = {
def defnTestTree(name: Name, stats: List[Stat]) = {
val title = name.syntax
val title = name.value
val trees =
scaladocTestTree(comments.leading(tree)) :::
stats.flatMap(testTree)
Expand All @@ -264,7 +264,7 @@ object Example extends AutoPlugin {
defnTestTree(name, template.early ::: template.stats)
}
def leafTestTree(name: Name) = {
val title = name.syntax
val title = name.value
val trees = scaladocTestTree(comments.leading(tree))
if (trees.isEmpty) {
Nil
Expand Down Expand Up @@ -485,7 +485,7 @@ object Example extends AutoPlugin {
"""
IO.write(
outputFile,
generatedFileTree.syntax,
(testDialect, generatedFileTree).syntax,
scala.io.Codec.UTF8.charSet
)
Seq(outputFile)
Expand Down
10 changes: 10 additions & 0 deletions src/sbt-test/sbt-example/scala3-keyword-then/build.sbt
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
enablePlugins(Example)

enablePlugins(ScalaJSPlugin)

libraryDependencies += "org.scalatest" %% "scalatest" % "3.2.14" % Provided

import scala.meta._
exampleSuperTypes += init"_root_.org.scalatest.Inside"

scalaVersion := "3.2.1"
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
sbt.version=1.7.3
10 changes: 10 additions & 0 deletions src/sbt-test/sbt-example/scala3-keyword-then/project/plugins.sbt
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
sys.props.get("plugin.version") match {
case Some(x) => addSbtPlugin("com.thoughtworks.example" % "sbt-example" % x)
case _ =>
sys.error(
"""|The system property 'plugin.version' is not defined.
|Specify this property using the scriptedLaunchOpts -D.""".stripMargin
)
}

addSbtPlugin("org.scala-js" % "sbt-scalajs" % "1.12.0")
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@


/** Testing Scala 3 keyword
* @example
* Call to `then` should compile
* {{{
* import scala.scalajs.js
* js.Promise.resolve(40).`then`(_ + 2)
* }}}
*/
object Scala3KeywordThen
2 changes: 2 additions & 0 deletions src/sbt-test/sbt-example/scala3-keyword-then/test
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
> test
$ exists target/scala-3.2.1/src_managed/test/sbt-example-generated.scala

0 comments on commit 7d1d8a2

Please sign in to comment.