let valid_program =
	{|
struct Item {
	int value;
};

int fold(int[] xs) {
	int total = 0;
	foreach (int x in xs) {
		total = total + x;
	}
	return total;
}

int main() {
	int[] xs;
	struct Item it;
	int y = 2 + 3 * 4;
	it.value = y;
	if (y >= 0) {
		y = fold(xs);
	} else {
		y = 0;
	}
	return y;
}
|}

let invalid_program =
	{|
int main() {
	bool flag = true;
	int x = 1;
	x = flag;
	return x;
}
|}

let test_valid_program () =
	match Spooky.parse_and_type_check valid_program with
	| Ok _ -> ()
	| Error msg -> failwith ("expected valid program, got: " ^ msg)

let test_invalid_program () =
	match Spooky.parse_and_type_check invalid_program with
	| Ok _ -> failwith "expected type error, but got success"
	| Error _ -> ()

let () =
	test_valid_program ();
	test_invalid_program ();
	print_endline "All parser/type-check tests passed."
