Skip to content

Commit

Permalink
test: better regression test for #454
Browse files Browse the repository at this point in the history
  • Loading branch information
c-cube committed Sep 17, 2024
1 parent c959e39 commit 69f0e9b
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 13 deletions.
3 changes: 2 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ build:
dune build @install -p $(PACKAGES)

test: build
dune runtest --display=quiet --cache=disabled --no-buffer --force
# run tests in release mode to expose bug in #454
dune runtest --display=quiet --cache=disabled --no-buffer --force --profile=release

clean:
dune clean
Expand Down
5 changes: 5 additions & 0 deletions tests/core/reg/dune
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@

(tests
(ocamlopt_flags :standard -inline 1000)
(names t_reg454)
(libraries containers))
Empty file.
8 changes: 8 additions & 0 deletions tests/core/reg/t_reg454.ml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
module Vec = CCVector

let () =
let arr : Int32.t Vec.vector = Vec.create () in
Vec.push arr (Int32.of_int 123456);
Format.printf "%d\n" (Int32.to_int (Vec.get arr 0));
let x = Vec.get arr 0 in
Format.printf "%d\n" (Int32.to_int x)
12 changes: 0 additions & 12 deletions tests/core/t_vector.ml
Original file line number Diff line number Diff line change
Expand Up @@ -753,15 +753,3 @@ push v 0;
push v 0;
push v 0;
6 = foldi (fun i acc _ -> acc + i) 0 v
;;

t ~name:"reg454" @@ fun () ->
let arr : Int32.t vector = create () in
CCVector.push arr (Int32.of_int 123456);
let s = spf "%d\n" (Int32.to_int (CCVector.get arr 0)) in
Printf.eprintf "%d\n" (Int32.to_int (CCVector.get arr 0));
let x = CCVector.get arr 0 in
let s2 = spf "%d\n" (Int32.to_int x) in
Printf.eprintf "%d\n" (Int32.to_int x);
assert_equal ~printer:(spf "%S") s s2;
true

0 comments on commit 69f0e9b

Please sign in to comment.