Skip to content

Commit

Permalink
0.7.1: add tests for class name or keys starting with $_
Browse files Browse the repository at this point in the history
  • Loading branch information
carueda committed Dec 15, 2016
1 parent 98c83f7 commit a6e7e08
Show file tree
Hide file tree
Showing 3 changed files with 75 additions and 0 deletions.
2 changes: 2 additions & 0 deletions changelog.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
2016-12-14 - 0.7.1

- add tests for class name or keys starting with `$_`
- fix #19 "quoted keys"
- use simpler, equivalent boolean access expression according to given default
- fixed: spec with literal values were not generating "primitive" types
Expand Down
36 changes: 36 additions & 0 deletions src/test/scala/tscfg/generators/java/JavaMainSpec.scala
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,11 @@ package tscfg.generators.java
import com.typesafe.config.ConfigFactory
import org.specs2.mutable.Specification
import tscfg.example._
import tscfg.generators.GenOpts
import tscfg.model
import tscfg.model._
import model.implicits._


class JavaMainSpec extends Specification {
import scala.collection.JavaConversions._
Expand Down Expand Up @@ -314,4 +319,35 @@ class JavaMainSpec extends Specification {
c._$_foo_ === "some string"
}
}

"given class name starting with $_" should {
"generate warning" in {
val genOpts = GenOpts("tscfg.example", "Classy", j7 = true)
val r = new JavaGen(genOpts).generate(ObjectType())
r.classNames === Set("Classy")
r.fields === Map()
// TODO actually verify generated warning
}
}

"keys starting with $_" should {
val objectType = ObjectType(
"$_baz" := STRING | "some value",
"other" := ObjectType(
"$_foo" := DOUBLE
)
)

"generate warnings" in {
val genOpts = GenOpts("tscfg.example", "Classy", j7 = true)
val r = new JavaGen(genOpts).generate(objectType)
r.classNames === Set("Classy", "Other")
r.fields === Map(
"$_baz" "java.lang.String",
"other" "Classy.Other",
"$_foo" "double"
)
// TODO actually verify the generated warnings
}
}
}
37 changes: 37 additions & 0 deletions src/test/scala/tscfg/generators/scala/ScalaMainSpec.scala
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,11 @@ package tscfg.generators.scala
import com.typesafe.config.ConfigFactory
import org.specs2.mutable.Specification
import tscfg.example.{ScalaDurationCfg, _}
import tscfg.generators.GenOpts
import tscfg.model
import tscfg.model._
import model.implicits._


class ScalaMainSpec extends Specification {

Expand Down Expand Up @@ -318,4 +323,36 @@ class ScalaMainSpec extends Specification {
c._$_foo_ === "some string"
}
}

"given class name starting with $_" should {
"generate warning" in {
val genOpts = GenOpts("tscfg.example", "Classy", j7 = true)
val r = new ScalaGen(genOpts).generate(ObjectType())
r.classNames === Set("Classy")
r.fields === Map()
// TODO actually verify generated warning
}
}

"keys starting with $_" should {
val objectType = ObjectType(
"$_baz" := STRING | "some value",
"other" := ObjectType(
"$_foo" := DOUBLE
)
)

"generate warnings" in {
val genOpts = GenOpts("tscfg.example", "Classy", j7 = true)
val r = new ScalaGen(genOpts).generate(objectType)

r.classNames === Set("Classy", "Other")
r.fields === Map(
"$_baz" "java.lang.String",
"other" "Classy.Other",
"$_foo" "scala.Double"
)
// TODO actually verify the generated warnings
}
}
}

0 comments on commit a6e7e08

Please sign in to comment.