-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathSolutionTest.v
45 lines (32 loc) · 953 Bytes
/
SolutionTest.v
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
Require Solution.
Require Import Preloaded.
Require Coq.extraction.Extraction.
From CW Require Import Loader.
Extract Inductive nat => "int"
["0" "(fun x -> x + 1)"]
"(fun zero succ n -> if n = 0 then zero () else succ (n - 1))".
Extract Constant plus => "( + )".
Extract Constant mult => "( * )".
(* CWStopOnFailure 0. *)
CWGroup "Group".
CWTest "Successful Extraction Test".
Extraction "factorial.ml" Solution.factorial.
CWCompileAndRun "factorial.mli" "factorial.ml" Options "-verbose" Driver "
open Factorial
let () =
assert (factorial 3 = 6);
assert (factorial 0 = 1);
assert (factorial 5 = 120)
".
CWTest "Extraction Test With Errors".
Extract Constant mult => "*".
Extraction "factorial.ml" Solution.factorial.
CWCompileAndRun "factorial.mli" "factorial.ml" Options "-verbose" Driver "
open Factorial
let () =
assert (factorial 3 = 6);
assert (factorial 0 = 1);
assert (factorial 5 = 120)
".
CWEndTest.
CWEndGroup.