open Mp5common
let rubric_version = "1.0"
let rubric_title = "CS421 Summer 2013 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.
 **************************************************************************)

let infer tree = Mp5common.canon (Mp5common.infer Solution.gather_ty_substitution [] tree);;
let infer_stu tree =
    Mp5common.canon (Mp5common.infer Student.gather_ty_substitution  [] tree);;

let infer2 gamma tree =
    Mp5common.canon (Mp5common.infer Solution.gather_ty_substitution gamma tree);;
let infer2_stu gamma tree =
    Mp5common.canon (Mp5common.infer Student.gather_ty_substitution  gamma tree);;

(* environment *)
let env0 = [];;
let env1 = make_env "f" ([0], mk_fun_ty bool_ty (TyVar 0));;

(* simple expressions *)
let con_exp1 = ConExp(Bool true);;
let var_exp1 = VarExp "f";;
let bin_exp1 = BinExp(Cons, ConExp (Int 62), ConExp Nil);;
let mon_exp1 = MonExp(Print, ConExp(Int 62));;
let if_exp1 = IfExp(ConExp(Bool true), ConExp(Int 62), ConExp(Int 252));;
let fun_exp1 = FunExp("x", BinExp(Add, VarExp "x", VarExp "x"));;
let app_exp1 = AppExp((FunExp("x", BinExp(Add, VarExp "x", VarExp "x"))), ConExp(Int 62));;
let let_exp1 = LetExp("y", ConExp(Int 5), BinExp(Add, VarExp "y", VarExp "y"));;
let rec_exp1 =
	RecExp("fact", "n",
		IfExp(
			BinExp(Eq, VarExp "n", ConExp(Int 0)),
			ConExp(Int 1),
			BinExp(Mul, VarExp "n", AppExp(VarExp "fact", BinExp(Sub, VarExp "n", ConExp(Int 1))))),
		AppExp(VarExp "fact", ConExp(Int 5)));;
let raise_exp1 = RaiseExp(IfExp(ConExp(Bool true), ConExp(Int 62), ConExp(Int 252)));;
let try_exp1 =
	TryWithExp(
		BinExp(Concat, ConExp(String "What"), RaiseExp(ConExp(Int 3))),
		(Some 0, ConExp(String " do you mean?")),
		[
			(None, ConExp(String " in the world?"))
		]);;


(* This list is for regular problems *)
let rubric =
[
	TEST2ARG_TWOFUN(0, infer2, infer2_stu, env0, con_exp1);

	TEST2ARG_TWOFUN(1, infer2, infer2_stu, env1, var_exp1);

	TEST2ARG_TWOFUN(1, infer2, infer2_stu, env0, bin_exp1);
	TEST2ARG_TWOFUN(1, infer2, infer2_stu, env0, mon_exp1);

	TEST2ARG_TWOFUN(1, infer2, infer2_stu, env0, if_exp1);

	TEST2ARG_TWOFUN(1, infer2, infer2_stu, env0, fun_exp1);

	TEST2ARG_TWOFUN(1, infer2, infer2_stu, env0, app_exp1);

	TEST2ARG_TWOFUN(1, infer2, infer2_stu, env0, let_exp1);

	TEST2ARG_TWOFUN(1, infer2, infer2_stu, env0, rec_exp1);

	TEST2ARG_TWOFUN(1, infer2, infer2_stu, env0, raise_exp1);
]

(* This list is for extra credit problems *)
let extra_rubric = [
	TEST2ARG_TWOFUN(1, infer2, infer2_stu, env0, try_exp1);
]

