Skip to content

Commit 51f91de

Browse files
committed
Lisa ounit-todo testimiseks
1 parent 0f25faa commit 51f91de

2 files changed

Lines changed: 36 additions & 0 deletions

File tree

test/ounit-todo/dune

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
(library
2+
(name ounittodo)
3+
(libraries ounit2 qcheck-ounit)
4+
(wrapped false))

test/ounit-todo/oUnitTodo.ml

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
open OUnit2
2+
3+
let wrap = OUnitTest.test_decorate (fun test ->
4+
fun ctxt ->
5+
try
6+
test ctxt
7+
with
8+
| Failure "TODO" [@warning "-fragile-literal-pattern"]
9+
| QCheck.Test.Test_error (_, _, Failure "TODO", _) [@warning "-fragile-literal-pattern"] ->
10+
todo "unimplemented"
11+
)
12+
13+
let assert_raises ?msg exn (f: unit -> 'a) =
14+
match f () with
15+
| _ ->
16+
let str = Format.sprintf "expected exception %s, but no exception was raised." (Printexc.to_string exn) in
17+
begin match msg with
18+
| None -> assert_failure str
19+
| Some s -> assert_failure (s ^ "\n" ^ str)
20+
end
21+
| exception Failure "TODO" [@warning "-fragile-literal-pattern"] ->
22+
todo "unimplemented"
23+
| exception e ->
24+
assert_equal ?msg ~printer:Printexc.to_string exn e
25+
26+
let passes (test: test_fun) (ctxt: test_ctxt) =
27+
match test ctxt with
28+
| () -> true
29+
| exception _ -> false
30+
31+
let skip_if_fails test ctxt msg =
32+
skip_if (not (passes test ctxt)) msg

0 commit comments

Comments
 (0)