-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathtest.ml
66 lines (56 loc) · 1.89 KB
/
test.ml
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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
open Lib.Util
module Simple = Interactive.SPrompt
module Degree = Interactive.DPrompt
module Kappa = Interactive.KPrompt
type mode = SimpleT | Interactive
type shape = Simple | Degree | Kappa
let simple_tests shape = match shape with
| Simple -> Simple.simple_tests ()
| Degree -> Degree.simple_tests ()
| Kappa -> Kappa.simple_tests ()
let shape_matcher = function
| "simple" -> Some Simple
| "degree" -> Some Degree
| _ -> Some Kappa
let string_of_shape = function
Simple -> "simple graphs"
| Degree -> "Port graph"
| Kappa -> "Kappa graph"
let ask_shape () = ask_until "[kappa|simple|degree] (kappa) " shape_matcher
let rec interactive maybe_shape =
let shape = match maybe_shape with
| Some shape -> shape
| None -> ask_shape ()
in
log (Printf.sprintf "entering interactive extension base builder (%s)." (string_of_shape shape)); log "" ;
try
match shape with
| Simple -> Simple.interactive ()
| Degree -> Degree.interactive ()
| Kappa -> Kappa.interactive ()
with Interactive.Change_shape s ->
let shape = match shape_matcher s with
| Some shape -> shape
| None -> ask_shape ()
in interactive (Some shape)
let load shape file = (match shape with
| Some Simple -> ignore (Simple.process_command Simple.empty (Parser.Load file))
| Some Degree -> ignore (Degree.process_command Degree.empty (Parser.Load file))
| Some Kappa -> ignore (Kappa.process_command Kappa.empty (Parser.Load file))
| _ -> failwith "Impossible"); log ""
let test shape debug mode =
if debug then debug_mode () else ();
match mode with
| SimpleT -> simple_tests shape
| Interactive -> interactive (Some shape)
let () =
ignore (LNoise.history_load histfile);
if Array.length Sys.argv > 1 then
let file = Sys.argv.(1) in
Kappa.bench file
else
let shape = Kappa in
let debug = false
in
let mode = Interactive
in test shape debug mode