Skip to content

Commit 501b15f

Browse files
committed
Js.Array(2) -> Array
1 parent c354960 commit 501b15f

21 files changed

+58
-1228
lines changed

tests/build_tests/uncurried-always/src/UncurriedAlways.res

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,4 @@ let a = 3->foo(4)
1212

1313
Console.log(a) // Test automatic uncurried application
1414

15-
let _ = Js.Array2.map([1], x => x + 1)
15+
let _ = Array.map([1], x => x + 1)

tests/tests/src/UncurriedAlways.res

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ let a = 3->foo(4)
1414

1515
Console.log(a) // Test automatic uncurried application
1616

17-
let _ = Js.Array2.map([1], x => x + 1)
17+
let _ = Array.map([1], x => x + 1)
1818

1919
let ptl = foo(10, ...) // force partial application
2020

tests/tests/src/array_subtle_test.mjs

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

33
import * as Mt from "./mt.mjs";
4-
import * as Primitive_array from "rescript/lib/es6/Primitive_array.js";
54

65
let suites = {
76
contents: /* [] */0
@@ -41,8 +40,8 @@ eq("File \"array_subtle_test.res\", line 16, characters 12-19", [
4140
]);
4241

4342
eq("File \"array_subtle_test.res\", line 19, characters 5-12", [
44-
5,
45-
v.push(3)
43+
undefined,
44+
(v.push(3), undefined)
4645
]);
4746

4847
eq("File \"array_subtle_test.res\", line 20, characters 5-12", [
@@ -57,14 +56,14 @@ eq("File \"array_subtle_test.res\", line 21, characters 5-12", [
5756

5857
eq("File \"array_subtle_test.res\", line 25, characters 5-12", [
5958
3,
60-
Primitive_array.get(v, 2)
59+
v[2]
6160
]);
6261

63-
Primitive_array.set(v, 2, 4);
62+
v[2] = 4;
6463

6564
eq("File \"array_subtle_test.res\", line 27, characters 5-12", [
6665
4,
67-
Primitive_array.get(v, 2)
66+
v[2]
6867
]);
6968

7069
while (v.length > 0) {
@@ -87,7 +86,7 @@ function f(v) {
8786
}
8887

8988
function fff(x) {
90-
return true;
89+
return x.length >= 0;
9190
}
9291

9392
function fff2(x) {
@@ -99,11 +98,15 @@ function fff2(x) {
9998
}
10099

101100
function fff3(x) {
102-
return 1;
101+
if (x.length >= 0) {
102+
return 1;
103+
} else {
104+
return 2;
105+
}
103106
}
104107

105108
function fff4(x) {
106-
if (x.length !== 0) {
109+
if (x.length > 0) {
107110
return 1;
108111
} else {
109112
return 2;
@@ -127,10 +130,7 @@ eq("File \"array_subtle_test.res\", line 68, characters 3-10", [
127130

128131
Mt.from_pair_suites("Array_subtle_test", suites.contents);
129132

130-
let $$Array;
131-
132133
export {
133-
$$Array,
134134
suites,
135135
test_id,
136136
eq,

tests/tests/src/array_subtle_test.res

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
module Array = Ocaml_Array
1+
// module Array = Ocaml_Array
22

33
let suites: ref<Mt.pair_suites> = ref(list{})
44
let test_id = ref(0)
@@ -16,30 +16,30 @@ let v = [1, 2, 3, 3]
1616
let () = eq(__LOC__, (4, Array.length(v)))
1717

1818
let () = {
19-
eq(__LOC__, (5, Js.Array2.push(v, 3))) /* in Js array length can be changing .. */
19+
eq(__LOC__, ((), Array.push(v, 3))) /* in Js array length can be changing .. */
20+
eq(__LOC__, (5, Array.length(v)))
2021
eq(__LOC__, (5, Array.length(v)))
21-
eq(__LOC__, (5, Js.Array2.length(v)))
2222
}
2323

2424
let () = {
25-
eq(__LOC__, (3, v[2]))
25+
eq(__LOC__, (Some(3), v[2]))
2626
v[2] = 4
27-
eq(__LOC__, (4, v[2]))
27+
eq(__LOC__, (Some(4), v[2]))
2828
} /* should not inline */
2929

3030
let () = {
31-
while Js.Array2.length(v) > 0 {
32-
ignore(Js.Array2.pop(v))
31+
while Array.length(v) > 0 {
32+
ignore(Array.pop(v))
3333
}
34-
eq(__LOC__, (0, Js.Array2.length(v)))
34+
eq(__LOC__, (0, Array.length(v)))
3535
}
3636

3737
let f = v => {
38-
switch Js.Array2.pop(v) {
38+
switch Array.pop(v) {
3939
| Some(x) => Console.log("hi")
4040
| None => Console.log("hi2")
4141
}
42-
Console.log(ignore(Js.Array2.pop(v)))
42+
Console.log(ignore(Array.pop(v)))
4343
}
4444

4545
let fff = x => Array.length(x) >= 0

tests/tests/src/bs_array_test.mjs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import * as Mt from "./mt.mjs";
44
import * as Belt_List from "rescript/lib/es6/Belt_List.js";
55
import * as Belt_Array from "rescript/lib/es6/Belt_Array.js";
6+
import * as Stdlib_Array from "rescript/lib/es6/Stdlib_Array.js";
67
import * as Primitive_int from "rescript/lib/es6/Primitive_int.js";
78
import * as Primitive_object from "rescript/lib/es6/Primitive_object.js";
89

@@ -45,12 +46,12 @@ function push(prim0, prim1) {
4546
prim0.push(prim1);
4647
}
4748

48-
console.log([
49+
console.log(Stdlib_Array.reduce([
4950
1,
5051
2,
5152
3,
5253
4
53-
].filter(x => x > 2).map((x, i) => x + i | 0).reduce((x, y) => x + y | 0, 0));
54+
].filter(x => x > 2).map((x, i) => x + i | 0), 0, (x, y) => x + y | 0));
5455

5556
let v = [
5657
1,

tests/tests/src/bs_array_test.res

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,12 @@ module L = Belt.List
1717

1818
let {push} = module(A)
1919

20-
type t<'a> = Js.Array2.t<'a>
20+
type t<'a> = array<'a>
2121
let () =
2222
[1, 2, 3, 4]
23-
->Js.Array2.filter(x => x > 2)
24-
->Js.Array2.mapi((x, i) => x + i)
25-
->Js.Array2.reduce((x, y) => x + y, 0)
23+
->Array.filter(x => x > 2)
24+
->Array.mapWithIndex((x, i) => x + i)
25+
->Array.reduce(0, (x, y) => x + y)
2626
->Console.log
2727

2828
let () = {

tests/tests/src/bs_auto_uncurry_test.mjs

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

33
import * as Mt from "./mt.mjs";
4+
import * as Stdlib_Array from "rescript/lib/es6/Stdlib_Array.js";
45

56
let suites = {
67
contents: /* [] */0
@@ -77,17 +78,17 @@ eq("File \"bs_auto_uncurry_test.res\", line 32, characters 5-12", [
7778
4
7879
]);
7980

80-
eq("File \"bs_auto_uncurry_test.res\", line 34, characters 5-12", [
81+
eq("File \"bs_auto_uncurry_test.res\", line 34, characters 5-12", Stdlib_Array.reduce([
8182
1,
8283
2,
8384
3
84-
].reduce((prim0, prim1) => prim0 + prim1 | 0, 0), 6);
85+
], 0, (prim0, prim1) => prim0 + prim1 | 0), 6);
8586

86-
eq("File \"bs_auto_uncurry_test.res\", line 36, characters 5-12", [
87+
eq("File \"bs_auto_uncurry_test.res\", line 36, characters 5-12", Stdlib_Array.reduceWithIndex([
8788
1,
8889
2,
8990
3
90-
].reduce((x, y, i) => (x + y | 0) + i | 0, 0), 9);
91+
], 0, (x, y, i) => (x + y | 0) + i | 0), 9);
9192

9293
eq("File \"bs_auto_uncurry_test.res\", line 38, characters 5-12", [
9394
1,

tests/tests/src/bs_auto_uncurry_test.res

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,15 +29,15 @@ let () = {
2929

3030
let () = {
3131
eq(__LOC__, [1, 2, 3]->map(x => x + 1), [2, 3, 4])
32-
eq(__LOC__, [1, 2, 3]->Js.Array2.map(x => x + 1), [2, 3, 4])
32+
eq(__LOC__, [1, 2, 3]->Array.map(x => x + 1), [2, 3, 4])
3333

34-
eq(__LOC__, [1, 2, 3]->Js.Array2.reduce(\"+", 0), 6)
34+
eq(__LOC__, [1, 2, 3]->Array.reduce(0, \"+"), 6)
3535

36-
eq(__LOC__, [1, 2, 3]->Js.Array2.reducei((x, y, i) => x + y + i, 0), 9)
36+
eq(__LOC__, [1, 2, 3]->Array.reduceWithIndex(0, (x, y, i) => x + y + i), 9)
3737

38-
eq(__LOC__, [1, 2, 3]->Js.Array2.some(x => x < 1), false)
38+
eq(__LOC__, [1, 2, 3]->Array.some(x => x < 1), false)
3939

40-
eq(__LOC__, [1, 2, 3]->Js.Array2.every(x => x > 0), true)
40+
eq(__LOC__, [1, 2, 3]->Array.every(x => x > 0), true)
4141
}
4242

4343
let () = Mt.from_pair_suites(__MODULE__, suites.contents)

tests/tests/src/bs_string_test.mjs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
// Generated by ReScript, PLEASE EDIT WITH CARE
22

33
import * as Mt from "./mt.mjs";
4+
import * as Stdlib_Array from "rescript/lib/es6/Stdlib_Array.js";
45

56
let suites = {
67
contents: /* [] */0
@@ -25,7 +26,7 @@ function eq(loc, x, y) {
2526
};
2627
}
2728

28-
eq("File \"bs_string_test.res\", line 13, characters 2-9", "ghso ghso g".split(" ").reduce((x, y) => x + ("-" + y), ""), "-ghso-ghso-g");
29+
eq("File \"bs_string_test.res\", line 13, characters 2-9", Stdlib_Array.reduce("ghso ghso g".split(" "), "", (x, y) => x + ("-" + y)), "-ghso-ghso-g");
2930

3031
Mt.from_pair_suites("Bs_string_test", suites.contents);
3132

tests/tests/src/bs_string_test.res

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ let eq = (loc, x, y) => {
1111

1212
let () = eq(
1313
__LOC__,
14-
"ghso ghso g"->Js.String2.split(" ")->Js.Array2.reduce((x, y) => x ++ ("-" ++ y), ""),
14+
"ghso ghso g"->Js.String2.split(" ")->Array.reduce("", (x, y) => x ++ ("-" ++ y)),
1515
"-ghso-ghso-g",
1616
)
1717

0 commit comments

Comments
 (0)