mirror of
https://github.com/c-cube/iter.git
synced 2025-12-05 19:00:31 -05:00
basic building blocks for testing
This commit is contained in:
parent
6443648f56
commit
ec8a865500
5 changed files with 55 additions and 12 deletions
6
.merlin
6
.merlin
|
|
@ -1,2 +1,6 @@
|
|||
B _build
|
||||
S .
|
||||
S tests/
|
||||
B _build
|
||||
B _build/tests/
|
||||
PKG oUnit
|
||||
PKG bench
|
||||
|
|
|
|||
11
Makefile
11
Makefile
|
|
@ -5,20 +5,19 @@ TARGETS = sequence.cma sequence.cmxa sequence.cmi sequence.a
|
|||
LIB = $(addprefix _build/, $(TARGETS))
|
||||
INSTALL = $(LIB) sequence.mli
|
||||
|
||||
all:
|
||||
all: tests
|
||||
ocamlbuild $(TARGETS) $(DOC)
|
||||
|
||||
bench: all
|
||||
ocamlbuild \
|
||||
-cflags -I,`ocamlfind query extlib` \
|
||||
-lflags -I,`ocamlfind query extlib` \
|
||||
-package extlib -package unix bench.native
|
||||
ocamlbuild -use-ocamlfind -pkg bench tests/benchs.native
|
||||
|
||||
tests:
|
||||
ocamlbuild tests.native
|
||||
ocamlbuild -use-ocamlfind -pkg oUnit tests/run_tests.native
|
||||
|
||||
install: all
|
||||
ocamlfind install $(NAME) META $(INSTALL)
|
||||
|
||||
clean:
|
||||
ocamlbuild -clean
|
||||
|
||||
.PHONY: all clean tests bench
|
||||
|
|
|
|||
24
README.md
24
README.md
|
|
@ -19,12 +19,26 @@ You need OCaml, say OCaml 3.12 or OCaml 4.0.
|
|||
|
||||
$ make
|
||||
|
||||
To see how to use it, check `tests.ml`. `sequence.ml` has a few examples of how to convert
|
||||
data structures into sequences, and conversely.
|
||||
If you have `OUnit` installed, you can build and run tests with
|
||||
|
||||
The module `sexpr.mli` exposes the interface of the S-expression example library. It
|
||||
requires OCaml>=4.0 to compile, because of the GADT structure used in the monadic
|
||||
parser combinators part of `sexpr.ml`.
|
||||
$ make tests
|
||||
$ ./run_tests.native
|
||||
|
||||
If you have `Bench` installed, you can build and run benchmarks with
|
||||
|
||||
$ make benchs
|
||||
$ ./benchs.native
|
||||
|
||||
To see how to use the library, check the `examples` directory.
|
||||
`tests.ml` has a few examples of how to convert basic data structures into
|
||||
sequences, and conversely.
|
||||
|
||||
Examples
|
||||
========
|
||||
|
||||
The module `examples/sexpr.mli` exposes the interface of the S-expression
|
||||
example library. It requires OCaml>=4.0 to compile, because of the GADT
|
||||
structure used in the monadic parser combinators part of `examples/sexpr.ml`.
|
||||
|
||||
Documentation
|
||||
=============
|
||||
|
|
|
|||
9
tests/run_tests.ml
Normal file
9
tests/run_tests.ml
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
|
||||
open OUnit
|
||||
|
||||
let suite =
|
||||
"run_tests" >:::
|
||||
[ Test_sequence.suite; ]
|
||||
|
||||
let _ =
|
||||
OUnit.run_test_tt_main suite
|
||||
17
tests/test_sequence.ml
Normal file
17
tests/test_sequence.ml
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
|
||||
open OUnit
|
||||
|
||||
module S = Sequence
|
||||
|
||||
let test_empty () =
|
||||
let seq = S.empty in
|
||||
OUnit.assert_bool "empty" (S.is_empty seq);
|
||||
OUnit.assert_bool "empty"
|
||||
(try S.iter (fun _ -> raise Exit) seq; true with Exit -> false);
|
||||
()
|
||||
|
||||
let suite =
|
||||
"test_sequence" >:::
|
||||
[ "test_empty" >:: test_empty;
|
||||
|
||||
]
|
||||
Loading…
Add table
Reference in a new issue