diff options
author | Alex AUVOLAT <alex.auvolat@ens.fr> | 2013-11-04 22:05:57 +0100 |
---|---|---|
committer | Alex AUVOLAT <alex.auvolat@ens.fr> | 2013-11-04 22:05:57 +0100 |
commit | cebd07b64f1f537c5ecf00ec21ff4b7c4032f0a3 (patch) | |
tree | 9d2048313fe3ad4c92865c8f0236bed24e64449b /sched/graph_test.ml | |
parent | f253f98136def21b5e50c5922246e2ddfe315442 (diff) | |
download | SystDigit-Projet-cebd07b64f1f537c5ecf00ec21ff4b7c4032f0a3.tar.gz SystDigit-Projet-cebd07b64f1f537c5ecf00ec21ff4b7c4032f0a3.zip |
Added stub C simulator (defined dumb-down syntax for netlists).
Diffstat (limited to 'sched/graph_test.ml')
-rw-r--r-- | sched/graph_test.ml | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/sched/graph_test.ml b/sched/graph_test.ml new file mode 100644 index 0000000..ac31677 --- /dev/null +++ b/sched/graph_test.ml @@ -0,0 +1,28 @@ +open Graph + +let rec check l = match l with + | [] | [_] -> true + | s1::s2::l -> (String.length s1 <= String.length s2) && (check (s2::l)) + +let test_good () = + let g = mk_graph () in + add_node g "1"; add_node g "21"; add_node g "22"; add_node g "333"; + add_edge g "1" "21"; add_edge g "1" "22"; + add_edge g "21" "333"; add_edge g "22" "333"; + let l = topological g in + print_string "Test: Tri topologique --> "; + if check l then print_endline "OK" else print_endline "FAIL"; + List.iter print_endline l; + print_newline () + +let test_cycle () = + let g = mk_graph () in + add_node g "1"; add_node g "2"; add_node g "3"; + add_edge g "1" "2"; add_edge g "2" "3"; add_edge g "3" "1"; + print_string "Test: Detection de cycle --> "; + if has_cycle g then print_endline "OK" else print_endline "FAIL" +;; + +test_cycle ();; +test_good ();; + |