Coverage Summary for Class: Expr (dev.suresh)
  | Class | 
  Method, %
 | 
  Branch, %
 | 
  Line, %
 | 
  Instruction, %
 | 
  | Expr | 
  
    100%
  
  
    (1/1)
  
 | 
  
    60%
  
  
    (9/15)
  
 | 
  
    72.7%
  
  
    (8/11)
  
 | 
  
    64%
  
  
    (112/175)
  
 | 
  
    | Expr$Add | 
  
    100%
  
  
    (1/1)
  
 | 
     | 
  
    100%
  
  
    (1/1)
  
 | 
  
    100%
  
  
    (19/19)
  
 | 
  
  
    | Expr$Const | 
     | 
  
  
    | Expr$Const$Double | 
  
    100%
  
  
    (1/1)
  
 | 
     | 
  
    100%
  
  
    (1/1)
  
 | 
  
    100%
  
  
    (14/14)
  
 | 
  
  
    | Expr$Const$Int | 
  
    100%
  
  
    (1/1)
  
 | 
     | 
  
    100%
  
  
    (1/1)
  
 | 
  
    100%
  
  
    (14/14)
  
 | 
  
  
    | Expr$Const$Long | 
  
    100%
  
  
    (1/1)
  
 | 
     | 
  
    100%
  
  
    (1/1)
  
 | 
  
    100%
  
  
    (14/14)
  
 | 
  
  
    | Expr$Const$Str | 
  
    0%
  
  
    (0/1)
  
 | 
     | 
  
    0%
  
  
    (0/1)
  
 | 
  
    0%
  
  
    (0/14)
  
 | 
  
  
    | Expr$Div | 
  
    100%
  
  
    (1/1)
  
 | 
     | 
  
    100%
  
  
    (1/1)
  
 | 
  
    100%
  
  
    (19/19)
  
 | 
  
  
    | Expr$Mul | 
  
    0%
  
  
    (0/1)
  
 | 
     | 
  
    0%
  
  
    (0/1)
  
 | 
  
    0%
  
  
    (0/19)
  
 | 
  
  
    | Expr$Neg | 
  
    0%
  
  
    (0/1)
  
 | 
     | 
  
    0%
  
  
    (0/1)
  
 | 
  
    0%
  
  
    (0/14)
  
 | 
  
  | Total | 
  
    66.7%
  
  
    (6/9)
  
 | 
  
    60%
  
  
    (9/15)
  
 | 
  
    68.4%
  
  
    (13/19)
  
 | 
  
    63.6%
  
  
    (192/302)
  
 | 
 package dev.suresh;
 
 import org.jspecify.annotations.NullMarked;
 
 @NullMarked
 public sealed interface Expr {
     record Add(Expr left, Expr right) implements Expr {}
 
     record Mul(Expr left, Expr right) implements Expr {}
 
     record Div(Expr left, Expr right) implements Expr {}
 
     record Neg(Expr e) implements Expr {}
 
     sealed interface Const extends Expr {
         record Int(int i) implements Const {}
 
         record Double(double d) implements Const {}
 
         record Long(long l) implements Const {}
 
         record Str(String s) implements Const {}
     }
 
     static long eval(Expr expr) {
         return switch (expr) {
             case Expr.Add(var l, var r) -> eval(l) + eval(r);
             case Expr.Mul(var l, var r) -> eval(l) * eval(r);
             case Expr.Div(var l, var r) -> eval(l) / eval(r);
             case Expr.Neg(var e) -> -eval(e);
             case Expr.Const c ->
                 switch (c) {
                     case Expr.Const.Int(var i) -> i;
                     case Expr.Const.Double(var d) -> (long) d;
                     case Expr.Const.Long(var l) -> l;
                     case Expr.Const.Str(var s) -> Long.parseLong(s);
                 };
         };
     }
 }