Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Remove ocaml_compat stuff from tests#7871

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
cknitt merged 2 commits intorescript-lang:masterfromcknitt:no-ocaml-compat
Sep 10, 2025
Merged
Show file tree
Hide file tree
Changes from1 commit
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
2 changes: 1 addition & 1 deletiontests/tests/src/alias_test.mjs
View file
Open in desktop
Original file line numberDiff line numberDiff 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 deletionstests/tests/src/alias_test.res
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
module String = Ocaml_String

let a0 = "hello "

let a1 = a0
Expand DownExpand 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 deletionstests/tests/src/array_safe_get.mjs
View file
Open in desktop
Original file line numberDiff line numberDiff 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 deletionstests/tests/src/array_safe_get.res
View file
Open in desktop
Original file line numberDiff line numberDiff 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 deletionstests/tests/src/array_subtle_test.mjs
View file
Open in desktop
Original file line numberDiff line numberDiff 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) {
returntrue;
returnx.length >= 0;
Copy link
MemberAuthor

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
MemberAuthor

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\", line40, characters 7-14", 4, v.length);
Test_utils.eq("File \"array_subtle_test.res\", line38, 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\", line45, characters 7-14", 5, v.push(3));
Test_utils.eq("File \"array_subtle_test.res\", line46, characters 7-14", 5, v.length);
Test_utils.eq("File \"array_subtle_test.res\", line47, characters 7-14", 5, v.length);
Test_utils.eq("File \"array_subtle_test.res\", line43, characters 7-14", 5, v.push(3));
Test_utils.eq("File \"array_subtle_test.res\", line44, characters 7-14", 5, v.length);
Test_utils.eq("File \"array_subtle_test.res\", line45, 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\", line52, characters 7-14", 3,Primitive_array.get(v, 2));
Primitive_array.set(v, 2, 4);
Test_utils.eq("File \"array_subtle_test.res\", line54, characters 7-14", 4,Primitive_array.get(v, 2));
Test_utils.eq("File \"array_subtle_test.res\", line50, characters 7-14", 3,v[2]);
v[2] = 4;
Test_utils.eq("File \"array_subtle_test.res\", line52, 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\", line62, characters 7-14", 0, v.length);
Test_utils.eq("File \"array_subtle_test.res\", line60, characters 7-14", 0, v.length);
});
Mocha.test("array_function_tests", () => {
Test_utils.eq("File \"array_subtle_test.res\", line66, characters 7-14", 1, fff3([]));
Test_utils.eq("File \"array_subtle_test.res\", line67, characters 7-14", 2, fff4([]));
Test_utils.eq("File \"array_subtle_test.res\", line68, characters 7-14", 1, fff4([1]));
Test_utils.eq("File \"array_subtle_test.res\", line64, characters 7-14", 1, fff3([]));
Test_utils.eq("File \"array_subtle_test.res\", line65, characters 7-14", 2, fff4([]));
Test_utils.eq("File \"array_subtle_test.res\", line66, characters 7-14", 1, fff4([1]));
});
});

let $$Array;

export {
$$Array,
v,
f,
fff,
Expand Down
8 changes: 3 additions & 5 deletionstests/tests/src/array_subtle_test.res
View file
Open in desktop
Original file line numberDiff line numberDiff 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 DownExpand 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
70 changes: 33 additions & 37 deletionstests/tests/src/bdd.mjs
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,14 @@
// Generated by ReScript, PLEASE EDIT WITH CARE

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

function $$eval(_bdd, vars) {
while (true) {
let bdd = _bdd;
if (typeof bdd !== "object") {
return bdd === "One";
}
if (Primitive_array.get(vars,bdd._1)) {
if (vars[bdd._1]) {
_bdd = bdd._3;
continue;
}
Expand DownExpand Up@@ -67,7 +66,7 @@ function resize(newSize) {
RE_EXN_ID: "Assert_failure",
_1: [
"bdd.res",
62,
60,
13
],
Error: new Error()
Expand All@@ -77,44 +76,44 @@ function resize(newSize) {
RE_EXN_ID: "Assert_failure",
_1: [
"bdd.res",
62,
60,
13
],
Error: new Error()
};
} else {
let ind = hashVal(getId(n._0), getId(n._3), n._1) & newSz_1;
Primitive_array.set(newArr,ind, {
newArr[ind] = {
hd: n,
tl:Primitive_array.get(newArr,ind)
});
tl: newArr[ind]
};
_bucket = bucket.tl;
continue;
}
};
};
for (let n = 0, n_finish = sz_1.contents; n <= n_finish; ++n) {
copyBucket(Primitive_array.get(arr, n));
copyBucket(arr[n]);
}
htab.contents = newArr;
sz_1.contents = newSz_1;
}

function insert(idl, idh, v, ind, bucket, newNode) {
if (n_items.contents <= sz_1.contents) {
Primitive_array.set(htab.contents,ind, {
htab.contents[ind] = {
hd: newNode,
tl: bucket
});
};
n_items.contents = n_items.contents + 1 | 0;
return;
}
resize((sz_1.contents + sz_1.contents | 0) + 2 | 0);
let ind$1 = hashVal(idl, idh, v) & sz_1.contents;
Primitive_array.set(htab.contents,ind$1, {
htab.contents[ind$1] = {
hd: newNode,
tl:Primitive_array.get(htab.contents,ind$1)
});
tl: htab.contents[ind$1]
};
}

function resetUnique() {
Expand All@@ -131,7 +130,7 @@ function mkNode(low, v, high) {
return low;
}
let ind = hashVal(idl, idh, v) & sz_1.contents;
let bucket =Primitive_array.get(htab.contents,ind);
let bucket = htab.contents[ind];
let _b = bucket;
while (true) {
let b = _b;
Expand All@@ -143,7 +142,7 @@ function mkNode(low, v, high) {
RE_EXN_ID: "Assert_failure",
_1: [
"bdd.res",
123,
121,
15
],
Error: new Error()
Expand All@@ -153,7 +152,7 @@ function mkNode(low, v, high) {
RE_EXN_ID: "Assert_failure",
_1: [
"bdd.res",
123,
121,
15
],
Error: new Error()
Expand DownExpand Up@@ -224,12 +223,12 @@ function not(n) {
}
let id = n._2;
let h = id % 1999;
if (id ===Primitive_array.get(notslot1, h)) {
returnPrimitive_array.get(notslot2, h);
if (id === notslot1[h]) {
return notslot2[h];
}
let f = mkNode(not(n._0), n._1, not(n._3));
Primitive_array.set(notslot1, h, id);
Primitive_array.set(notslot2, h, f);
notslot1[h] = id;
notslot2[h] = f;
return f;
}

Expand DownExpand Up@@ -257,8 +256,8 @@ function and2(n1, n2) {
let v2 = n2._1;
let l2 = n2._0;
let h = hash(i1, i2);
if (i1 ===Primitive_array.get(andslot1, h) && i2 ===Primitive_array.get(andslot2, h)) {
returnPrimitive_array.get(andslot3, h);
if (i1 === andslot1[h] && i2 === andslot2[h]) {
return andslot3[h];
}
let match = cmpVar(v1, v2);
let f;
Expand All@@ -273,9 +272,9 @@ function and2(n1, n2) {
f = mkNode(and2(n1, l2), v2, and2(n1, r2));
break;
}
Primitive_array.set(andslot1, h, i1);
Primitive_array.set(andslot2, h, i2);
Primitive_array.set(andslot3, h, f);
andslot1[h] = i1;
andslot2[h] = i2;
andslot3[h] = f;
return f;
}

Expand DownExpand Up@@ -303,8 +302,8 @@ function xor(n1, n2) {
let v2 = n2._1;
let l2 = n2._0;
let h = hash(i1, i2);
if (i1 ===Primitive_array.get(andslot1, h) && i2 ===Primitive_array.get(andslot2, h)) {
returnPrimitive_array.get(andslot3, h);
if (i1 === andslot1[h] && i2 === andslot2[h]) {
return andslot3[h];
}
let match = cmpVar(v1, v2);
let f;
Expand All@@ -319,9 +318,9 @@ function xor(n1, n2) {
f = mkNode(xor(n1, l2), v2, xor(n1, r2));
break;
}
Primitive_array.set(andslot1, h, i1);
Primitive_array.set(andslot2, h, i2);
Primitive_array.set(andslot3, h, f);
andslot1[h] = i1;
andslot2[h] = i2;
andslot3[h] = f;
return f;
}

Expand DownExpand Up@@ -355,7 +354,7 @@ function random() {
function random_vars(n) {
let vars = Belt_Array.make(n, false);
for (let i = 0; i < n; ++i) {
Primitive_array.set(vars, i,random());
vars[i] =random();
}
return vars;
}
Expand All@@ -371,12 +370,12 @@ function bool_equal(a, b) {
function test_hwb(bdd, vars) {
let ntrue = 0;
for (let i = 0, i_finish = vars.length; i < i_finish; ++i) {
if (Primitive_array.get(vars, i)) {
if (vars[i]) {
ntrue = ntrue + 1 | 0;
}

}
return bool_equal($$eval(bdd, vars), ntrue > 0 ?Primitive_array.get(vars,ntrue - 1 | 0) : false);
return bool_equal($$eval(bdd, vars), ntrue > 0 ? vars[ntrue - 1 | 0] : false);
}

function main() {
Expand All@@ -392,7 +391,7 @@ function main() {
RE_EXN_ID: "Assert_failure",
_1: [
"bdd.res",
304,
302,
2
],
Error: new Error()
Expand All@@ -401,8 +400,6 @@ function main() {

main();

let $$Array;

let initSize_1 = 8191;

let zero = "Zero";
Expand All@@ -412,7 +409,6 @@ let one = "One";
let cacheSize = 1999;

export {
$$Array,
$$eval,
getId,
initSize_1,
Expand Down
Loading
Loading

[8]ページ先頭

©2009-2025 Movatter.jp