File tree Expand file tree Collapse file tree 3 files changed +21
-10
lines changed
main/scala/org/scalaexercises/exercises
test/scala/com/fortysevendeg/exercises Expand file tree Collapse file tree 3 files changed +21
-10
lines changed Original file line number Diff line number Diff line change @@ -88,20 +88,13 @@ class Evaluator(timeout: Duration = 20.seconds) {
8888
8989 val errors : Map [Severity , List [CompilationInfo ]] = eval.errors.toMap
9090
91- println(allCode)
92-
93- println(result)
94-
95- println(errors)
96-
9791 result match {
9892 case scala.util.Success (r) ⇒ EvalResult .Success [T ](errors, r, " " )
9993 case scala.util.Failure (t) ⇒ t match {
10094 case e : Eval .CompilerException ⇒ EvalResult .CompilationError (errors)
101- case e ⇒ EvalResult .EvalRuntimeError (errors, None )
95+ case NonFatal (e) ⇒ EvalResult .EvalRuntimeError (errors, Option (RuntimeError (e, None )))
96+ case e ⇒ EvalResult .GeneralError (e)
10297 }
10398 }
104-
10599 }
106-
107100}
Original file line number Diff line number Diff line change 11package org .scalaexercises .runtime
22
3- object ExampleTarget {
3+ import org .scalatest ._
4+
5+ object ExampleTarget extends FlatSpec with Matchers {
46 def intStringMethod (a : Int , b : String ): String = {
57 s " $a$b"
68 }
79
10+ def isOne (a : Int ) = {
11+ a shouldBe 1
12+ }
13+
814 class ExampleException extends Exception (" this is an example exception" )
915
1016 def throwsExceptionMethod () {
Original file line number Diff line number Diff line change @@ -49,6 +49,18 @@ class MethodEvalSpec extends FunSpec with Matchers {
4949 assert(res.toExecutionXor.isRight)
5050 }
5151
52+ it(" fails with assertion error when the parameters are incorrect" ) {
53+ val res = methodEval.eval(
54+ " org.scalaexercises.runtime" ,
55+ " org.scalaexercises.runtime.ExampleTarget.isOne" ,
56+ " 2" :: Nil
57+ )
58+
59+ res should matchPattern {
60+ case EvaluationException (_ : TestFailedException ) ⇒
61+ }
62+ }
63+
5264 it(" captures exceptions thrown by the called method" ) {
5365 val res = methodEval.eval(
5466 " org.scalaexercises.runtime" ,
You can’t perform that action at this time.
0 commit comments