Simulation not allowed to exit the test

Dear Support ,

I have already written the code and the code is getting executed successfully … For some reason while coming out of the simulation test, It says it is not completed yet… Can you please have a kindly check from your expertise point of view, Is there any gap ?.. thanks!

abstract class Expression
case class Var(name: String) extends Expression
case class Number(num: Double) extends Expression
case class UnOp(operator: String, arg: Expression) extends Expression
case class BinOp(operator: String, left: Expression, right: Expression) extends Expression

object CaseClassMatching extends App {

def describe(exp: Expression): String =
  exp match {
    case Var(_) => "It is a string expression"
    case Number(d) => "It is a number"
    case UnOp(op, arg) => "It is a unary expression"
    case BinOp(op, left, right) => "It is a binary operation"
    //case _ => "Invalid Expression"
  }
val op = BinOp("+", Number(1), Number(4))
println(describe(op))

}

What’s your problem exactly? Can you give some more details please…

When I run your code I see

It is a binary operation

which is what I would have expected.

Thanks for the attempt… this has fixed…

What was the fix?

(When asking questions on the Internet, even if you manage to fix the problem yourself, it’s always polite to say what the solution was, in case someone else runs into the same thing.)

1 Like

this bunch of code to get inside the App {

abstract class Expression
case class Var(name: String) extends Expression
case class Number(num: Double) extends Expression
case class UnOp(operator: String, arg: Expression) extends Expression
case class BinOp(operator: String, left: Expression, right: Expression) extends Expression