Skip to content

Commit 6f423e4

Browse files
authored
Remove ocaml_compat stuff from tests (#7871)
* Remove ocaml_compat * CHANGELOG
1 parent d711614 commit 6f423e4

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

56 files changed

+445
-5180
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
#### :house: Internal
3535

3636
- Playground: Add config options for experimental features and jsx preserve mode. https://github.com/rescript-lang/rescript/pull/7865
37+
- Clean up tests. https://github.com/rescript-lang/rescript/pull/7861 https://github.com/rescript-lang/rescript/pull/7871
3738

3839
# 12.0.0-beta.10
3940

tests/tests/src/alias_test.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ let a10 = "hello world";
55

66
let a20 = a10 + "not";
77

8-
let v = a20.codePointAt(0) === /* 'h' */104 ? 1 : 2;
8+
let v = a20[0] === "h" ? 1 : 2;
99

1010
let a21 = a20 + a20;
1111

tests/tests/src/alias_test.res

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
module String = Ocaml_String
2-
31
let a0 = "hello "
42

53
let a1 = a0
@@ -41,7 +39,7 @@ let a18 = a17
4139
let a19 = a18
4240

4341
let a20 = a19 ++ "not"
44-
let v = if String.get(a20, 0) == 'h' {
42+
let v = if String.getUnsafe(a20, 0) == "h" {
4543
1
4644
} else {
4745
2

tests/tests/src/array_safe_get.mjs

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
// Generated by ReScript, PLEASE EDIT WITH CARE
22

3-
import * as Primitive_array from "@rescript/runtime/lib/es6/Primitive_array.js";
43
import * as Primitive_exceptions from "@rescript/runtime/lib/es6/Primitive_exceptions.js";
54

65
let x = [
@@ -11,7 +10,7 @@ let x = [
1110
let y;
1211

1312
try {
14-
y = Primitive_array.get(x, 3);
13+
y = x[3];
1514
} catch (raw_msg) {
1615
let msg = Primitive_exceptions.internalToException(raw_msg);
1716
if (msg.RE_EXN_ID === "Invalid_argument") {
@@ -22,10 +21,7 @@ try {
2221
}
2322
}
2423

25-
let $$Array;
26-
2724
export {
28-
$$Array,
2925
x,
3026
y,
3127
}

tests/tests/src/array_safe_get.res

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
1-
module Array = Ocaml_Array
2-
31
let x = [1, 2]
4-
let y = try x[3] catch {
2+
let y = try x->Array.getUnsafe(3) catch {
53
| Invalid_argument(msg) =>
64
Js.log(msg)
75
0

tests/tests/src/array_subtle_test.mjs

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
import * as Mocha from "mocha";
44
import * as Test_utils from "./test_utils.mjs";
5-
import * as Primitive_array from "@rescript/runtime/lib/es6/Primitive_array.js";
65

76
let v = [
87
1,
@@ -22,7 +21,7 @@ function f(v) {
2221
}
2322

2423
function fff(x) {
25-
return true;
24+
return x.length >= 0;
2625
}
2726

2827
function fff2(x) {
@@ -34,11 +33,15 @@ function fff2(x) {
3433
}
3534

3635
function fff3(x) {
37-
return 1;
36+
if (x.length >= 0) {
37+
return 1;
38+
} else {
39+
return 2;
40+
}
3841
}
3942

4043
function fff4(x) {
41-
if (x.length !== 0) {
44+
if (x.length > 0) {
4245
return 1;
4346
} else {
4447
return 2;
@@ -53,7 +56,7 @@ Mocha.describe("Array_subtle_test", () => {
5356
3,
5457
3
5558
];
56-
Test_utils.eq("File \"array_subtle_test.res\", line 40, characters 7-14", 4, v.length);
59+
Test_utils.eq("File \"array_subtle_test.res\", line 38, characters 7-14", 4, v.length);
5760
});
5861
Mocha.test("array_push_test", () => {
5962
let v = [
@@ -62,9 +65,9 @@ Mocha.describe("Array_subtle_test", () => {
6265
3,
6366
3
6467
];
65-
Test_utils.eq("File \"array_subtle_test.res\", line 45, characters 7-14", 5, v.push(3));
66-
Test_utils.eq("File \"array_subtle_test.res\", line 46, characters 7-14", 5, v.length);
67-
Test_utils.eq("File \"array_subtle_test.res\", line 47, characters 7-14", 5, v.length);
68+
Test_utils.eq("File \"array_subtle_test.res\", line 43, characters 7-14", 5, v.push(3));
69+
Test_utils.eq("File \"array_subtle_test.res\", line 44, characters 7-14", 5, v.length);
70+
Test_utils.eq("File \"array_subtle_test.res\", line 45, characters 7-14", 5, v.length);
6871
});
6972
Mocha.test("array_mutation_test", () => {
7073
let v = [
@@ -73,9 +76,9 @@ Mocha.describe("Array_subtle_test", () => {
7376
3,
7477
3
7578
];
76-
Test_utils.eq("File \"array_subtle_test.res\", line 52, characters 7-14", 3, Primitive_array.get(v, 2));
77-
Primitive_array.set(v, 2, 4);
78-
Test_utils.eq("File \"array_subtle_test.res\", line 54, characters 7-14", 4, Primitive_array.get(v, 2));
79+
Test_utils.eq("File \"array_subtle_test.res\", line 50, characters 7-14", 3, v[2]);
80+
v[2] = 4;
81+
Test_utils.eq("File \"array_subtle_test.res\", line 52, characters 7-14", 4, v[2]);
7982
});
8083
Mocha.test("array_pop_test", () => {
8184
let v = [
@@ -87,19 +90,16 @@ Mocha.describe("Array_subtle_test", () => {
8790
while (v.length > 0) {
8891
v.pop();
8992
};
90-
Test_utils.eq("File \"array_subtle_test.res\", line 62, characters 7-14", 0, v.length);
93+
Test_utils.eq("File \"array_subtle_test.res\", line 60, characters 7-14", 0, v.length);
9194
});
9295
Mocha.test("array_function_tests", () => {
93-
Test_utils.eq("File \"array_subtle_test.res\", line 66, characters 7-14", 1, fff3([]));
94-
Test_utils.eq("File \"array_subtle_test.res\", line 67, characters 7-14", 2, fff4([]));
95-
Test_utils.eq("File \"array_subtle_test.res\", line 68, characters 7-14", 1, fff4([1]));
96+
Test_utils.eq("File \"array_subtle_test.res\", line 64, characters 7-14", 1, fff3([]));
97+
Test_utils.eq("File \"array_subtle_test.res\", line 65, characters 7-14", 2, fff4([]));
98+
Test_utils.eq("File \"array_subtle_test.res\", line 66, characters 7-14", 1, fff4([1]));
9699
});
97100
});
98101

99-
let $$Array;
100-
101102
export {
102-
$$Array,
103103
v,
104104
f,
105105
fff,

tests/tests/src/array_subtle_test.res

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
open Mocha
22
open Test_utils
33

4-
module Array = Ocaml_Array
5-
64
let v = [1, 2, 3, 3]
75

86
let f = v => {
@@ -49,9 +47,9 @@ describe(__MODULE__, () => {
4947

5048
test("array_mutation_test", () => {
5149
let v = [1, 2, 3, 3]
52-
eq(__LOC__, 3, v[2])
53-
v[2] = 4
54-
eq(__LOC__, 4, v[2])
50+
eq(__LOC__, 3, v->Array.getUnsafe(2))
51+
v->Array.setUnsafe(2, 4)
52+
eq(__LOC__, 4, v->Array.getUnsafe(2))
5553
})
5654

5755
test("array_pop_test", () => {

0 commit comments

Comments
 (0)