test: better regression test for #454

This commit is contained in:
Simon Cruanes 2024-09-17 14:04:09 -04:00
parent c959e396b3
commit 69f0e9b624
No known key found for this signature in database
GPG key ID: EBFFF6F283F3A2B4
5 changed files with 15 additions and 13 deletions

View file

@ -6,7 +6,8 @@ build:
dune build @install -p $(PACKAGES) dune build @install -p $(PACKAGES)
test: build 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: clean:
dune clean dune clean

5
tests/core/reg/dune Normal file
View file

@ -0,0 +1,5 @@
(tests
(ocamlopt_flags :standard -inline 1000)
(names t_reg454)
(libraries containers))

View file

View file

@ -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)

View file

@ -753,15 +753,3 @@ push v 0;
push v 0; push v 0;
push v 0; push v 0;
6 = foldi (fun i acc _ -> acc + i) 0 v 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