Skip to content

Commit ef42a56

Browse files
ejgallegohhugo
authored andcommitted
[tests] [32bit] update tests for 32bit CI
1 parent 2347eda commit ef42a56

File tree

6 files changed

+33
-19
lines changed

6 files changed

+33
-19
lines changed

compiler/lib/stdlib.ml

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -307,23 +307,25 @@ module Int32 = struct
307307

308308
external equal : int32 -> int32 -> bool = "%equal"
309309

310-
let warn_overflow ~to_dec ~to_hex i i32 =
310+
let warn_overflow name ~to_dec ~to_hex i i32 =
311311
warn
312-
"Warning: integer overflow: integer 0x%s (%s) truncated to 0x%lx (%ld); the \
313-
generated code might be incorrect.@."
312+
"Warning: integer overflow: %s 0x%s (%s) truncated to 0x%lx (%ld); the generated \
313+
code might be incorrect.@."
314+
name
314315
(to_hex i)
315316
(to_dec i)
316317
i32
317318
i32
318319

319-
let convert_warning_on_overflow ~to_int32 ~of_int32 ~equal ~to_dec ~to_hex x =
320+
let convert_warning_on_overflow name ~to_int32 ~of_int32 ~equal ~to_dec ~to_hex x =
320321
let i32 = to_int32 x in
321322
let x' = of_int32 i32 in
322-
if not (equal x' x) then warn_overflow ~to_dec ~to_hex x i32;
323+
if not (equal x' x) then warn_overflow name ~to_dec ~to_hex x i32;
323324
i32
324325

325326
let of_nativeint_warning_on_overflow n =
326327
convert_warning_on_overflow
328+
"native integer"
327329
~to_int32:Nativeint.to_int32
328330
~of_int32:Nativeint.of_int32
329331
~equal:Nativeint.equal

compiler/lib/targetint.ml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,7 @@ let of_float_opt x =
122122

123123
let of_int_warning_on_overflow i =
124124
Stdlib.Int32.convert_warning_on_overflow
125+
"integer"
125126
~to_int32:(fun i -> wrap_modulo (Int32.of_int i))
126127
~of_int32:Int32.to_int
127128
~equal:Int.equal
@@ -131,6 +132,7 @@ let of_int_warning_on_overflow i =
131132

132133
let of_int32_warning_on_overflow n =
133134
Stdlib.Int32.convert_warning_on_overflow
135+
"int32"
134136
~to_int32:(fun i -> wrap_modulo i)
135137
~of_int32:Fun.id
136138
~equal:Int32.equal
@@ -140,6 +142,7 @@ let of_int32_warning_on_overflow n =
140142

141143
let of_nativeint_warning_on_overflow n =
142144
Stdlib.Int32.convert_warning_on_overflow
145+
"native integer"
143146
~to_int32:(fun i -> wrap_modulo (Nativeint.to_int32 i))
144147
~of_int32:Nativeint.of_int32
145148
~equal:Nativeint.equal

compiler/tests-compiler/dune.inc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -287,11 +287,11 @@
287287
(library
288288
;; compiler/tests-compiler/gh1051.ml
289289
(name gh1051_15)
290-
(enabled_if true)
290+
(enabled_if %{arch_sixtyfour})
291291
(modules gh1051)
292292
(libraries js_of_ocaml_compiler unix str jsoo_compiler_expect_tests_helper)
293293
(inline_tests
294-
(enabled_if true)
294+
(enabled_if %{arch_sixtyfour})
295295
(deps
296296
(file %{project_root}/compiler/bin-js_of_ocaml/js_of_ocaml.exe)
297297
(file %{project_root}/compiler/bin-jsoo_minify/jsoo_minify.exe)))

compiler/tests-compiler/gen-rules/gen.ml

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,14 +47,17 @@ let prefix : string =
4747

4848
type enabled_if =
4949
| GE5
50+
| B64
5051
| Any
5152

5253
let lib_enabled_if = function
5354
| "obj" | "effects" -> GE5
55+
| "gh1051" -> B64
5456
| _ -> Any
5557

5658
let test_enabled_if = function
5759
| "obj" | "lazy" -> GE5
60+
| "gh1051" -> B64
5861
| _ -> Any
5962

6063
let () =
@@ -86,8 +89,10 @@ let () =
8689
(Hashtbl.hash prefix mod 100)
8790
(match lib_enabled_if basename with
8891
| Any -> "true"
89-
| GE5 -> "(>= %{ocaml_version} 5)")
92+
| GE5 -> "(>= %{ocaml_version} 5)"
93+
| B64 -> "%{arch_sixtyfour}")
9094
basename
9195
(match test_enabled_if basename with
9296
| Any -> "true"
93-
| GE5 -> "(>= %{ocaml_version} 5)"))
97+
| GE5 -> "(>= %{ocaml_version} 5)"
98+
| B64 -> "%{arch_sixtyfour}"))

compiler/tests-compiler/gh1051.ml

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,19 +25,21 @@ let%expect_test _ =
2525
Util.compile_and_run ~skip_modern:true prog;
2626
[%expect
2727
{|
28-
Warning: integer overflow: integer 0xffffffff (4294967295) truncated to 0xffffffff (-1); the generated code might be incorrect.
29-
ffffffff |}];
28+
Warning: integer overflow: native integer 0xffffffff (4294967295) truncated to 0xffffffff (-1); the generated code might be incorrect.
29+
ffffffff
30+
|}];
3031
()
3132

3233
let%expect_test _ =
3334
Util.print_fun_decl (Util.compile_and_parse prog) None;
3435
[%expect
3536
{|
36-
Warning: integer overflow: integer 0xffffffff (4294967295) truncated to 0xffffffff (-1); the generated code might be incorrect.
37+
Warning: integer overflow: native integer 0xffffffff (4294967295) truncated to 0xffffffff (-1); the generated code might be incorrect.
3738
function caml_call2(f, a0, a1){
3839
return (f.l >= 0 ? f.l : f.l = f.length) == 2
3940
? f(a0, a1)
4041
: runtime.caml_call_gen(f, [a0, a1]);
4142
}
42-
//end |}];
43+
//end
44+
|}];
4345
()

compiler/tests-compiler/pbt/test_int31.ml

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -59,21 +59,23 @@ let%expect_test _ =
5959
i);
6060
[%expect ""]
6161

62+
let sixty_four = Sys.int_size > 32
63+
6264
let%expect_test _ =
6365
let i = Gen.(generate1 (no_shrink out_of_range_i32)) in
6466
let i_trunc = Int32.(shift_right (shift_left i 1) 1) in
6567
ignore (Int31.of_int32_warning_on_overflow i);
6668
let output = [%expect.output] in
6769
let expected =
6870
Format.sprintf
69-
"Warning: integer overflow: integer 0x%lx (%ld) truncated to 0x%lx (%ld); the \
71+
"Warning: integer overflow: int32 0x%lx (%ld) truncated to 0x%lx (%ld); the \
7072
generated code might be incorrect.@."
7173
i
7274
i
7375
i_trunc
7476
i_trunc
7577
in
76-
if not (String.equal output expected)
78+
if sixty_four && not (String.equal output expected)
7779
then Format.printf "Unexpected output string@.%[email protected]:@.%s@." output expected;
7880
[%expect ""]
7981

@@ -91,7 +93,7 @@ let%expect_test _ =
9193
i_trunc
9294
i_trunc
9395
in
94-
if not (String.equal output expected)
96+
if sixty_four && not (String.equal output expected)
9597
then Format.printf "Unexpected output string@.%[email protected]:@.%s@." output expected;
9698
[%expect ""]
9799

@@ -102,14 +104,14 @@ let%expect_test _ =
102104
let output = [%expect.output] in
103105
let expected =
104106
Format.sprintf
105-
"Warning: integer overflow: integer 0x%nx (%nd) truncated to 0x%lx (%ld); the \
106-
generated code might be incorrect.@."
107+
"Warning: integer overflow: native integer 0x%nx (%nd) truncated to 0x%lx (%ld); \
108+
the generated code might be incorrect.@."
107109
i
108110
i
109111
i_trunc
110112
i_trunc
111113
in
112-
if not (String.equal output expected)
114+
if sixty_four && not (String.equal output expected)
113115
then Format.printf "Unexpected output string@.%[email protected]:@.%s@." output expected;
114116
[%expect ""]
115117

0 commit comments

Comments
 (0)