Skip to content

Commit

Permalink
More parametric tests and only run tests when z3 available
Browse files Browse the repository at this point in the history
  • Loading branch information
filipeom committed Jun 17, 2024
1 parent b9e643d commit 9be702f
Show file tree
Hide file tree
Showing 12 changed files with 48 additions and 40 deletions.
3 changes: 3 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,3 +41,6 @@ jobs:

- name: Build
run: opam exec -- dune build @install

- name: Test
run: opam exec -- dune runtest
1 change: 1 addition & 0 deletions example/dune
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
(libraries smtml))

(cram
(enabled_if %{lib-available:z3})
(deps
./product_mix.exe
(source_tree test)))
3 changes: 2 additions & 1 deletion lib/optimizer.mli
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,5 @@
(* along with this program. If not, see <https://www.gnu.org/licenses/>. *)
(***************************************************************************)

include Optimizer_intf.Intf (** @inline *)
(** @inline *)
include Optimizer_intf.Intf
7 changes: 5 additions & 2 deletions test/dune
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,16 @@
test_harness
test_solver_params
test_solver
test_lia)
test_lia
test_lra
test_optimizer)
(libraries smtml))

(test
(name test_z3)
(modules test_z3)
(libraries smtml smtml_tests))
(libraries smtml smtml_tests)
(build_if %{lib-available:z3}))

(test
(name test_colibri2)
Expand Down
1 change: 1 addition & 0 deletions test/parser/dune
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
(cram
(enabled_if %{lib-available:z3})
(deps
%{bin:smtml}
test_core.smtml
Expand Down
1 change: 1 addition & 0 deletions test/regression/dune
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
(cram
(enabled_if %{lib-available:z3})
(deps %{bin:smtml} test_pr_71.smtml))

(tests
Expand Down
18 changes: 18 additions & 0 deletions test/test_lra.ml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
open Smtml

module Make (M : Mappings_intf.S) = struct
module Solver = Solver.Batch (M)

let () =
let solver = Solver.create () in
assert (
let x = Expr.mk_symbol Symbol.("x" @: Ty_real) in
let y = Expr.mk_symbol Symbol.("y" @: Ty_real) in
let c0 = Expr.relop Ty_bool Eq x y in
let c1 =
Expr.relop Ty_bool Eq
(Expr.cvtop Ty_real ToString x)
(Expr.cvtop Ty_real ToString y)
in
`Sat = Solver.check solver [ c0; c1 ] )
end
15 changes: 15 additions & 0 deletions test/test_optimizer.ml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
open Smtml

module Make (M : Mappings_intf.S) = struct
open Test_harness
module Optimizer = Optimizer.Make (M)

let () =
let open Infix in
let opt = Optimizer.create () in
let x = symbol "x" Ty_int in
Optimizer.add opt Int.[ x >= int 0; x < int 5 ];
Optimizer.protect opt (fun () ->
assert (Stdlib.(Some (Value.Int 0) = Optimizer.minimize opt x)) );
assert (Stdlib.(Some (Value.Int 4) = Optimizer.maximize opt x))
end
2 changes: 2 additions & 0 deletions test/test_z3.ml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ let () = assert Z3_mappings.is_available

module Test_solver_params = Test_solver_params.Make (Z3_mappings.Fresh.Make ())
module Test_solver = Test_solver.Make (Z3_mappings.Fresh.Make ())
module Test_optimizer = Test_optimizer.Make (Z3_mappings.Fresh.Make ())
module Test_bv = Test_bv.Make (Z3_mappings.Fresh.Make ())
module Test_fp = Test_fp.Make (Z3_mappings.Fresh.Make ())
module Test_lia = Test_lia.Make (Z3_mappings.Fresh.Make ())
module Test_lra = Test_lra.Make (Z3_mappings.Fresh.Make ())
2 changes: 0 additions & 2 deletions test/unit/dune
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
(tests
(names
test_expr_hc
test_optimizer
test_real
test_simplify
test_unop
test_binop
Expand Down
19 changes: 0 additions & 19 deletions test/unit/test_optimizer.ml

This file was deleted.

16 changes: 0 additions & 16 deletions test/unit/test_real.ml

This file was deleted.

0 comments on commit 9be702f

Please sign in to comment.