open Mp6common
let rubric_version = "1.0"
let rubric_title = "CS421 Summer 2009 MP6"

(**************************************************************************
 * You can add new test cases by adding new elements to the following lists
 * Format is:
 * TEST<X>ARG(<weight>, <function_name>, <arg1>, <arg2>, ..., <argX>)
 *
 * <X> is the number of argument that the function being tested takes.
 **************************************************************************)


(* Test cases should go in this list. 
 * The first element of the pair is the weight of the case,
 * and the second is the string to be given to the parser.
 *)

(* This list is for regular problems *)
let test_cases = [

/* expressions */
1, "class A {public int main(int i){ return i;}}";
1, "class A {public int main(int i){ return 5 < 3;}}";
1, "class A {public int main(int i){ return !true;}}";

/* statements */
1, "class A {public int main(int i){ {i=1; i=2;} return i;}}";
1, "class A {public int main(int i){ if(true) i=1; else i=2; return i;}}";
1, "class A {public int main(int i){ System.out.println(i); return i+5;}}";

/* method and class */
1, "class A {public int main(int i){ return dummy.fact(5);} public int fact(int a){ if((a<2)) a=1; else a=a*dummy.fact(a-1); return a; }}"

]

let extra_test_cases = [
]


let parse s = Minijavaparse.program Minijavalex.tokenize (Lexing.from_string s)
let eval_sol s = try Some(Mp6common.execProg (Solution.compile (parse s))) with _ -> None
let eval_stu s = try Some(Mp6common.execProg (Student.compile (parse s)) ) with _ -> None


let mptest weight pair = compare isEq 4 weight pair;;
output := "";;

let rubric = List.map 
             (fun (w,s) -> turnOffShortCircuit(); TEST1ARG_TWOFUN(w, eval_sol, eval_stu, s))
             test_cases;;

let extra_rubric = List.map
             (fun (w,s) -> turnOnShortCircuit(); TEST1ARG_TWOFUN(w, eval_sol, eval_stu, s))
             extra_test_cases
;;


