open Mp5common
let rubric_version = "1.0"
let rubric_title = "CS421 Summer 2009 MP5"

(**************************************************************************
 * 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 = [
1, "class A { }";
1, "class A { int i; String j; }";
1, "class A { public int m1(){return 0;} }";
1, "class A { int i; public int m1(int a){return 0;} }";
1, "class A { public int m1() { return a.length; }}";
1, "class A { public int m1() { return a.m(arg1); }}";
1, "class A { public int m1() { return a & b & c; }}";
1, "class A { public int m1() { return 3 < 5 + 6; }}";
1, "class A { public int m1() { return a & b < d | c; }}";
1, "class A { public int m1() { return !a.m(); }}";
1, "class A { public int m1() { if(true) if(false) x=1; else x=2; return 1; }}";
1, "class A { public int m1() { while(c) { break; continue; } return 1; }}";
1, "class A { public int m1() { x[1]=2; return 1; }}";
1, "class A { public int m1() { switch(a){case 1: x=1; break; case 2: x=2; default: break;} return 1; }}";
1, "class A { public int m1() { Dummy x; x=1; return 1; }}";
1, "class A { public int m1() { A[] x; x[1]=1; System.out.println(1); return 1; }}";
]


(* This list is for extra credit problems *)
let extra_test_cases = [
]


let parse s = 
  try Some(Solution.program Minijavalex2.tokenize (Lexing.from_string s))
  with Parsing.Parse_error -> None

let parse_stu s = 
  try Some(Student.program  Minijavalex.tokenize  (Lexing.from_string s))
  with Parsing.Parse_error -> None


let rubric = List.map 
             (fun (w,s) -> TEST1ARG_TWOFUN(w, parse, parse_stu, s))
             test_cases


let extra_rubric = List.map 
             (fun (w,s) -> TEST1ARG_TWOFUN(w, parse, parse_stu, s))
             extra_test_cases
