refactored to make more testable

This commit is contained in:
Tony Tam
2012-09-23 12:18:22 -07:00
parent d6cf7fc9aa
commit cec3fa5810
7 changed files with 192 additions and 43 deletions

View File

@@ -93,6 +93,25 @@ class BasicScalaGeneratorTest extends FlatSpec with ShouldMatchers {
config.toDeclaredType("object") should be ("Any")
}
/*
* declarations are used in models, and types need to be
* mapped appropriately
*/
it should "convert a string a declaration" in {
val expected = Map("string" -> ("String", "_"),
"int" -> ("Int", "0"),
"float" -> ("Float", "0f"),
"long" -> ("Long", "0L"),
"double" -> ("Double", "0.0"),
"object" -> ("Any", "_"))
expected.map(e => {
val model = new DocumentationSchema
model.name = "simple_" + e._1
model.setType(e._1)
config.toDeclaration(model) should be (e._2)
})
}
/*
* codegen should honor special imports to avoid generating
* classes