Add a mechanism for converting user input to custom types
See original GitHub issueFor writing our own exercises and specially for third party libraries’ exercises we need a way to specify how to convert an input string from the user to an arbitrary type. Built-in types like String
or Int
are supported but we often have exercises like this:
def anExercise(res0: Xor.Right[String, Int]) = {
val right: String Xor Int = Xor.Right(42)
right should be(res0)
}
We can’t currently convert an user-provided input to a cats.data.Xor
and we should be able to do so. Same for the every type constructors that cats or other libraries provide.
Another case that we don’t handle currently is referring to an identifier, see the following example:
def anExercise(res0: ?) = {
val one = 1
val anotherOne = 1
(one == res0) should be(true)
}
Here, we expect the user to insert anotherOne
. The problem is that we don’t want to treat res0
’s content as a string but an identifier that will be resolved to the value it refers to at runtime.
@andyscott feel free to split this into separate issues if you think they should be tackled separately.
@raulraja @rafaparadela @juanpedromoreno feel free to add your comments.
Issue Analytics
- State:
- Created 8 years ago
- Comments:5 (4 by maintainers)
Top GitHub Comments
Will do. I’m in the process of bringing back and rewriting some code from a month ago that addresses this properly.
@andyscott Regarding A. We need to get user input refering to lib types working. I tested that if for example I change…
for
All the shapeless types immediately work. For the time being we should allow at the Lib level provide a set of imports that will be evaluated with each lib exercise along with the user input.
We need to get this working now because it’s preventing from actually properly testing the UI input when trying to reproduce the user experience completing the exercises.
Let’s make this change a high priority.