Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
#### :house: Internal

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

# 12.0.0-beta.10

Expand Down
2 changes: 1 addition & 1 deletion tests/tests/src/alias_test.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ let a10 = "hello world";

let a20 = a10 + "not";

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

let a21 = a20 + a20;

Expand Down
4 changes: 1 addition & 3 deletions tests/tests/src/alias_test.res
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
module String = Ocaml_String

let a0 = "hello "

let a1 = a0
Expand Down Expand Up @@ -41,7 +39,7 @@ let a18 = a17
let a19 = a18

let a20 = a19 ++ "not"
let v = if String.get(a20, 0) == 'h' {
let v = if String.getUnsafe(a20, 0) == "h" {
1
} else {
2
Expand Down
6 changes: 1 addition & 5 deletions tests/tests/src/array_safe_get.mjs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
// Generated by ReScript, PLEASE EDIT WITH CARE

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

let x = [
Expand All @@ -11,7 +10,7 @@ let x = [
let y;

try {
y = Primitive_array.get(x, 3);
y = x[3];
} catch (raw_msg) {
let msg = Primitive_exceptions.internalToException(raw_msg);
if (msg.RE_EXN_ID === "Invalid_argument") {
Expand All @@ -22,10 +21,7 @@ try {
}
}

let $$Array;

export {
$$Array,
x,
y,
}
Expand Down
4 changes: 1 addition & 3 deletions tests/tests/src/array_safe_get.res
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
module Array = Ocaml_Array

let x = [1, 2]
let y = try x[3] catch {
let y = try x->Array.getUnsafe(3) catch {
| Invalid_argument(msg) =>
Js.log(msg)
0
Expand Down
36 changes: 18 additions & 18 deletions tests/tests/src/array_subtle_test.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

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

let v = [
1,
Expand All @@ -22,7 +21,7 @@ function f(v) {
}

function fff(x) {
return true;
return x.length >= 0;
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This change is interesting. Will make a separate PR regarding that.

}

function fff2(x) {
Expand All @@ -34,11 +33,15 @@ function fff2(x) {
}

function fff3(x) {
return 1;
if (x.length >= 0) {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here

return 1;
} else {
return 2;
}
}

function fff4(x) {
if (x.length !== 0) {
if (x.length > 0) {
return 1;
} else {
return 2;
Expand All @@ -53,7 +56,7 @@ Mocha.describe("Array_subtle_test", () => {
3,
3
];
Test_utils.eq("File \"array_subtle_test.res\", line 40, characters 7-14", 4, v.length);
Test_utils.eq("File \"array_subtle_test.res\", line 38, characters 7-14", 4, v.length);
});
Mocha.test("array_push_test", () => {
let v = [
Expand All @@ -62,9 +65,9 @@ Mocha.describe("Array_subtle_test", () => {
3,
3
];
Test_utils.eq("File \"array_subtle_test.res\", line 45, characters 7-14", 5, v.push(3));
Test_utils.eq("File \"array_subtle_test.res\", line 46, characters 7-14", 5, v.length);
Test_utils.eq("File \"array_subtle_test.res\", line 47, characters 7-14", 5, v.length);
Test_utils.eq("File \"array_subtle_test.res\", line 43, characters 7-14", 5, v.push(3));
Test_utils.eq("File \"array_subtle_test.res\", line 44, characters 7-14", 5, v.length);
Test_utils.eq("File \"array_subtle_test.res\", line 45, characters 7-14", 5, v.length);
});
Mocha.test("array_mutation_test", () => {
let v = [
Expand All @@ -73,9 +76,9 @@ Mocha.describe("Array_subtle_test", () => {
3,
3
];
Test_utils.eq("File \"array_subtle_test.res\", line 52, characters 7-14", 3, Primitive_array.get(v, 2));
Primitive_array.set(v, 2, 4);
Test_utils.eq("File \"array_subtle_test.res\", line 54, characters 7-14", 4, Primitive_array.get(v, 2));
Test_utils.eq("File \"array_subtle_test.res\", line 50, characters 7-14", 3, v[2]);
v[2] = 4;
Test_utils.eq("File \"array_subtle_test.res\", line 52, characters 7-14", 4, v[2]);
});
Mocha.test("array_pop_test", () => {
let v = [
Expand All @@ -87,19 +90,16 @@ Mocha.describe("Array_subtle_test", () => {
while (v.length > 0) {
v.pop();
};
Test_utils.eq("File \"array_subtle_test.res\", line 62, characters 7-14", 0, v.length);
Test_utils.eq("File \"array_subtle_test.res\", line 60, characters 7-14", 0, v.length);
});
Mocha.test("array_function_tests", () => {
Test_utils.eq("File \"array_subtle_test.res\", line 66, characters 7-14", 1, fff3([]));
Test_utils.eq("File \"array_subtle_test.res\", line 67, characters 7-14", 2, fff4([]));
Test_utils.eq("File \"array_subtle_test.res\", line 68, characters 7-14", 1, fff4([1]));
Test_utils.eq("File \"array_subtle_test.res\", line 64, characters 7-14", 1, fff3([]));
Test_utils.eq("File \"array_subtle_test.res\", line 65, characters 7-14", 2, fff4([]));
Test_utils.eq("File \"array_subtle_test.res\", line 66, characters 7-14", 1, fff4([1]));
});
});

let $$Array;

export {
$$Array,
v,
f,
fff,
Expand Down
8 changes: 3 additions & 5 deletions tests/tests/src/array_subtle_test.res
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
open Mocha
open Test_utils

module Array = Ocaml_Array

let v = [1, 2, 3, 3]

let f = v => {
Expand Down Expand Up @@ -49,9 +47,9 @@ describe(__MODULE__, () => {

test("array_mutation_test", () => {
let v = [1, 2, 3, 3]
eq(__LOC__, 3, v[2])
v[2] = 4
eq(__LOC__, 4, v[2])
eq(__LOC__, 3, v->Array.getUnsafe(2))
v->Array.setUnsafe(2, 4)
eq(__LOC__, 4, v->Array.getUnsafe(2))
})

test("array_pop_test", () => {
Expand Down
Loading
Loading