Created
April 22, 2012 15:24
-
-
Save jroper/2464615 to your computer and use it in GitHub Desktop.
ScalaFlect - The new strongly typed reflection library I'm writing for using in query DSLs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package au.id.jazzy.scalaflect | |
import org.specs2.mutable.Specification | |
object ScalaFlectSpec extends Specification { | |
"ScalaFlect" should { | |
"be able to look up simple case class properties" in { | |
val exampleCaseClass = new ScalaFlect(classOf[ExampleCaseClass]) | |
val member = exampleCaseClass.reflect(_.property) | |
member.toString mustEqual "property" | |
} | |
"be able to follow a path of case class properties" in { | |
val exampleCaseClassParent = new ScalaFlect(classOf[ExampleCaseClassParent]) | |
val member = exampleCaseClassParent.reflect(_.example.property) | |
member.toString mustEqual "example.property" | |
} | |
"be able to look up simple class properties" in { | |
val exampleClass = new ScalaFlect(classOf[ExampleClass]) | |
val member = exampleClass.reflect(_.property) | |
member.toString mustEqual "property" | |
} | |
"be able to follow a path of class properties" in { | |
val exampleClassParent = new ScalaFlect(classOf[ExampleClassParent]) | |
val member = exampleClassParent.reflect(_.example.property) | |
member.toString mustEqual "example.property" | |
} | |
} | |
} | |
case class ExampleCaseClass(property: String) | |
case class ExampleCaseClassParent(example: ExampleCaseClass) | |
class ExampleClass(val property: String) | |
class ExampleClassParent(val example: ExampleClass) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment