diff --git a/CHANGELOG.md b/CHANGELOG.md index 8aad3d4f94..f940a261cb 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -14,6 +14,7 @@ #### :boom: Breaking Change +- Remove runtime APIs that were deprecated for removal in ReScript 13, including the `Char` module, unsafe `Obj` operations, legacy `Pervasives` helpers, and `Array.unsafe_get`. https://github.com/rescript-lang/rescript/pull/8564 - Remove the deprecated `Js` namespace and its runtime modules. https://github.com/rescript-lang/rescript/pull/8531 - Move Belt into the separately installed `@rescript/belt` package. Projects using Belt must install the package and list it in their `rescript.json` dependencies. https://github.com/rescript-lang/rescript/pull/8554 diff --git a/packages/@rescript/belt/src/Belt_Array.resi b/packages/@rescript/belt/src/Belt_Array.resi index 8609a51c80..75cd9fb4b2 100644 --- a/packages/@rescript/belt/src/Belt_Array.resi +++ b/packages/@rescript/belt/src/Belt_Array.resi @@ -749,7 +749,7 @@ one by one using `f(xi, yi)`; and return true if all results are true false othe ## Examples ```rescript -Belt.Array.eq([1, 2, 3], [-1, -2, -3], (a, b) => abs(a) == abs(b)) == true +Belt.Array.eq([1, 2, 3], [-1, -2, -3], (a, b) => Math.Int.abs(a) == Math.Int.abs(b)) == true ``` */ let eq: (t<'a>, t<'a>, ('a, 'a) => bool) => bool diff --git a/packages/@rescript/belt/src/Belt_HashMap.res b/packages/@rescript/belt/src/Belt_HashMap.res index 5503e3bd49..340ff3f75f 100644 --- a/packages/@rescript/belt/src/Belt_HashMap.res +++ b/packages/@rescript/belt/src/Belt_HashMap.res @@ -30,7 +30,7 @@ let rec copyBucketReHash = (~hash, ~h_buckets, ~ndata_tail, old_bucket) => switch C.toOpt(old_bucket) { | None => () | Some(cell) => - let nidx = land(hash(cell.N.key), A.length(h_buckets) - 1) + let nidx = Int.bitwiseAnd(hash(cell.N.key), A.length(h_buckets) - 1) let v = C.return(cell) switch C.toOpt(A.getUnsafe(ndata_tail, nidx)) { | None => A.setUnsafe(h_buckets, nidx, v) @@ -75,7 +75,7 @@ let rec replaceInBucket = (~eq, key, info, cell) => let set0 = (h, key, value, ~eq, ~hash) => { let h_buckets = h.C.buckets let buckets_len = A.length(h_buckets) - let i = land(hash(key), buckets_len - 1) + let i = Int.bitwiseAnd(hash(key), buckets_len - 1) let l = A.getUnsafe(h_buckets, i) switch C.toOpt(l) { | None => @@ -87,7 +87,7 @@ let set0 = (h, key, value, ~eq, ~hash) => { h.C.size = h.C.size + 1 } } - if h.C.size > lsl(buckets_len, 1) { + if h.C.size > Int.shiftLeft(buckets_len, 1) { resize(~hash, h) } } @@ -113,7 +113,7 @@ let rec removeInBucket = (h, h_buckets, i, key, prec, bucket, ~eq) => let remove = (h, key) => { let h_buckets = h.C.buckets - let i = land(Belt_Id.getHashInternal(h.C.hash)(key), A.length(h_buckets) - 1) + let i = Int.bitwiseAnd(Belt_Id.getHashInternal(h.C.hash)(key), A.length(h_buckets) - 1) let bucket = A.getUnsafe(h_buckets, i) switch C.toOpt(bucket) { | None => () @@ -141,7 +141,7 @@ let rec getAux = (~eq, key, buckets) => let get = (h, key) => { let h_buckets = h.C.buckets - let nid = land(Belt_Id.getHashInternal(h.C.hash)(key), A.length(h_buckets) - 1) + let nid = Int.bitwiseAnd(Belt_Id.getHashInternal(h.C.hash)(key), A.length(h_buckets) - 1) switch C.toOpt(A.getUnsafe(h_buckets, nid)) { | None => None | Some(cell1: N.bucket<_>) => @@ -179,7 +179,7 @@ let rec memInBucket = (key, cell, ~eq) => let has = (h, key) => { let h_buckets = h.C.buckets - let nid = land(Belt_Id.getHashInternal(h.C.hash)(key), A.length(h_buckets) - 1) + let nid = Int.bitwiseAnd(Belt_Id.getHashInternal(h.C.hash)(key), A.length(h_buckets) - 1) let bucket = A.getUnsafe(h_buckets, nid) switch C.toOpt(bucket) { | None => false diff --git a/packages/@rescript/belt/src/Belt_HashMapInt.res b/packages/@rescript/belt/src/Belt_HashMapInt.res index d035e786ef..3782945bb6 100644 --- a/packages/@rescript/belt/src/Belt_HashMapInt.res +++ b/packages/@rescript/belt/src/Belt_HashMapInt.res @@ -22,7 +22,7 @@ let rec copyBucketReHash = (~h_buckets, ~ndata_tail, old_bucket: C.opt () | Some(cell) => - let nidx = land(hash(cell.key), A.length(h_buckets) - 1) + let nidx = Int.bitwiseAnd(hash(cell.key), A.length(h_buckets) - 1) let v = C.return(cell) switch C.toOpt(A.getUnsafe(ndata_tail, nidx)) { | None => A.setUnsafe(h_buckets, nidx, v) @@ -67,7 +67,7 @@ let rec replaceInBucket = (key: key, info, cell) => let set = (h, key: key, value) => { let h_buckets = h.C.buckets let buckets_len = A.length(h_buckets) - let i = land(hash(key), buckets_len - 1) + let i = Int.bitwiseAnd(hash(key), buckets_len - 1) let l = A.getUnsafe(h_buckets, i) switch C.toOpt(l) { | None => @@ -79,7 +79,7 @@ let set = (h, key: key, value) => { h.C.size = h.C.size + 1 } } - if h.C.size > lsl(buckets_len, 1) { + if h.C.size > Int.shiftLeft(buckets_len, 1) { resize(h) } } @@ -99,7 +99,7 @@ let rec removeInBucket = (h, h_buckets, i, key: key, prec, buckets) => let remove = (h, key) => { let h_buckets = h.C.buckets - let i = land(hash(key), A.length(h_buckets) - 1) + let i = Int.bitwiseAnd(hash(key), A.length(h_buckets) - 1) let bucket = A.getUnsafe(h_buckets, i) switch C.toOpt(bucket) { | None => () @@ -126,7 +126,7 @@ let rec getAux = (key: key, buckets) => let get = (h, key: key) => { let h_buckets = h.C.buckets - let nid = land(hash(key), A.length(h_buckets) - 1) + let nid = Int.bitwiseAnd(hash(key), A.length(h_buckets) - 1) switch C.toOpt(A.getUnsafe(h_buckets, nid)) { | None => None | Some(cell1) => @@ -163,7 +163,7 @@ let rec memInBucket = (key: key, cell) => let has = (h, key) => { let h_buckets = h.C.buckets - let nid = land(hash(key), A.length(h_buckets) - 1) + let nid = Int.bitwiseAnd(hash(key), A.length(h_buckets) - 1) let bucket = A.getUnsafe(h_buckets, nid) switch C.toOpt(bucket) { | None => false diff --git a/packages/@rescript/belt/src/Belt_HashMapString.res b/packages/@rescript/belt/src/Belt_HashMapString.res index aa6900e1c3..9e442090c7 100644 --- a/packages/@rescript/belt/src/Belt_HashMapString.res +++ b/packages/@rescript/belt/src/Belt_HashMapString.res @@ -22,7 +22,7 @@ let rec copyBucketReHash = (~h_buckets, ~ndata_tail, old_bucket: C.opt () | Some(cell) => - let nidx = land(hash(cell.key), A.length(h_buckets) - 1) + let nidx = Int.bitwiseAnd(hash(cell.key), A.length(h_buckets) - 1) let v = C.return(cell) switch C.toOpt(A.getUnsafe(ndata_tail, nidx)) { | None => A.setUnsafe(h_buckets, nidx, v) @@ -67,7 +67,7 @@ let rec replaceInBucket = (key: key, info, cell) => let set = (h, key: key, value) => { let h_buckets = h.C.buckets let buckets_len = A.length(h_buckets) - let i = land(hash(key), buckets_len - 1) + let i = Int.bitwiseAnd(hash(key), buckets_len - 1) let l = A.getUnsafe(h_buckets, i) switch C.toOpt(l) { | None => @@ -79,7 +79,7 @@ let set = (h, key: key, value) => { h.C.size = h.C.size + 1 } } - if h.C.size > lsl(buckets_len, 1) { + if h.C.size > Int.shiftLeft(buckets_len, 1) { resize(h) } } @@ -99,7 +99,7 @@ let rec removeInBucket = (h, h_buckets, i, key: key, prec, buckets) => let remove = (h, key) => { let h_buckets = h.C.buckets - let i = land(hash(key), A.length(h_buckets) - 1) + let i = Int.bitwiseAnd(hash(key), A.length(h_buckets) - 1) let bucket = A.getUnsafe(h_buckets, i) switch C.toOpt(bucket) { | None => () @@ -126,7 +126,7 @@ let rec getAux = (key: key, buckets) => let get = (h, key: key) => { let h_buckets = h.C.buckets - let nid = land(hash(key), A.length(h_buckets) - 1) + let nid = Int.bitwiseAnd(hash(key), A.length(h_buckets) - 1) switch C.toOpt(A.getUnsafe(h_buckets, nid)) { | None => None | Some(cell1) => @@ -163,7 +163,7 @@ let rec memInBucket = (key: key, cell) => let has = (h, key) => { let h_buckets = h.C.buckets - let nid = land(hash(key), A.length(h_buckets) - 1) + let nid = Int.bitwiseAnd(hash(key), A.length(h_buckets) - 1) let bucket = A.getUnsafe(h_buckets, nid) switch C.toOpt(bucket) { | None => false diff --git a/packages/@rescript/belt/src/Belt_HashSet.res b/packages/@rescript/belt/src/Belt_HashSet.res index 5be753c4b7..d35e746c3f 100644 --- a/packages/@rescript/belt/src/Belt_HashSet.res +++ b/packages/@rescript/belt/src/Belt_HashSet.res @@ -22,7 +22,10 @@ let rec copyBucket = (~hash, ~h_buckets, ~ndata_tail, old_bucket) => switch C.toOpt(old_bucket) { | None => () | Some(cell) => - let nidx = land(Belt_Id.getHashInternal(hash)(cell.N.key), A.length(h_buckets) - 1) + let nidx = Stdlib.Int.bitwiseAnd( + Belt_Id.getHashInternal(hash)(cell.N.key), + A.length(h_buckets) - 1, + ) let v = C.return(cell) switch C.toOpt(A.getUnsafe(ndata_tail, nidx)) { | None => A.setUnsafe(h_buckets, nidx, v) @@ -69,7 +72,7 @@ let rec removeBucket = (~eq, h, h_buckets, i, key, prec, cell) => { let remove = (h, key) => { let eq = h.C.eq let h_buckets = h.C.buckets - let i = land(Belt_Id.getHashInternal(h.C.hash)(key), A.length(h_buckets) - 1) + let i = Stdlib.Int.bitwiseAnd(Belt_Id.getHashInternal(h.C.hash)(key), A.length(h_buckets) - 1) let l = A.getUnsafe(h_buckets, i) switch C.toOpt(l) { | None => () @@ -101,7 +104,7 @@ let rec addBucket = (h, key, cell, ~eq) => let add0 = (h, key, ~hash, ~eq) => { let h_buckets = h.C.buckets let buckets_len = A.length(h_buckets) - let i = land(Belt_Id.getHashInternal(hash)(key), buckets_len - 1) + let i = Stdlib.Int.bitwiseAnd(Belt_Id.getHashInternal(hash)(key), buckets_len - 1) let l = A.getUnsafe(h_buckets, i) switch C.toOpt(l) { | None => @@ -109,7 +112,7 @@ let add0 = (h, key, ~hash, ~eq) => { A.setUnsafe(h_buckets, i, C.return({N.key, next: C.emptyOpt})) | Some(cell) => addBucket(~eq, h, key, cell) } - if h.C.size > lsl(buckets_len, 1) { + if h.C.size > Stdlib.Int.shiftLeft(buckets_len, 1) { tryDoubleResize(~hash, h) } } @@ -125,7 +128,7 @@ let rec memInBucket = (~eq, key, cell) => let has = (h, key) => { let (eq, h_buckets) = (h.C.eq, h.C.buckets) - let nid = land(Belt_Id.getHashInternal(h.C.hash)(key), A.length(h_buckets) - 1) + let nid = Stdlib.Int.bitwiseAnd(Belt_Id.getHashInternal(h.C.hash)(key), A.length(h_buckets) - 1) let bucket = A.getUnsafe(h_buckets, nid) switch C.toOpt(bucket) { | None => false diff --git a/packages/@rescript/belt/src/Belt_HashSet.resi b/packages/@rescript/belt/src/Belt_HashSet.resi index d281f82024..9dac3b66c9 100644 --- a/packages/@rescript/belt/src/Belt_HashSet.resi +++ b/packages/@rescript/belt/src/Belt_HashSet.resi @@ -14,11 +14,11 @@ different _hash_ functions will have different type. ## Examples ```rescript -module I0 = unpack(Belt.Id.hashable(~hash=(a: int) => land(a, 65535), ~eq=(a, b) => a == b)) +module I0 = unpack(Belt.Id.hashable(~hash=(a: int) => Int.bitwiseAnd(a, 65535), ~eq=(a, b) => a == b)) let s0 = Belt.HashSet.make(~id=module(I0), ~hintSize=40) -module I1 = unpack(Belt.Id.hashable(~hash=(a: int) => land(a, 255), ~eq=(a, b) => a == b)) +module I1 = unpack(Belt.Id.hashable(~hash=(a: int) => Int.bitwiseAnd(a, 255), ~eq=(a, b) => a == b)) let s1 = Belt.HashSet.make(~id=module(I1), ~hintSize=40) diff --git a/packages/@rescript/belt/src/Belt_HashSetInt.res b/packages/@rescript/belt/src/Belt_HashSetInt.res index 43668f800a..11bf5c2d6d 100644 --- a/packages/@rescript/belt/src/Belt_HashSetInt.res +++ b/packages/@rescript/belt/src/Belt_HashSetInt.res @@ -14,7 +14,7 @@ let rec copyBucket = (~h_buckets, ~ndata_tail, old_bucket) => switch C.toOpt(old_bucket) { | None => () | Some(cell) => - let nidx = land(hash(cell.N.key), A.length(h_buckets) - 1) + let nidx = Int.bitwiseAnd(hash(cell.N.key), A.length(h_buckets) - 1) let v = C.return(cell) switch C.toOpt(A.getUnsafe(ndata_tail, nidx)) { | None => A.setUnsafe(h_buckets, nidx, v) @@ -60,7 +60,7 @@ let rec removeBucket = (h, h_buckets, i, key: key, prec, cell) => { let remove = (h, key: key) => { let h_buckets = h.C.buckets - let i = land(hash(key), A.length(h_buckets) - 1) + let i = Int.bitwiseAnd(hash(key), A.length(h_buckets) - 1) let l = A.getUnsafe(h_buckets, i) switch C.toOpt(l) { | None => () @@ -92,7 +92,7 @@ let rec addBucket = (h, key: key, cell) => let add = (h, key: key) => { let h_buckets = h.C.buckets let buckets_len = A.length(h_buckets) - let i = land(hash(key), buckets_len - 1) + let i = Int.bitwiseAnd(hash(key), buckets_len - 1) let l = A.getUnsafe(h_buckets, i) switch C.toOpt(l) { | None => @@ -100,7 +100,7 @@ let add = (h, key: key) => { h.C.size = h.C.size + 1 | Some(cell) => addBucket(h, key, cell) } - if h.C.size > lsl(buckets_len, 1) { + if h.C.size > Int.shiftLeft(buckets_len, 1) { tryDoubleResize(h) } } @@ -114,7 +114,7 @@ let rec memInBucket = (key: key, cell) => let has = (h, key) => { let h_buckets = h.C.buckets - let nid = land(hash(key), A.length(h_buckets) - 1) + let nid = Int.bitwiseAnd(hash(key), A.length(h_buckets) - 1) let bucket = A.getUnsafe(h_buckets, nid) switch C.toOpt(bucket) { | None => false diff --git a/packages/@rescript/belt/src/Belt_HashSetString.res b/packages/@rescript/belt/src/Belt_HashSetString.res index 6405d464b7..9de78e2e32 100644 --- a/packages/@rescript/belt/src/Belt_HashSetString.res +++ b/packages/@rescript/belt/src/Belt_HashSetString.res @@ -14,7 +14,7 @@ let rec copyBucket = (~h_buckets, ~ndata_tail, old_bucket) => switch C.toOpt(old_bucket) { | None => () | Some(cell) => - let nidx = land(hash(cell.N.key), A.length(h_buckets) - 1) + let nidx = Int.bitwiseAnd(hash(cell.N.key), A.length(h_buckets) - 1) let v = C.return(cell) switch C.toOpt(A.getUnsafe(ndata_tail, nidx)) { | None => A.setUnsafe(h_buckets, nidx, v) @@ -60,7 +60,7 @@ let rec removeBucket = (h, h_buckets, i, key: key, prec, cell) => { let remove = (h, key: key) => { let h_buckets = h.C.buckets - let i = land(hash(key), A.length(h_buckets) - 1) + let i = Int.bitwiseAnd(hash(key), A.length(h_buckets) - 1) let l = A.getUnsafe(h_buckets, i) switch C.toOpt(l) { | None => () @@ -92,7 +92,7 @@ let rec addBucket = (h, key: key, cell) => let add = (h, key: key) => { let h_buckets = h.C.buckets let buckets_len = A.length(h_buckets) - let i = land(hash(key), buckets_len - 1) + let i = Int.bitwiseAnd(hash(key), buckets_len - 1) let l = A.getUnsafe(h_buckets, i) switch C.toOpt(l) { | None => @@ -100,7 +100,7 @@ let add = (h, key: key) => { h.C.size = h.C.size + 1 | Some(cell) => addBucket(h, key, cell) } - if h.C.size > lsl(buckets_len, 1) { + if h.C.size > Int.shiftLeft(buckets_len, 1) { tryDoubleResize(h) } } @@ -114,7 +114,7 @@ let rec memInBucket = (key: key, cell) => let has = (h, key) => { let h_buckets = h.C.buckets - let nid = land(hash(key), A.length(h_buckets) - 1) + let nid = Int.bitwiseAnd(hash(key), A.length(h_buckets) - 1) let bucket = A.getUnsafe(h_buckets, nid) switch C.toOpt(bucket) { | None => false diff --git a/packages/@rescript/belt/src/Belt_List.resi b/packages/@rescript/belt/src/Belt_List.resi index d03595b9d2..f8a9db8504 100644 --- a/packages/@rescript/belt/src/Belt_List.resi +++ b/packages/@rescript/belt/src/Belt_List.resi @@ -760,7 +760,7 @@ Belt.List.eq(list{1, 2, 3}, list{1, 2}, (a, b) => a == b) == false Belt.List.eq(list{1, 2}, list{1, 2}, (a, b) => a == b) == true -Belt.List.eq(list{1, 2, 3}, list{-1, -2, -3}, (a, b) => abs(a) == abs(b)) == true +Belt.List.eq(list{1, 2, 3}, list{-1, -2, -3}, (a, b) => Math.Int.abs(a) == Math.Int.abs(b)) == true ``` */ let eq: (t<'a>, t<'a>, ('a, 'a) => bool) => bool @@ -780,7 +780,7 @@ list{1, 2, 3}->Belt.List.has(2, (a, b) => a == b) == true list{1, 2, 3}->Belt.List.has(4, (a, b) => a == b) == false -list{-1, -2, -3}->Belt.List.has(2, (a, b) => abs(a) == abs(b)) == true +list{-1, -2, -3}->Belt.List.has(2, (a, b) => Math.Int.abs(a) == Math.Int.abs(b)) == true ``` */ let has: (t<'a>, 'b, ('a, 'b) => bool) => bool diff --git a/packages/@rescript/belt/src/Belt_Result.resi b/packages/@rescript/belt/src/Belt_Result.resi index 71b9c64cb5..8bb7bde1bf 100644 --- a/packages/@rescript/belt/src/Belt_Result.resi +++ b/packages/@rescript/belt/src/Belt_Result.resi @@ -77,7 +77,7 @@ ordinary value. ## Examples ```rescript -let f = x => sqrt(Belt.Int.toFloat(x)) +let f = x => Math.sqrt(Belt.Int.toFloat(x)) Belt.Result.map(Ok(64), f) == Ok(8.0) diff --git a/packages/@rescript/belt/src/Belt_SortArray.resi b/packages/@rescript/belt/src/Belt_SortArray.resi index 6830a24668..96c9267555 100644 --- a/packages/@rescript/belt/src/Belt_SortArray.resi +++ b/packages/@rescript/belt/src/Belt_SortArray.resi @@ -69,15 +69,15 @@ element that is larger than value. If value is not found and value is greater than all elements in array, the negative number returned is the bitwise complement of (the index of the last element plus 1)for example, if `key` is -smaller than all elements return `-1` since `lnot(-1) == 0` if `key` is larger -than all elements return `lnot(-1) == 0` since `lnot(- (len + 1)) == len` +smaller than all elements return `-1` since `Int.bitwiseNot(-1) == 0` if `key` is larger +than all elements return `Int.bitwiseNot(-1) == 0` since `Int.bitwiseNot(- (len + 1)) == len` ## Examples ```rescript Belt.SortArray.binarySearchBy([1, 2, 3, 4, 33, 35, 36], 33, Pervasives.compare) == 4 -lnot(Belt.SortArray.binarySearchBy([1, 3, 5, 7], 4, Pervasives.compare)) == 2 +Int.bitwiseNot(Belt.SortArray.binarySearchBy([1, 3, 5, 7], 4, Pervasives.compare)) == 2 ``` */ let binarySearchBy: (array<'a>, 'a, ('a, 'a) => int) => int diff --git a/packages/@rescript/runtime/Char.res b/packages/@rescript/runtime/Char.res deleted file mode 100644 index 133e63b873..0000000000 --- a/packages/@rescript/runtime/Char.res +++ /dev/null @@ -1,59 +0,0 @@ -// FIXME: -// This exists for compatibility reason. -// Move this into Pervasives or Core - -// Below is all deprecated and should be removed in v13 - -type t = char - -external code: t => int = "%identity" - -external unsafe_chr: int => t = "%identity" - -external chr: int => t = "%identity" - -external bytes_create: int => array = "Array" - -external bytes_unsafe_set: (array<'a>, int, 'a) => unit = "%array_unsafe_set" - -@scope("String") @variadic -external unsafe_to_string: array => string = "fromCodePoint" - -let escaped = param => - switch param { - | '\'' => "\\'" - | '\\' => "\\\\" - | '\n' => "\\n" - | '\t' => "\\t" - | '\r' => "\\r" - | '\b' => "\\b" - | ' ' .. '~' as c => - let s = bytes_create(1) - bytes_unsafe_set(s, 0, c) - unsafe_to_string(s) - | c => - let n = code(c) - let s = bytes_create(4) - bytes_unsafe_set(s, 0, '\\') - bytes_unsafe_set(s, 1, unsafe_chr(48 + n / 100)) - bytes_unsafe_set(s, 2, unsafe_chr(48 + mod(n / 10, 10))) - bytes_unsafe_set(s, 3, unsafe_chr(48 + mod(n, 10))) - unsafe_to_string(s) - } - -let lowercase_ascii = c => - if c >= 'A' && c <= 'Z' { - unsafe_chr(code(c) + 32) - } else { - c - } - -let uppercase_ascii = c => - if c >= 'a' && c <= 'z' { - unsafe_chr(code(c) - 32) - } else { - c - } - -let compare = (c1, c2) => code(c1) - code(c2) -let equal = (c1: t, c2: t) => compare(c1, c2) == 0 diff --git a/packages/@rescript/runtime/Char.resi b/packages/@rescript/runtime/Char.resi deleted file mode 100644 index 3b5c16483c..0000000000 --- a/packages/@rescript/runtime/Char.resi +++ /dev/null @@ -1,55 +0,0 @@ -// FIXME: -// This exists for compatibility reason. -// Move this into Pervasives or Core - -@@deprecated("Use type `string` and `String` module instead. This will be removed in v13") - -/** Return the ASCII code of the argument. */ -@deprecated("Use type `string` and `String.charCodeAt` instead. This will be removed in v13") -external code: char => int = "%identity" - -/** Return the character with the given ASCII code. - Beware this function is unsafe. */ -@deprecated("Use type `string` and `String.fromCharCode` instead. This will be removed in v13") -external chr: int => char = "%identity" - -/** Return a string representing the given character, - with special characters escaped following the lexical conventions - of OCaml. - All characters outside the ASCII printable range (32..126) are - escaped, as well as backslash, double-quote, and single-quote. */ -@deprecated("Use type `string` instead. This will be removed in v13") -let escaped: char => string - -/** Convert the given character to its equivalent lowercase character, - using the US-ASCII character set. - @since 4.03.0 */ -@deprecated("Use type `string` and `String.toLowerCase` instead. This will be removed in v13") -let lowercase_ascii: char => char - -/** Convert the given character to its equivalent uppercase character, - using the US-ASCII character set. - @since 4.03.0 */ -@deprecated("Use type `string` and `String.toUpperCase` instead. This will be removed in v13") -let uppercase_ascii: char => char - -/** An alias for the type of characters. */ -@deprecated("Use type `string` instead. This will be removed in v13") -type t = char - -/** The comparison function for characters, with the same specification as - {!Pervasives.compare}. Along with the type [t], this function [compare] - allows the module [Char] to be passed as argument to the functors - {!Set.Make} and {!Map.Make}. */ -@deprecated("Use type `string` and `String.compare` instead. This will be removed in v13") -let compare: (t, t) => int - -/** The equal function for chars. - @since 4.03.0 */ -@deprecated("Use type `string` and `String.equal` instead. This will be removed in v13") -let equal: (t, t) => bool - -/* The following is for system use only. Do not call directly. */ - -@deprecated("Use type `string` and `String.fromCharCode` instead. This will be removed in v13") -external unsafe_chr: int => char = "%identity" diff --git a/packages/@rescript/runtime/Obj.res b/packages/@rescript/runtime/Obj.res index eacdb95a6e..53edbf22fb 100644 --- a/packages/@rescript/runtime/Obj.res +++ b/packages/@rescript/runtime/Obj.res @@ -5,27 +5,3 @@ type t = Primitive_object_extern.t external magic: 'a => 'b = "%identity" - -@deprecated("Do not use directly. This will be removed in v13") -external repr: 'a => t = "%identity" - -@deprecated("Do not use directly. This will be removed in v13") -external obj: t => 'a = "%identity" - -@deprecated("Do not use directly. This will be removed in v13") -external tag: t => int = "%obj_tag" - -@deprecated("Do not use directly. This will be removed in v13") -external size: t => int = "%obj_size" - -@deprecated("Do not use directly. This will be removed in v13") -external getField: (t, 'a) => t = "%obj_get_field" - -@deprecated("Do not use directly. This will be removed in v13") -external setField: (t, 'a, t) => unit = "%obj_set_field" - -@deprecated("Do not use directly. This will be removed in v13") -external dup: t => t = "%obj_dup" - -@deprecated("Do not use directly. This will be removed in v13") @scope("Object") -external updateDummy: (t, t) => unit = "assign" diff --git a/packages/@rescript/runtime/Pervasives.res b/packages/@rescript/runtime/Pervasives.res index dcd2a29780..1755355cc6 100644 --- a/packages/@rescript/runtime/Pervasives.res +++ b/packages/@rescript/runtime/Pervasives.res @@ -1,6 +1,3 @@ -@deprecated("Do not use. This will be removed in v13") -external __unsafe_cast: 'a => 'b = "%identity" - /* Exceptions */ /** @@ -36,14 +33,6 @@ let invalid_arg = s => throw(Invalid_argument(s)) @deprecated("Use custom exception instead") exception Exit -/* Composition operators */ - -@deprecated("This will be removed in v13") -external \"|>": ('a, 'a => 'b) => 'b = "%revapply" - -@deprecated("This will be removed in v13") -external \"@@": ('a => 'b, 'a) => 'b = "%apply" - /* Debugging */ external __LOC__: string = "%loc_LOC" @@ -101,50 +90,6 @@ external \"&&": (bool, bool) => bool = "%sequand" external \"||": (bool, bool) => bool = "%sequor" -/* Integer operations */ - -@deprecated("Use `x => x + 1` instead. This will be removed in v13") -external succ: int => int = "%succint" - -@deprecated("Use `x => x - 1` instead. This will be removed in v13") -external pred: int => int = "%predint" - -@deprecated("Use `Math.abs` instead. This will be removed in v13") -let abs = x => - if x >= 0 { - x - } else { - -x - } - -@deprecated("Use `Int.bitwiseAnd` instead. This will be removed in v13") -external land: (int, int) => int = "%andint" - -@deprecated("Use `Int.bitwiseOr` instead. This will be removed in v13") -external lor: (int, int) => int = "%orint" - -@deprecated("Use `Int.bitwiseXor` instead. This will be removed in v13") -external lxor: (int, int) => int = "%xorint" - -@deprecated("Use `Int.bitwiseNot` instead. This will be removed in v13") -external lnot: int => int = "%bitnot_int" - -@deprecated("Use `Int.shiftLeft` instead. This will be removed in v13") -external lsl: (int, int) => int = "%lslint" - -@deprecated("Use `Int.shiftRightUnsigned` instead. This will be removed in v13") -external lsr: (int, int) => int = "%lsrint" - -@deprecated("Use `Int.shiftRight` instead. This will be removed in v13") -external asr: (int, int) => int = "%asrint" - -@deprecated("Use `Int.Constants.maxValue` instead. This will be removed in v13") -let max_int = lsr(-1, 1) - -@deprecated("Use `Int.Constants.minValue` instead. This will be removed in v13") -let min_int = - max_int + 1 - /* Floating-point operations */ external \"~-.": float => float = "%negfloat" @@ -154,216 +99,16 @@ external \"-.": (float, float) => float = "%subfloat" external \"*.": (float, float) => float = "%mulfloat" external \"/.": (float, float) => float = "%divfloat" -@deprecated("Use `Math.exp` instead. This will be removed in v13") @val @scope("Math") -external exp: float => float = "exp" - -@deprecated("Use `Math.acos` instead. This will be removed in v13") @val @scope("Math") -external acos: float => float = "acos" - -@deprecated("Use `Math.asin` instead. This will be removed in v13") @val @scope("Math") -external asin: float => float = "asin" - -@deprecated("Use `Math.atan` instead. This will be removed in v13") @val @scope("Math") -external atan: float => float = "atan" - -@deprecated("Use `Math.atan2` instead. This will be removed in v13") @val @scope("Math") -external atan2: (float, float) => float = "atan2" - -@deprecated("Use `Math.cos` instead. This will be removed in v13") @val @scope("Math") -external cos: float => float = "cos" - -@deprecated("Use `Math.cosh` instead. This will be removed in v13") @val @scope("Math") -external cosh: float => float = "cosh" - -@deprecated("Use `Math.log` instead. This will be removed in v13") @val @scope("Math") -external log: float => float = "log" - -@deprecated("Use `Math.log10` instead. This will be removed in v13") @val @scope("Math") -external log10: float => float = "log10" - -@deprecated("Use `Math.log1p` instead. This will be removed in v13") @val @scope("Math") -external log1p: float => float = "log1p" - -@deprecated("Use `Math.sin` instead. This will be removed in v13") @val @scope("Math") -external sin: float => float = "sin" - -@deprecated("Use `Math.sinh` instead. This will be removed in v13") @val @scope("Math") -external sinh: float => float = "sinh" - -@deprecated("Use `Math.sqrt` instead. This will be removed in v13") @val @scope("Math") -external sqrt: float => float = "sqrt" - -@deprecated("Use `Math.tan` instead. This will be removed in v13") @val @scope("Math") -external tan: float => float = "tan" - -@deprecated("Use `Math.tanh` instead. This will be removed in v13") @val @scope("Math") -external tanh: float => float = "tanh" - -@deprecated("Use `Math.ceil` instead. This will be removed in v13") @val @scope("Math") -external ceil: float => float = "ceil" - -@deprecated("Use `Math.floor` instead. This will be removed in v13") @val @scope("Math") -external floor: float => float = "floor" - -@deprecated("Use `Math.abs` instead. This will be removed in v13") @val @scope("Math") -external abs_float: float => float = "abs" - -@deprecated("Use `%` instead. This will be removed in v13") -external mod_float: (float, float) => float = "%modfloat" - -@deprecated("Use `Int.toFloat` instead. This will be removed in v13") -external float: int => float = "%floatofint" - -@deprecated("Use `Int.toFloat` instead. This will be removed in v13") -external float_of_int: int => float = "%floatofint" - -@deprecated("Use `Float.toInt` instead. This will be removed in v13") -external truncate: float => int = "%intoffloat" - -@deprecated("Use `Float.toInt` instead. This will be removed in v13") -external int_of_float: float => int = "%intoffloat" - -@deprecated("Use `Float.positiveInfinity` instead. This will be removed in v13") -let infinity = 0x1p2047 - -@deprecated("Use `Float.negativeInfinity` instead. This will be removed in v13") -let neg_infinity = -0x1p2047 - -@deprecated("Use `Float.nan` instead. This will be removed in v13") @val @scope("Number") -external nan: float = "NaN" - -@deprecated("Use `Float.Constants.maxValue` instead. This will be removed in v13") -let max_float = 1.79769313486231571e+308 /* 0x1.ffff_ffff_ffff_fp+1023 */ - -@deprecated("Use `Float.Constants.minValue` instead. This will be removed in v13") -let min_float = 2.22507385850720138e-308 /* 0x1p-1022 */ - -@deprecated("Use `Float.Constants.epsilon` instead. This will be removed in v13") -let epsilon_float = 2.22044604925031308e-16 /* 0x1p-52 */ - -@deprecated("Do not use. This will be removed in v13") -type fpclass = - | FP_normal - | FP_subnormal - | FP_zero - | FP_infinite - | FP_nan - -@deprecated("Do not use. This will be removed in v13") -let classify_float = (x: float): fpclass => - if (%raw(`isFinite`): _ => _)(x) { - if abs_float(x) >= /* 0x1p-1022 */ /* 2.22507385850720138e-308 */ min_float { - FP_normal - } else if x != 0. { - FP_subnormal - } else { - FP_zero - } - } else if (%raw(`isNaN`): _ => _)(x) { - FP_nan - } else { - FP_infinite - } - /* String and byte sequence operations -- more in modules String and Bytes */ external \"++": (string, string) => string = "%string_concat" -/* Character operations -- more in module Char */ - -@deprecated("Use type `string` and `String.charCodeAt` instead. This will be removed in v13") -external int_of_char: char => int = "%identity" - -@deprecated("Use type `string` and `String.fromCharCode` instead. This will be removed in v13") -external unsafe_char_of_int: int => char = "%identity" - -@deprecated("Use type `string` and `String.fromCharCode` instead. This will be removed in v13") -let char_of_int = n => - if n < 0 || n > 255 { - invalid_arg("char_of_int") - } else { - unsafe_char_of_int(n) - } - /* Unit operations */ external ignore: 'a => unit = "%ignore" -/* Pair operations */ - -@deprecated("Use `Pair.first` instead. This will be removed in v13") -external fst: (('a, 'b)) => 'a = "%field0" - -@deprecated("Use `Pair.second` instead. This will be removed in v13") -external snd: (('a, 'b)) => 'b = "%field1" - /* References */ type ref<'a> = {mutable contents: 'a} external ref: 'a => ref<'a> = "%makeref" external \":=": (ref<'a>, 'a) => unit = "%refset" - -@deprecated("Do not use. This will be removed in v13") -external \"!": ref<'a> => 'a = "%refget" - -@deprecated("Use `Int.Ref.increment` instead. This will be removed in v13") -external incr: ref => unit = "%incr" - -@deprecated("Use `Int.Ref.decrement` instead. This will be removed in v13") -external decr: ref => unit = "%decr" - -/* String conversion functions */ - -@deprecated("Use `Bool.toString` instead. This will be removed in v13") -let string_of_bool = b => - if b { - "true" - } else { - "false" - } - -@deprecated("Use `Bool.fromString` instead. This will be removed in v13") -let bool_of_string = param => - switch param { - | "true" => true - | "false" => false - | _ => invalid_arg("bool_of_string") - } - -@deprecated("Use `Bool.fromString` instead. This will be removed in v13") -let bool_of_string_opt = param => - switch param { - | "true" => Some(true) - | "false" => Some(false) - | _ => None - } - -@deprecated("Use `Int.toString` instead. This will be removed in v13") -external string_of_int: int => string = "String" - -@deprecated("Use `Int.fromString` instead. This will be removed in v13") @scope("Number") -external int_of_string: string => int = "parseInt" - -@deprecated("Use `Int.fromString` instead. This will be removed in v13") -let int_of_string_opt = s => - switch int_of_string(s) { - | n if n == %raw("NaN") => None - | n => Some(n) - } - -@deprecated("Use `String.get` instead. This will be removed in v13") -external string_get: (string, int) => char = "%string_safe_get" - -/* List operations -- more in module List */ - -@deprecated("Use `List.concat` instead. This will be removed in v13") -let rec \"@" = (l1, l2) => - switch l1 { - | list{} => l2 - | list{hd, ...tl} => list{hd, ...\"@"(tl, l2)} - } - -/* Miscellaneous */ - -@deprecated("This will be removed in v13") -type int32 = int diff --git a/packages/@rescript/runtime/Primitive_hash.res b/packages/@rescript/runtime/Primitive_hash.res index 7392af626b..e44a3a73b1 100644 --- a/packages/@rescript/runtime/Primitive_hash.res +++ b/packages/@rescript/runtime/Primitive_hash.res @@ -5,6 +5,7 @@ */ module Float = Primitive_float_extern +module Int = Stdlib_Int module Obj = Primitive_object_extern module String = Primitive_string_extern @@ -69,24 +70,24 @@ let unsafe_pop = (q: t<'a>) => cell.content } -let rotl32 = (x: int, n) => lor(lsl(x, n), lsr(x, 32 - n)) +let rotl32 = (x: int, n) => Int.bitwiseOr(Int.shiftLeft(x, n), Int.shiftRightUnsigned(x, 32 - n)) let hash_mix_int = (h, d) => { let d = ref(d) d.contents = imul(d.contents, 0xcc9e2d51) d.contents = rotl32(d.contents, 15) d.contents = imul(d.contents, 0x1b873593) - let h = ref(lxor(h, d.contents)) + let h = ref(Int.bitwiseXor(h, d.contents)) h.contents = rotl32(h.contents, 13) - h.contents + lsl(h.contents, 2) + 0xe6546b64 + h.contents + Int.shiftLeft(h.contents, 2) + 0xe6546b64 } let hash_final_mix = h => { - let h = ref(lxor(h, lsr(h, 16))) + let h = ref(Int.bitwiseXor(h, Int.shiftRightUnsigned(h, 16))) h.contents = imul(h.contents, 0x85ebca6b) - h.contents = lxor(h.contents, lsr(h.contents, 13)) + h.contents = Int.bitwiseXor(h.contents, Int.shiftRightUnsigned(h.contents, 13)) h.contents = imul(h.contents, 0xc2b2ae35) - lxor(h.contents, lsr(h.contents, 16)) + Int.bitwiseXor(h.contents, Int.shiftRightUnsigned(h.contents, 16)) } let hash_mix_string = (h, s) => { @@ -95,29 +96,35 @@ let hash_mix_string = (h, s) => { let hash = ref(h) for i in 0 to block { let j = 4 * i - let w = lor( - lor(lor(s->charCodeAt(j), lsl(s->charCodeAt(j + 1), 8)), lsl(s->charCodeAt(j + 2), 16)), - lsl(s->charCodeAt(j + 3), 24), + let w = Int.bitwiseOr( + Int.bitwiseOr( + Int.bitwiseOr(s->charCodeAt(j), Int.shiftLeft(s->charCodeAt(j + 1), 8)), + Int.shiftLeft(s->charCodeAt(j + 2), 16), + ), + Int.shiftLeft(s->charCodeAt(j + 3), 24), ) hash.contents = hash_mix_int(hash.contents, w) } - let modulo = land(len, 0b11) + let modulo = Int.bitwiseAnd(len, 0b11) if modulo != 0 { let w = if modulo == 3 { - lor( - lor(lsl(s->charCodeAt(len - 1), 16), lsl(s->charCodeAt(len - 2), 8)), + Int.bitwiseOr( + Int.bitwiseOr( + Int.shiftLeft(s->charCodeAt(len - 1), 16), + Int.shiftLeft(s->charCodeAt(len - 2), 8), + ), s->charCodeAt(len - 3), ) } else if modulo == 2 { - lor(lsl(s->charCodeAt(len - 1), 8), s->charCodeAt(len - 2)) + Int.bitwiseOr(Int.shiftLeft(s->charCodeAt(len - 1), 8), s->charCodeAt(len - 2)) } else { s->charCodeAt(len - 1) } hash.contents = hash_mix_int(hash.contents, w) } - hash.contents = lxor(hash.contents, len) + hash.contents = Int.bitwiseXor(hash.contents, len) hash.contents } @@ -161,7 +168,7 @@ let hash = (count: int, _limit, seed: int, obj: Obj.t): int => { let size = Obj.size(obj) if size != 0 { let obj_tag = Obj.tag(obj) - let tag = lor(lsl(size, 10), obj_tag) + let tag = Int.bitwiseOr(Int.shiftLeft(size, 10), obj_tag) s.contents = hash_mix_int(s.contents, tag) let block = { let v = size - 1 @@ -183,7 +190,7 @@ let hash = (count: int, _limit, seed: int, obj: Obj.t): int => { } return size }`)(obj, v => push_back(queue, v)) - s.contents = hash_mix_int(s.contents, lor(lsl(size, 10), 0)) /* tag */ + s.contents = hash_mix_int(s.contents, Int.shiftLeft(size, 10)) /* tag */ } } } diff --git a/packages/@rescript/runtime/Stdlib_Array.res b/packages/@rescript/runtime/Stdlib_Array.res index eae6ac01bc..fc639b5a55 100644 --- a/packages/@rescript/runtime/Stdlib_Array.res +++ b/packages/@rescript/runtime/Stdlib_Array.res @@ -6,8 +6,6 @@ type arrayLike<'a> external getUnsafe: (array<'a>, int) => 'a = "%array_unsafe_get" external setUnsafe: (array<'a>, int, 'a) => unit = "%array_unsafe_set" -external unsafe_get: (array<'a>, int) => 'a = "%array_unsafe_get" - external asIterable: array<'a> => Stdlib_Iterable.t<'a> = "%identity" @val diff --git a/packages/@rescript/runtime/Stdlib_Array.resi b/packages/@rescript/runtime/Stdlib_Array.resi index f6e2f09154..d411a10b54 100644 --- a/packages/@rescript/runtime/Stdlib_Array.resi +++ b/packages/@rescript/runtime/Stdlib_Array.resi @@ -424,7 +424,7 @@ See [`Array.sort`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Refer ```rescript let array = [3, 2, 1] -array->Array.sort((a, b) => float(a - b)) +array->Array.sort((a, b) => Int.toFloat(a - b)) array == [1, 2, 3] ``` */ @@ -1329,29 +1329,6 @@ for index in 0 to array->Array.length - 1 { */ external getUnsafe: (array<'a>, int) => 'a = "%array_unsafe_get" -/** -`unsafe_get(array, index)` returns the element at `index` of `array`. - -This is _unsafe_, meaning it will return `undefined` value if `index` does not exist in `array`. - -Use `Array.unsafe_get` only when you are sure the `index` exists (i.e. when using for-loop). - -## Examples - -```rescript -let array = [1, 2, 3] -for index in 0 to array->Array.length - 1 { - let value = array->Array.unsafe_get(index) - Console.log(value) -} -``` -*/ -@deprecated({ - reason: "Use getUnsafe instead. This will be removed in v13", - migrate: Array.getUnsafe(), -}) -external unsafe_get: (array<'a>, int) => 'a = "%array_unsafe_get" - /** `setUnsafe(array, index, item)` sets the provided `item` at `index` of `array`. diff --git a/packages/@rescript/runtime/Stdlib_List.resi b/packages/@rescript/runtime/Stdlib_List.resi index 8d9e81554e..ddd9721b1f 100644 --- a/packages/@rescript/runtime/Stdlib_List.resi +++ b/packages/@rescript/runtime/Stdlib_List.resi @@ -750,7 +750,7 @@ List.equal(list{1, 2, 3}, list{1, 2}, (a, b) => a == b) == false List.equal(list{1, 2}, list{1, 2}, (a, b) => a == b) == true -List.equal(list{1, 2, 3}, list{-1, -2, -3}, (a, b) => abs(a) == abs(b)) == true +List.equal(list{1, 2, 3}, list{-1, -2, -3}, (a, b) => Math.Int.abs(a) == Math.Int.abs(b)) == true ``` */ let equal: (list<'a>, list<'a>, ('a, 'a) => bool) => bool @@ -768,7 +768,7 @@ list{1, 2, 3}->List.has(2, (a, b) => a == b) == true list{1, 2, 3}->List.has(4, (a, b) => a == b) == false -list{-1, -2, -3}->List.has(2, (a, b) => abs(a) == abs(b)) == true +list{-1, -2, -3}->List.has(2, (a, b) => Math.Int.abs(a) == Math.Int.abs(b)) == true ``` */ @deprecated("Use `some` instead") diff --git a/packages/@rescript/runtime/Stdlib_Result.resi b/packages/@rescript/runtime/Stdlib_Result.resi index 15142d1747..f475b62ce1 100644 --- a/packages/@rescript/runtime/Stdlib_Result.resi +++ b/packages/@rescript/runtime/Stdlib_Result.resi @@ -100,7 +100,7 @@ ordinary value. ## Examples ```rescript -let f = x => sqrt(Int.toFloat(x)) +let f = x => Math.sqrt(Int.toFloat(x)) Result.map(Ok(64), f) == Ok(8.0) diff --git a/packages/@rescript/runtime/lib/es6/Char.mjs b/packages/@rescript/runtime/lib/es6/Char.mjs deleted file mode 100644 index b2a6536046..0000000000 --- a/packages/@rescript/runtime/lib/es6/Char.mjs +++ /dev/null @@ -1,88 +0,0 @@ - - - -function escaped(param) { - let exit = 0; - if (param >= 40) { - if (param === 92) { - return "\\\\"; - } - exit = param >= 127 ? 1 : 2; - } else if (param >= 32) { - if (param >= 39) { - return "\\'"; - } - exit = 2; - } else if (param >= 14) { - exit = 1; - } else { - switch (param) { - case 8 : - return "\\b"; - case 9 : - return "\\t"; - case 10 : - return "\\n"; - case 0 : - case 1 : - case 2 : - case 3 : - case 4 : - case 5 : - case 6 : - case 7 : - case 11 : - case 12 : - exit = 1; - break; - case 13 : - return "\\r"; - } - } - switch (exit) { - case 1 : - let s = Array(4); - s[0] = /* '\\' */92; - s[1] = 48 + (param / 100 | 0) | 0; - s[2] = 48 + (param / 10 | 0) % 10 | 0; - s[3] = 48 + param % 10 | 0; - return String.fromCodePoint(...s); - case 2 : - let s$1 = Array(1); - s$1[0] = param; - return String.fromCodePoint(...s$1); - } -} - -function lowercase_ascii(c) { - if (c >= /* 'A' */65 && c <= /* 'Z' */90) { - return c + 32 | 0; - } else { - return c; - } -} - -function uppercase_ascii(c) { - if (c >= /* 'a' */97 && c <= /* 'z' */122) { - return c - 32 | 0; - } else { - return c; - } -} - -function compare(c1, c2) { - return c1 - c2 | 0; -} - -function equal(c1, c2) { - return (c1 - c2 | 0) === 0; -} - -export { - escaped, - lowercase_ascii, - uppercase_ascii, - compare, - equal, -} -/* No side effect */ diff --git a/packages/@rescript/runtime/lib/es6/Pervasives.mjs b/packages/@rescript/runtime/lib/es6/Pervasives.mjs index 6228bfa598..94da1e0685 100644 --- a/packages/@rescript/runtime/lib/es6/Pervasives.mjs +++ b/packages/@rescript/runtime/lib/es6/Pervasives.mjs @@ -20,127 +20,9 @@ function invalid_arg(s) { let Exit = /* @__PURE__ */Primitive_exceptions.create("Pervasives.Exit"); -function abs(x) { - if (x >= 0) { - return x; - } else { - return -x | 0; - } -} - -let min_int = -2147483648; - -function classify_float(x) { - if (isFinite(x)) { - if (Math.abs(x) >= 2.22507385850720138e-308) { - return "FP_normal"; - } else if (x !== 0) { - return "FP_subnormal"; - } else { - return "FP_zero"; - } - } else if (isNaN(x)) { - return "FP_nan"; - } else { - return "FP_infinite"; - } -} - -function char_of_int(n) { - if (n < 0 || n > 255) { - throw { - RE_EXN_ID: "Invalid_argument", - _1: "char_of_int", - Error: new Error() - }; - } - return n; -} - -function string_of_bool(b) { - if (b) { - return "true"; - } else { - return "false"; - } -} - -function bool_of_string(param) { - switch (param) { - case "false" : - return false; - case "true" : - return true; - default: - throw { - RE_EXN_ID: "Invalid_argument", - _1: "bool_of_string", - Error: new Error() - }; - } -} - -function bool_of_string_opt(param) { - switch (param) { - case "false" : - return false; - case "true" : - return true; - default: - return; - } -} - -function int_of_string_opt(s) { - let n = Number.parseInt(s); - if (n === NaN) { - return; - } else { - return n; - } -} - -function $at(l1, l2) { - if (l1 !== 0) { - return { - hd: l1.hd, - tl: $at(l1.tl, l2) - }; - } else { - return l2; - } -} - -let max_int = 2147483647; - -let infinity = Infinity; - -let neg_infinity = -Infinity; - -let max_float = 1.79769313486231571e+308; - -let min_float = 2.22507385850720138e-308; - -let epsilon_float = 2.22044604925031308e-16; - export { failwith, invalid_arg, Exit, - abs, - max_int, - min_int, - infinity, - neg_infinity, - max_float, - min_float, - epsilon_float, - classify_float, - char_of_int, - string_of_bool, - bool_of_string, - bool_of_string_opt, - int_of_string_opt, - $at, } /* No side effect */ diff --git a/packages/@rescript/runtime/lib/es6/Primitive_hash.mjs b/packages/@rescript/runtime/lib/es6/Primitive_hash.mjs index e085228b1b..f5bb46354f 100644 --- a/packages/@rescript/runtime/lib/es6/Primitive_hash.mjs +++ b/packages/@rescript/runtime/lib/es6/Primitive_hash.mjs @@ -36,7 +36,7 @@ function unsafe_pop(q) { RE_EXN_ID: "Assert_failure", _1: [ "Primitive_hash.res", - 58, + 59, 12 ], Error: new Error() @@ -133,7 +133,7 @@ function hash(count, _limit, seed, obj) { } return size })(obj$1, v => push_back(queue, v)); - s = hash_mix_int(s, (size$1 << 10) | 0); + s = hash_mix_int(s, (size$1 << 10)); } } }; diff --git a/packages/@rescript/runtime/lib/js/Char.cjs b/packages/@rescript/runtime/lib/js/Char.cjs deleted file mode 100644 index e854a99cd0..0000000000 --- a/packages/@rescript/runtime/lib/js/Char.cjs +++ /dev/null @@ -1,86 +0,0 @@ -'use strict'; - - -function escaped(param) { - let exit = 0; - if (param >= 40) { - if (param === 92) { - return "\\\\"; - } - exit = param >= 127 ? 1 : 2; - } else if (param >= 32) { - if (param >= 39) { - return "\\'"; - } - exit = 2; - } else if (param >= 14) { - exit = 1; - } else { - switch (param) { - case 8 : - return "\\b"; - case 9 : - return "\\t"; - case 10 : - return "\\n"; - case 0 : - case 1 : - case 2 : - case 3 : - case 4 : - case 5 : - case 6 : - case 7 : - case 11 : - case 12 : - exit = 1; - break; - case 13 : - return "\\r"; - } - } - switch (exit) { - case 1 : - let s = Array(4); - s[0] = /* '\\' */92; - s[1] = 48 + (param / 100 | 0) | 0; - s[2] = 48 + (param / 10 | 0) % 10 | 0; - s[3] = 48 + param % 10 | 0; - return String.fromCodePoint(...s); - case 2 : - let s$1 = Array(1); - s$1[0] = param; - return String.fromCodePoint(...s$1); - } -} - -function lowercase_ascii(c) { - if (c >= /* 'A' */65 && c <= /* 'Z' */90) { - return c + 32 | 0; - } else { - return c; - } -} - -function uppercase_ascii(c) { - if (c >= /* 'a' */97 && c <= /* 'z' */122) { - return c - 32 | 0; - } else { - return c; - } -} - -function compare(c1, c2) { - return c1 - c2 | 0; -} - -function equal(c1, c2) { - return (c1 - c2 | 0) === 0; -} - -exports.escaped = escaped; -exports.lowercase_ascii = lowercase_ascii; -exports.uppercase_ascii = uppercase_ascii; -exports.compare = compare; -exports.equal = equal; -/* No side effect */ diff --git a/packages/@rescript/runtime/lib/js/Pervasives.cjs b/packages/@rescript/runtime/lib/js/Pervasives.cjs index 45aadb5238..608a207f36 100644 --- a/packages/@rescript/runtime/lib/js/Pervasives.cjs +++ b/packages/@rescript/runtime/lib/js/Pervasives.cjs @@ -20,125 +20,7 @@ function invalid_arg(s) { let Exit = /* @__PURE__ */Primitive_exceptions.create("Pervasives.Exit"); -function abs(x) { - if (x >= 0) { - return x; - } else { - return -x | 0; - } -} - -let min_int = -2147483648; - -function classify_float(x) { - if (isFinite(x)) { - if (Math.abs(x) >= 2.22507385850720138e-308) { - return "FP_normal"; - } else if (x !== 0) { - return "FP_subnormal"; - } else { - return "FP_zero"; - } - } else if (isNaN(x)) { - return "FP_nan"; - } else { - return "FP_infinite"; - } -} - -function char_of_int(n) { - if (n < 0 || n > 255) { - throw { - RE_EXN_ID: "Invalid_argument", - _1: "char_of_int", - Error: new Error() - }; - } - return n; -} - -function string_of_bool(b) { - if (b) { - return "true"; - } else { - return "false"; - } -} - -function bool_of_string(param) { - switch (param) { - case "false" : - return false; - case "true" : - return true; - default: - throw { - RE_EXN_ID: "Invalid_argument", - _1: "bool_of_string", - Error: new Error() - }; - } -} - -function bool_of_string_opt(param) { - switch (param) { - case "false" : - return false; - case "true" : - return true; - default: - return; - } -} - -function int_of_string_opt(s) { - let n = Number.parseInt(s); - if (n === NaN) { - return; - } else { - return n; - } -} - -function $at(l1, l2) { - if (l1 !== 0) { - return { - hd: l1.hd, - tl: $at(l1.tl, l2) - }; - } else { - return l2; - } -} - -let max_int = 2147483647; - -let infinity = Infinity; - -let neg_infinity = -Infinity; - -let max_float = 1.79769313486231571e+308; - -let min_float = 2.22507385850720138e-308; - -let epsilon_float = 2.22044604925031308e-16; - exports.failwith = failwith; exports.invalid_arg = invalid_arg; exports.Exit = Exit; -exports.abs = abs; -exports.max_int = max_int; -exports.min_int = min_int; -exports.infinity = infinity; -exports.neg_infinity = neg_infinity; -exports.max_float = max_float; -exports.min_float = min_float; -exports.epsilon_float = epsilon_float; -exports.classify_float = classify_float; -exports.char_of_int = char_of_int; -exports.string_of_bool = string_of_bool; -exports.bool_of_string = bool_of_string; -exports.bool_of_string_opt = bool_of_string_opt; -exports.int_of_string_opt = int_of_string_opt; -exports.$at = $at; /* No side effect */ diff --git a/packages/@rescript/runtime/lib/js/Primitive_hash.cjs b/packages/@rescript/runtime/lib/js/Primitive_hash.cjs index cc87d55531..0d16c8972f 100644 --- a/packages/@rescript/runtime/lib/js/Primitive_hash.cjs +++ b/packages/@rescript/runtime/lib/js/Primitive_hash.cjs @@ -36,7 +36,7 @@ function unsafe_pop(q) { RE_EXN_ID: "Assert_failure", _1: [ "Primitive_hash.res", - 58, + 59, 12 ], Error: new Error() @@ -133,7 +133,7 @@ function hash(count, _limit, seed, obj) { } return size })(obj$1, v => push_back(queue, v)); - s = hash_mix_int(s, (size$1 << 10) | 0); + s = hash_mix_int(s, (size$1 << 10)); } } }; diff --git a/packages/artifacts.json b/packages/artifacts.json index 135b8da7f6..074d94e85c 100644 --- a/packages/artifacts.json +++ b/packages/artifacts.json @@ -18,7 +18,6 @@ "package.json" ], "@rescript/runtime": [ - "lib/es6/Char.mjs", "lib/es6/Dom.mjs", "lib/es6/Dom_storage.mjs", "lib/es6/Dom_storage2.mjs", @@ -126,7 +125,6 @@ "lib/es6/Stdlib_Uint8ClampedArray.mjs", "lib/es6/Stdlib_WeakMap.mjs", "lib/es6/Stdlib_WeakSet.mjs", - "lib/js/Char.cjs", "lib/js/Dom.cjs", "lib/js/Dom_storage.cjs", "lib/js/Dom_storage2.cjs", @@ -234,12 +232,6 @@ "lib/js/Stdlib_Uint8ClampedArray.cjs", "lib/js/Stdlib_WeakMap.cjs", "lib/js/Stdlib_WeakSet.cjs", - "lib/ocaml/Char.cmi", - "lib/ocaml/Char.cmj", - "lib/ocaml/Char.cmt", - "lib/ocaml/Char.cmti", - "lib/ocaml/Char.res", - "lib/ocaml/Char.resi", "lib/ocaml/Dom.cmi", "lib/ocaml/Dom.cmj", "lib/ocaml/Dom.cmt", diff --git a/tests/analysis_tests/tests-reanalyze/deadcode/expected/deadcode.txt b/tests/analysis_tests/tests-reanalyze/deadcode/expected/deadcode.txt index 79e44acd7a..44742ae6a5 100644 --- a/tests/analysis_tests/tests-reanalyze/deadcode/expected/deadcode.txt +++ b/tests/analysis_tests/tests-reanalyze/deadcode/expected/deadcode.txt @@ -2120,19 +2120,18 @@ Forward Liveness Analysis Root (external ref): VariantCase DeadRT.moduleAccessPath.Root Root (external ref): Value +TypeReexport.VariantUseOriginal.+value Root (annotated): Value +NestedModules.Universe.Nested2.Nested3.+nested3Function - Root (annotated): Value +Records.+someBusiness2 Root (annotated): Value +Types.+setMatch - Root (annotated): Value +Uncurried.+sumCurried + Root (annotated): Value +Docstrings.+oneU Root (annotated): Value +ImportJsValue.+areaValue + Root (annotated): Value +Uncurried.+callback2 Root (annotated): Value +Types.+testConvertNull Root (external ref): Value +CreateErrorHandler2.Error2.+notification Root (annotated): Value +ScopedAnnotationsOverride.M.+live1 Root (annotated): Value +VariantsWithPayload.+testSimpleVariant - Root (annotated): Value +Docstrings.+twoU Root (external ref): RecordLabel +TypeReexportCrossFileB.reexportedRecord.usedField Root (annotated): Value +NestedModules.Universe.Nested2.+nested2Function Root (external ref): Value +OptArg.+wrapfourArgs - Root (annotated): Value +Docstrings.+unitArgWithoutConversionU + Root (annotated): Value +Records.+getPayloadRecordPlusOne Root (external ref): Value +InterfaceOptionalArgEscape.+escaped Root (external ref): VariantCase +DeadTypeTest.deadType.OnlyInImplementation Root (annotated): Value +TestImport.+valueStartingWithUpperCaseLetter @@ -2150,16 +2149,15 @@ Forward Liveness Analysis Root (annotated): Value +LetPrivate.+y Root (annotated): Value +TestImport.+innerStuffContentsAsEmptyObject Root (annotated): Value +Types.+testFunctionOnOptionsAsArgument - Root (annotated): Value +Docstrings.+two - Root (annotated): Value +Uncurried.+uncurried3 + Root (annotated): Value +Records.+testMyObj2 Root (external ref): Value +Newton.+f - Root (external ref): RecordLabel +Records.record.v Root (external ref): Value +ContextOptionalArgs.ComponentUsingAction.+make Root (external ref): RecordLabel +Records.person.address Root (external ref): RecordLabel +ContextOptionalArgs.NotificationProvider.props.children Root (annotated): Value +Variants.+testConvert2 Root (annotated): Value +Tuples.+coord2d Root (external ref): Value +CreateErrorHandler1.Error1.+notification + Root (external ref): RecordLabel +Records.business2.address2 Root (annotated): Value +TransitiveType3.+convertT3 Root (annotated): Value +Variants.+swap Root (annotated): Value +Shadow.+test @@ -2168,40 +2166,38 @@ Forward Liveness Analysis Root (annotated): Value +NestedModules.+notNested Root (annotated): Value +Records.+computeArea Root (external ref): RecordLabel +TypeReexport.UseOriginal.reexportedType.directlyUsed + Root (annotated): Value +Docstrings.+useParam + Root (annotated): Value +Docstrings.+unitArgWithConversion + Root (annotated): Value +Docstrings.+unitArgWithConversionU Root (annotated): Value +ImportJsValue.+convertVariant - Root (annotated): Value +Uncurried.+curried3 - Root (annotated): Value +Docstrings.+tree Root (annotated): Value +ImportHooks.+foo Root (annotated): RecordLabel +ImportIndex.props.method - Root (annotated): Value +Docstrings.+unnamed2U Root (external ref): RecordLabel +RecordRest.config.name - Root (annotated): Value +Records.+testMyRecBsAs Root (external ref): Value +FirstClassModules.M.Z.+u - Root (annotated): Value +Uncurried.+callback2U + Root (annotated): Value +Records.+findAddress2 Root (annotated): Value +ImportJsValue.+default Root (external ref): Value +DynamicallyLoadedComponent.+make Root (annotated): Value +Hooks.RenderPropRequiresConversion.+make - Root (annotated): Value +Uncurried.+uncurried2 Root (annotated): Value +UseImportJsValue.+useTypeImportedInOtherModule Root (annotated): Value +Hooks.Inner.+make Root (external ref): RecordLabel +DeadTest.inlineRecord.IR.c Root (external ref): Value +OptArg.+foo + Root (annotated): Value +Records.+someBusiness2 Root (annotated): Value +Variants.+fortytwoOK Root (annotated): Value +TestOptArg.+liveSuppressesOptArgs - Root (annotated): Value +Uncurried.+sumU2 Root (external ref): Value OptArg.+bar Root (external ref): Value +TopLevelOptionalArgValueUse.+liveAliasCaller - Root (annotated): Value +Records.+payloadValue Root (annotated): Value +Hooks.+default Root (annotated): Value +Types.+currentTime - Root (annotated): Value +VariantsWithPayload.+testVariant1Object + Root (external ref): RecordLabel +Records.myRec.type_ Root (external ref): VariantCase +Unison.break_.Never Root (external ref): Value +ContextOptionalArgs.NotificationProvider.+make - Root (annotated): Value +Records.+computeArea3 Root (annotated): Value +TestEmitInnerModules.Inner.+y Root (external ref): VariantCase InnerModuleTypes.I.t.Foo Root (annotated): Value +Types.+selfRecursiveConverter + Root (annotated): Value +Uncurried.+sumLblCurried Root (annotated): Value +Opaque.+testConvertNestedRecordFromOtherFile + Root (annotated): Value +Docstrings.+two Root (external ref): Value +ReturnedOptionalSignatureUse.+useInterfaceDeclaration Root (external ref): RecordLabel +DeadTest.inlineRecord.IR.b Root (external ref): Value +OptArg.+bar @@ -2216,6 +2212,7 @@ Forward Liveness Analysis Root (external ref): VariantCase +DeadTest.VariantUsedOnlyInImplementation.t.A Root (external ref): RecordLabel +Records.coord.x Root (annotated): RecordLabel +DeadTypeTest.record.y + Root (annotated): Value +Records.+testMyRecBsAs2 Root (annotated): Value +TestImport.+defaultValue Root (annotated): Value +DeadTest.GloobLive.+globallyLive2 Root (external ref): RecordLabel +TypeReexport.UseReexported.reexportedType.usedField @@ -2233,16 +2230,16 @@ Forward Liveness Analysis Root (external ref): VariantCase +DeadTest.WithInclude.t.A Root (annotated): Value +Records.+origin Root (annotated): Value +Variants.+onlySunday - Root (annotated): Value +Docstrings.+treeU - Root (annotated): Value +Docstrings.+unnamed1 Root (annotated): Value +TypeParams3.+test2 Root (annotated): Value +Tuples.+origin - Root (annotated): Value +Docstrings.+unitArgWithConversionU - Root (annotated): Value +Records.+computeArea4 + Root (annotated): Value +Records.+getPayloadRecord Root (annotated): Value +Tuples.+computeArea Root (annotated): Value +References.+get + Root (annotated): Value +Docstrings.+unnamed1 Root (annotated): Value +ModuleAliases.+testNested + Root (annotated): Value +Docstrings.+twoU Root (external ref): Value +OptArg.+threeArgs + Root (annotated): Value +Records.+computeArea3 Root (annotated): Value +Types.+jsonStringify Root (external ref): Value +FirstClassModules.SomeFunctor.+ww Root (annotated): Value +Types.+testMarshalFields @@ -2250,7 +2247,6 @@ Forward Liveness Analysis Root (annotated): Value +ImportJsValue.+area Root (external ref): Value +TopLevelOptionalArgValueUse.+mutuallyRecursiveCaller Root (external ref): Value +DeadTest.MM.+x - Root (external ref): RecordLabel +Uncurried.auth.login Root (annotated): Value +ImportJsValue.+roundedNumber Root (external ref): RecordLabel +RepeatedLabel.tabState.a Root (external ref): Value +ReturnedOptionalSignatureUse.+useInlineSignature @@ -2266,18 +2262,18 @@ Forward Liveness Analysis Root (annotated): Value +Hooks.NoProps.+make Root (annotated): Value +ImportJsValue.+useGetProp Root (annotated): Value +Variants.+id2 - Root (annotated): Value +Uncurried.+sumU + Root (annotated): Value +Docstrings.+unnamed1U Root (annotated): Value +DeadTest.+thisIsMarkedLive - Root (annotated): Value +Docstrings.+one + Root (external ref): RecordLabel +Uncurried.authU.loginU + Root (annotated): Value +VariantsWithPayload.+testVariant1Int Root (annotated): Value +OcamlWarningSuppressToplevel.+suppressed1 + Root (annotated): Value +Uncurried.+sumCurried Root (external ref): Value +TopLevelOptionalArgValueUse.+liveCaller Root (annotated): Value +Tuples.+testTuple Root (external ref): Value +ContextOptionalArgs.NotificationProvider.+dispatchNotification Root (external ref): Value +OptArg.+wrapOneArg - Root (annotated): Value +Uncurried.+callback2 Root (annotated): Value +ImportMyBanner.+make Root (annotated): Value +VariantsWithPayload.+testVariantWithPayloads - Root (external ref): RecordLabel +Records.payload.payload Root (annotated): Value +Tuples.+marry Root (annotated): Value +ImportJsValue.+returnMixedArray Root (annotated): Value +TestEmitInnerModules.Outer.Medium.Inner.+y @@ -2286,62 +2282,59 @@ Forward Liveness Analysis Root (external ref): RecordLabel +ComponentAsProp.props.title Root (external ref): Value +ContextOptionalArgs.ComponentUsingAction.+dispatchNotification Root (annotated): Value +Records.+findAddress - Root (annotated): Value +Uncurried.+callback Root (external ref): Value +DeadTest.+thisIsUsedTwice Root (annotated): Value +VariantsWithPayload.+printVariantWithPayload + Root (annotated): Value +VariantsWithPayload.+testVariant1Object Root (annotated): Value +TestImmutableArray.+testImmutableArrayGet Root (annotated): Value +VariantsWithPayload.+printManyPayloads Root (external ref): Value +TopLevelOptionalArgValueUse.+formatDateTopLevelEscape Root (external ref): Value +TypeReexport.UseOriginal.+value - Root (annotated): Value +Docstrings.+unnamed2 Root (annotated): Value +LetPrivate.local_1.+x Root (annotated): Value +TestImport.+make Root (external ref): Value +ContextOptionalArgs.NotificationProvider.Provider.+make - Root (annotated): Value +Docstrings.+grouped Root (annotated): Value +OcamlWarningSuppressToplevel.M.+suppressed4 Root (external ref): VariantCase +DeadTest.inlineRecord.IR - Root (annotated): Value +Records.+getPayloadRecordPlusOne Root (annotated): Value +Types.+swap Root (annotated): RecordLabel +ImportHookDefault.props.person Root (annotated): Value +Variants.+saturday - Root (external ref): VariantCase +Docstrings.t.A Root (annotated): Value +OcamlWarningSuppressToplevel.M.+suppressed3 Root (annotated): Value +Uncurried.+uncurried0 Root (annotated): Value +Records.+someBusiness + Root (annotated): Value +Records.+computeArea4 Root (external ref): RecordLabel +Hooks.vehicle.name Root (external ref): RecordLabel +Tuples.person.age Root (annotated): Value +RecordRest.+getRest Root (annotated): Value +References.+preserveRefIdentity Root (annotated): Value +Variants.+restResult1 Root (external ref): Value +TestOptArg.+notSuppressesOptArgs - Root (external ref): RecordLabel +Records.myRecBsAs.type_ Root (external ref): VariantCase +TypeReexport.VariantUseReexported.reexportedType.A Root (external ref): Value +Unison.+toString Root (annotated): Value +ImportJsValue.+polymorphic Root (annotated): Value +References.+set - Root (annotated): Value +Records.+testMyRecBsAs2 + Root (external ref): VariantCase +Docstrings.t.A Root (annotated): Value +ModuleAliases.+testInner Root (external ref): RecordLabel +ComponentAsProp.props.description - Root (annotated): Value +Docstrings.+useParamU Root (annotated): Value +ImportJsValue.+useColor + Root (annotated): Value +Uncurried.+sumU Root (external ref): Value +Unison.+group Root (external ref): RecordLabel +RecordRest.SubConfig.t.version - Root (annotated): Value +Docstrings.+unnamed1U - Root (annotated): Value +Records.+recordValue + Root (annotated): Value +Uncurried.+uncurried2 + Root (annotated): Value +Uncurried.+sumU2 Root (annotated): Value +ImportHookDefault.+make Root (annotated): Value +Types.+map Root (annotated): RecordLabel +DeadTypeTest.record.x Root (external ref): Value +TestOptArg.+bar Root (external ref): Value +ContextOptionalArgs.ComponentNotUsingAction.+make - Root (external ref): RecordLabel +Records.myRec.type_ + Root (annotated): Value +Records.+testMyRec Root (external ref): Value +DeadTest.+make Root (annotated): Value NestedModulesInSignature.Universe.+theAnswer - Root (annotated): Value +Docstrings.+unitArgWithoutConversion Root (annotated): Value +ContextOptionalArgs.+make Root (annotated): Value +References.+create Root (external ref): Value +InterfaceOptionalArgEscapeUse.+use Root (external ref): Value +TopLevelOptionalArgValueUse.+liveEscapeCaller + Root (annotated): Value +Docstrings.+unnamed2U Root (annotated): Value +FirstClassModules.+testConvert + Root (annotated): Value +Docstrings.+unnamed2 Root (external ref): Value +TopLevelOptionalArgValueUse.+liveTupleCaller Root (external ref): RecordLabel +Records.coord.z Root (annotated): Value +Types.+someIntList @@ -2359,16 +2352,19 @@ Forward Liveness Analysis Root (annotated): RecordLabel +ImportHooks.props.children Root (external ref): RecordLabel +DeadTest.props.s Root (external ref): VariantCase +DeadTypeTest.t.A - Root (annotated): Value +Docstrings.+oneU + Root (annotated): Value +Docstrings.+unitArgWithoutConversion Root (annotated): RecordLabel +DeadTypeTest.record.z - Root (annotated): Value +Records.+testMyObj2 Root (annotated): Value +Docstrings.+flat Root (annotated): Value +NestedModules.Universe.Nested2.+nested2Value - Root (external ref): RecordLabel +Records.business2.address2 Root (external ref): VariantCase DeadTypeTest.deadType.InBoth + Root (annotated): Value +Docstrings.+one + Root (external ref): RecordLabel +Records.payload.payload Root (annotated): Value +ScopedAnnotationsOverride.M.+live2 Root (annotated): Value +FirstClassModules.+someFunctorAsFunction + Root (external ref): RecordLabel +Records.record.v Root (annotated): Value +Variants.+fortytwoBAD + Root (annotated): Value +Records.+testMyRec2 + Root (annotated): Value +Records.+recordValue Root (external ref): RecordLabel +Unison.t.break_ Root (external ref): RecordLabel +Hooks.Inner.props.vehicle Root (external ref): Value ImmutableArray.+fromArray @@ -2376,35 +2372,38 @@ Forward Liveness Analysis Root (annotated): Value +Variants.+testConvert2to3 Root (external ref): Value +DeadTest.+thisIsUsedOnce Root (annotated): Value +ImportJsValue.+round + Root (annotated): Value +Docstrings.+unitArgWithoutConversionU Root (annotated): Value +TestModuleAliases.+testInner2 + Root (annotated): Value +Uncurried.+uncurried3 Root (annotated): Value +Tuples.+getFirstName Root (annotated): Value +TestFirstClassModules.+convert - Root (annotated): Value +Records.+testMyRec Root (external ref): VariantCase +DeadRT.moduleAccessPath.Kaboom Root (external ref): Value +TypeReexport.UseReexported.+value Root (external ref): Value +DeadTest.+deadIncorrect Root (external ref): Value +DeadCodeImplementation.M.+x Root (annotated): Value +Variants.+restResult2 - Root (annotated): Value +Docstrings.+useParam - Root (annotated): Value +Records.+getPayload + Root (annotated): Value +Uncurried.+curried3 Root (external ref): Value +TopLevelOptionalArgValueUse.+liveReturnedFunctionCaller Root (annotated): Value +VariantsWithPayload.+printVariantWithPayloads + Root (annotated): Value +Docstrings.+tree Root (annotated): Value +ScopedAnnotationsOverride.M.NestedInLive.+nestedLive + Root (annotated): Value +Docstrings.+treeU Root (external ref): Value +FirstClassModules.M.+y - Root (annotated): Value +Records.+findAddress2 - Root (external ref): RecordLabel +Uncurried.authU.loginU Root (external ref): RecordLabel +Tuples.person.name + Root (annotated): Value +Records.+testMyRecBsAs Root (annotated): Value +ModuleAliases.+testInner2 Root (annotated): RecordLabel +ImportHooks.props.person Root (external ref): Value DeadValueTest.+valueAlive Root (external ref): Value +DeadTest.+ira Root (external ref): RecordLabel +Hooks.RenderPropRequiresConversion.props.renderVehicle Root (annotated): Value +Shadow.M.+test - Root (annotated): Value +Uncurried.+sumLblCurried Root (annotated): Value +ComponentAsProp.+make Root (annotated): Value +TestFirstClassModules.+convertFirstClassModuleWithTypeEquations + Root (annotated): Value +Docstrings.+grouped Root (annotated): Value +TransitiveType1.+convertAlias + Root (annotated): Value +Records.+payloadValue Root (annotated): Value +ForOf.+keep + Root (external ref): RecordLabel +Uncurried.auth.login Root (external ref): VariantCase +Unison.stack.Cons Root (external ref): Exception +DeadExn.Inside.Einside Root (annotated): Value +TestImport.+defaultValue2 @@ -2413,12 +2412,12 @@ Forward Liveness Analysis Root (annotated): Value +Variants.+monday Root (annotated): Value +Unboxed.+r2Test Root (external ref): RecordLabel +Records.coord.y - Root (annotated): Value +Records.+testMyObj Root (annotated): Value +TestPromise.+convert Root (annotated): Value +FirstClassModules.+firstClassModule Root (external ref): RecordLabel +Hooks.props.vehicle Root (external ref): Value +DeadTest.VariantUsedOnlyInImplementation.+a Root (annotated): Value +ImportJsValue.+useGetAbs + Root (annotated): Value +Docstrings.+useParamU Root (external ref): Value +JsxV4.C.+make Root (external ref): RecordLabel +Types.selfRecursive.self Root (external ref): VariantCase +TypeReexport.VariantUseOriginal.reexportedType.A @@ -2426,13 +2425,13 @@ Forward Liveness Analysis Root (annotated): Value +References.+destroysRefIdentity Root (external ref): Value +Hooks.RenderPropRequiresConversion.+car Root (external ref): Value +OptArg.+twoArgs + Root (external ref): RecordLabel +Records.myRecBsAs.type_ Root (external ref): Value +FirstClassModules.M.+x Root (external ref): Value +TypeReexportCrossFileB.+recordValue Root (external ref): Value +InterfaceOptionalArgEscape.+takesFn Root (annotated): Value +TestModuleAliases.+testInner1Expanded Root (external ref): Value +TypeReexport.OnlyReexportedDead.+value Root (annotated): Value +DeadTest.GloobLive.+globallyLive3 - Root (annotated): Value +VariantsWithPayload.+testVariant1Int Root (annotated): Value +ImportIndex.+make Root (annotated): Value +Unboxed.+testV1 Root (annotated): Value +NestedModules.Universe.+theAnswer @@ -2446,20 +2445,21 @@ Forward Liveness Analysis Root (annotated): Value +Opaque.+noConversion Root (external ref): RecordLabel +RepeatedLabel.tabState.b Root (annotated): Value +VariantsWithPayload.+testManyPayloads + Root (annotated): Value +Records.+getPayload + Root (annotated): Value +Uncurried.+callback Root (external ref): RecordLabel +TypeReexport.OnlyReexportedDead.reexportedType.usedField - Root (annotated): Value +Docstrings.+unitArgWithConversion Root (external ref): Value +TopLevelOptionalArgValueUse.+takesFn Root (external ref): RecordLabel +Records.business.owner + Root (annotated): Value +Uncurried.+callback2U Root (external ref): VariantCase +DeadTypeTest.deadType.InBoth Root (external ref): RecordLabel +Records.business.address Root (external ref): RecordLabel +VariantsWithPayload.payload.y Root (annotated): RecordLabel +ImportHookDefault.props.children - Root (annotated): Value +Records.+testMyRec2 + Root (annotated): Value +Records.+testMyObj Root (annotated): Value +TestModuleAliases.+testInner1 Root (annotated): Value +ForAwaitOf.+keep Root (annotated): Value +OcamlWarningSuppressToplevel.+suppressed2 Root (annotated): Value +VariantsWithPayload.+testWithPayload - Root (annotated): Value +Records.+getPayloadRecord Root (annotated): Value +Tuples.+computeAreaNoConverters Root (annotated): Value +Types.+mutuallyRecursiveConverter Root (annotated): Value +UseImportJsValue.+useGetProp @@ -2478,6 +2478,7 @@ Forward Liveness Analysis Propagate: +Newton.+f -> +Newton.+* Propagate: +ContextOptionalArgs.ComponentUsingAction.+make -> +ContextOptionalArgs.NotificationProvider.+useNotification Propagate: +TypeReexport.UseOriginal.reexportedType.directlyUsed -> +TypeReexport.UseOriginal.originalType.directlyUsed + Propagate: +Records.+findAddress2 -> +Records.+getOpt Propagate: +TopLevelOptionalArgValueUse.+liveAliasCaller -> +TopLevelOptionalArgValueUse.+formatDateAlias2 Propagate: +Hooks.+default -> +Hooks.+make Propagate: InnerModuleTypes.I.t.Foo -> +InnerModuleTypes.I.t.Foo @@ -2496,7 +2497,6 @@ Forward Liveness Analysis Propagate: +ScopedAnnotationsLiveVsDead.LiveScope.+root -> +ScopedAnnotationsLiveVsDead.+middleLive Propagate: +Newton.+result -> +Newton.+newton Propagate: +Newton.+result -> +Newton.+fPrimed - Propagate: +Records.+findAllAddresses -> +Records.+getOpt Propagate: +DeadTest.+thisIsMarkedLive -> +DeadTest.+thisIsKeptAlive Propagate: +TopLevelOptionalArgValueUse.+liveCaller -> +TopLevelOptionalArgValueUse.+formatDate Propagate: +OptArg.+wrapOneArg -> +OptArg.+oneArg diff --git a/tests/analysis_tests/tests-reanalyze/deadcode/src/CreateErrorHandler2.res b/tests/analysis_tests/tests-reanalyze/deadcode/src/CreateErrorHandler2.res index 9b64fc61db..d375b74840 100644 --- a/tests/analysis_tests/tests-reanalyze/deadcode/src/CreateErrorHandler2.res +++ b/tests/analysis_tests/tests-reanalyze/deadcode/src/CreateErrorHandler2.res @@ -1,7 +1,6 @@ module Error2 = { type t = int - let notification = n => (string_of_int(n), "") + let notification = n => (Int.toString(n), "") } module MyErrorHandler = ErrorHandler.Make(Error2) /* MyErrorHandler.notify(42) */ - diff --git a/tests/analysis_tests/tests-reanalyze/deadcode/src/Docstrings.res b/tests/analysis_tests/tests-reanalyze/deadcode/src/Docstrings.res index 55712ed85a..175977e07d 100644 --- a/tests/analysis_tests/tests-reanalyze/deadcode/src/Docstrings.res +++ b/tests/analysis_tests/tests-reanalyze/deadcode/src/Docstrings.res @@ -9,7 +9,7 @@ let flat = 34 * @returns A signed message ") @genType -let signMessage = (message, key) => message ++ string_of_int(key) +let signMessage = (message, key) => message ++ Int.toString(key) @genType let one = a => a + 0 @@ -65,4 +65,3 @@ let unitArgWithConversion = () => A @genType let unitArgWithConversionU = (()) => A - diff --git a/tests/analysis_tests/tests-reanalyze/deadcode/src/Records.res b/tests/analysis_tests/tests-reanalyze/deadcode/src/Records.res index 386cc2b5e4..8e8f16efdd 100644 --- a/tests/analysis_tests/tests-reanalyze/deadcode/src/Records.res +++ b/tests/analysis_tests/tests-reanalyze/deadcode/src/Records.res @@ -46,7 +46,7 @@ let someBusiness = {name: "SomeBusiness", owner: None, address: None} let findAllAddresses = (businesses: array): array => businesses ->Array.map(business => - \"@"( + List.concat( business.address->getOpt(list{}, a => list{a}), business.owner->getOpt(list{}, p => p.address->getOpt(list{}, a => list{a})), ) diff --git a/tests/analysis_tests/tests-reanalyze/deadcode/src/Uncurried.res b/tests/analysis_tests/tests-reanalyze/deadcode/src/Uncurried.res index 74eb18f307..63dd60cb3d 100644 --- a/tests/analysis_tests/tests-reanalyze/deadcode/src/Uncurried.res +++ b/tests/analysis_tests/tests-reanalyze/deadcode/src/Uncurried.res @@ -14,19 +14,19 @@ type u3 = (int, string, int) => string let uncurried0 = (()) => "" @genType -let uncurried1 = (x) => x -> string_of_int +let uncurried1 = (x) => Int.toString(x) @genType -let uncurried2 = (x, y) => (x -> string_of_int) ++ y +let uncurried2 = (x, y) => Int.toString(x) ++ y @genType -let uncurried3 = (x, y, z) => (x -> string_of_int) ++ (y ++ (z -> string_of_int)) +let uncurried3 = (x, y, z) => Int.toString(x) ++ (y ++ Int.toString(z)) @genType -let curried3 = (x, y, z) => (x -> string_of_int) ++ (y ++ (z -> string_of_int)) +let curried3 = (x, y, z) => Int.toString(x) ++ (y ++ Int.toString(z)) @genType -let callback = cb => cb() -> string_of_int +let callback = cb => Int.toString(cb()) type auth = {login: unit => string} type authU = {loginU: (unit) => string} @@ -54,4 +54,3 @@ let sumLblCurried = (s: string, ~n) => { Console.log3(s, "sumLblCurried 1st arg", n) (~m) => Console.log4("sumLblCurried 2nd arg", m, "result", n + m) } - diff --git a/tests/analysis_tests/tests-reanalyze/deadcode/src/VariantsWithPayload.res b/tests/analysis_tests/tests-reanalyze/deadcode/src/VariantsWithPayload.res index def8d27679..f647b6b8ea 100644 --- a/tests/analysis_tests/tests-reanalyze/deadcode/src/VariantsWithPayload.res +++ b/tests/analysis_tests/tests-reanalyze/deadcode/src/VariantsWithPayload.res @@ -68,21 +68,21 @@ let testVariantWithPayloads = (x: variantWithPayloads) => x let printVariantWithPayloads = x => switch x { | A => Console.log2("printVariantWithPayloads", "A") - | B(x) => Console.log2("printVariantWithPayloads", "B(" ++ (string_of_int(x) ++ ")")) + | B(x) => Console.log2("printVariantWithPayloads", "B(" ++ (Int.toString(x) ++ ")")) | C(x, y) => Console.log2( "printVariantWithPayloads", - "C(" ++ (string_of_int(x) ++ (", " ++ (string_of_int(y) ++ ")"))), + "C(" ++ (Int.toString(x) ++ (", " ++ (Int.toString(y) ++ ")"))), ) | D((x, y)) => Console.log2( "printVariantWithPayloads", - "D((" ++ (string_of_int(x) ++ (", " ++ (string_of_int(y) ++ "))"))), + "D((" ++ (Int.toString(x) ++ (", " ++ (Int.toString(y) ++ "))"))), ) | E(x, s, y) => Console.log2( "printVariantWithPayloads", - "E(" ++ (string_of_int(x) ++ (", " ++ (s ++ (", " ++ (string_of_int(y) ++ ")"))))), + "E(" ++ (Int.toString(x) ++ (", " ++ (s ++ (", " ++ (Int.toString(y) ++ ")"))))), ) } @@ -97,4 +97,3 @@ type variant1Object = R(payload) @genType let testVariant1Object = (x: variant1Object) => x - diff --git a/tests/analysis_tests/tests-reanalyze/deadcode/src/exception/Exn.res b/tests/analysis_tests/tests-reanalyze/deadcode/src/exception/Exn.res index 5fd6969beb..dd7bb400a0 100644 --- a/tests/analysis_tests/tests-reanalyze/deadcode/src/exception/Exn.res +++ b/tests/analysis_tests/tests-reanalyze/deadcode/src/exception/Exn.res @@ -100,14 +100,14 @@ let array = a => a[2] let id = x => x let tryChar = v => { - try ignore(id(Char.chr(v))) catch { + try ignore(id(String.fromCharCode(v))) catch { | _ => () } 42 } @throws(Not_found) -let throwAtAt = () => \"@@"(throw, Not_found) +let throwAtAt = () => throw(Not_found) @throws(Not_found) let throwPipe = throw(Not_found) diff --git a/tests/analysis_tests/tests/src/expected/Completion.res.txt b/tests/analysis_tests/tests/src/expected/Completion.res.txt index 0c6d944367..10de32c074 100644 --- a/tests/analysis_tests/tests/src/expected/Completion.res.txt +++ b/tests/analysis_tests/tests/src/expected/Completion.res.txt @@ -396,7 +396,7 @@ Path Array. "detail": "(array<'a>, ('a, 'a) => Ordering.t) => unit", "documentation": { "kind": "markdown", - "value": "\n`sort(array, comparator)` sorts `array` in-place using the `comparator` function.\n\nBeware this will *mutate* the array.\n\nSee [`Array.sort`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/sort) on MDN.\n\n## Examples\n\n```rescript\nlet array = [3, 2, 1]\narray->Array.sort((a, b) => float(a - b))\narray == [1, 2, 3]\n```\n" + "value": "\n`sort(array, comparator)` sorts `array` in-place using the `comparator` function.\n\nBeware this will *mutate* the array.\n\nSee [`Array.sort`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/sort) on MDN.\n\n## Examples\n\n```rescript\nlet array = [3, 2, 1]\narray->Array.sort((a, b) => Int.toFloat(a - b))\narray == [1, 2, 3]\n```\n" }, "kind": 12, "label": "sort", @@ -921,17 +921,6 @@ Path Array. "label": "some", "tags": [] }, - { - "deprecated": true, - "detail": "(array<'a>, int) => 'a", - "documentation": { - "kind": "markdown", - "value": "Deprecated: Use getUnsafe instead. This will be removed in v13\n\n\n`unsafe_get(array, index)` returns the element at `index` of `array`.\n\nThis is _unsafe_, meaning it will return `undefined` value if `index` does not exist in `array`.\n\nUse `Array.unsafe_get` only when you are sure the `index` exists (i.e. when using for-loop).\n\n## Examples\n\n```rescript\nlet array = [1, 2, 3]\nfor index in 0 to array->Array.length - 1 {\n let value = array->Array.unsafe_get(index)\n Console.log(value)\n}\n```\n" - }, - "kind": 12, - "label": "unsafe_get", - "tags": [ 1 ] - }, { "detail": "(t<'a>, 'a => bool) => (t<'a>, t<'a>)", "documentation": { diff --git a/tests/analysis_tests/tests/src/expected/DotPipeCompletionSpec.res.txt b/tests/analysis_tests/tests/src/expected/DotPipeCompletionSpec.res.txt index 6e5b64bb4b..9c4aaa2edb 100644 --- a/tests/analysis_tests/tests/src/expected/DotPipeCompletionSpec.res.txt +++ b/tests/analysis_tests/tests/src/expected/DotPipeCompletionSpec.res.txt @@ -348,28 +348,6 @@ Path u "sortText": "unshift", "tags": [] }, - { - "additionalTextEdits": [ - { - "newText": "", - "range": { - "end": { "character": 8, "line": 75 }, - "start": { "character": 7, "line": 75 } - } - } - ], - "deprecated": true, - "detail": "(array<'a>, int) => 'a", - "documentation": { - "kind": "markdown", - "value": "Deprecated: Use getUnsafe instead. This will be removed in v13\n\n\n`unsafe_get(array, index)` returns the element at `index` of `array`.\n\nThis is _unsafe_, meaning it will return `undefined` value if `index` does not exist in `array`.\n\nUse `Array.unsafe_get` only when you are sure the `index` exists (i.e. when using for-loop).\n\n## Examples\n\n```rescript\nlet array = [1, 2, 3]\nfor index in 0 to array->Array.length - 1 {\n let value = array->Array.unsafe_get(index)\n Console.log(value)\n}\n```\n" - }, - "insertText": "->Array.unsafe_get", - "kind": 12, - "label": "->Array.unsafe_get", - "sortText": "unsafe_get", - "tags": [ 1 ] - }, { "additionalTextEdits": [ { diff --git a/tests/belt_tests/src/belt_sortarray_test.res b/tests/belt_tests/src/belt_sortarray_test.res index 9310b6b960..7be9110bb7 100644 --- a/tests/belt_tests/src/belt_sortarray_test.res +++ b/tests/belt_tests/src/belt_sortarray_test.res @@ -105,7 +105,7 @@ describe(__MODULE__, () => { }) test("binarySearchBy", () => { - eq(__LOC__, lnot(S.binarySearchBy([1, 3, 5, 7], 4, cmp)), 2) + eq(__LOC__, Stdlib.Int.bitwiseNot(S.binarySearchBy([1, 3, 5, 7], 4, cmp)), 2) eq(__LOC__, S.binarySearchBy([1, 2, 3, 4, 33, 35, 36], 33, cmp), 4) eq(__LOC__, S.binarySearchBy([1, 2, 3, 4, 33, 35, 36], 1, cmp), 0) eq(__LOC__, S.binarySearchBy([1, 2, 3, 4, 33, 35, 36], 2, cmp), 1) @@ -115,14 +115,14 @@ describe(__MODULE__, () => { ok(__LOC__, R.every(0, 1000, i => S.binarySearchBy(aa, i, cmp) == i)) /* 0, 2, 4, ... 4000 */ let cc = A.map(I.range(0, 2000), x => x * 2) - eq(__LOC__, lnot(S.binarySearchBy(cc, 5000, cmp)), 2001) - eq(__LOC__, lnot(S.binarySearchBy(cc, -1, cmp)), 0) + eq(__LOC__, Stdlib.Int.bitwiseNot(S.binarySearchBy(cc, 5000, cmp)), 2001) + eq(__LOC__, Stdlib.Int.bitwiseNot(S.binarySearchBy(cc, -1, cmp)), 0) eq(__LOC__, S.binarySearchBy(cc, 0, cmp), 0) - eq(__LOC__, lnot(S.binarySearchBy(cc, 1, cmp)), 1) + eq(__LOC__, Stdlib.Int.bitwiseNot(S.binarySearchBy(cc, 1, cmp)), 1) ok( __LOC__, - R.every(0, 1999, i => lnot(S.binarySearchBy(cc, 2 * i + 1, cmp)) == i + 1), + R.every(0, 1999, i => Stdlib.Int.bitwiseNot(S.binarySearchBy(cc, 2 * i + 1, cmp)) == i + 1), /* 1, 3, 5, ... , 3999 */ ) }) diff --git a/tests/belt_tests/src/bs_array_test.mjs b/tests/belt_tests/src/bs_array_test.mjs index 74bd691202..47393b577f 100644 --- a/tests/belt_tests/src/bs_array_test.mjs +++ b/tests/belt_tests/src/bs_array_test.mjs @@ -235,7 +235,7 @@ Mocha.describe("Bs_array_test", () => { Test_utils.eq("File \"bs_array_test.res\", line 123, characters 7-14", makeMatrixExn(0, 3, 1), []); Test_utils.eq("File \"bs_array_test.res\", line 124, characters 7-14", makeMatrixExn(1, 1, 1), [[1]]); Test_utils.eq("File \"bs_array_test.res\", line 125, characters 7-14", [].slice(0), []); - Test_utils.eq("File \"bs_array_test.res\", line 126, characters 7-14", Belt_Array.map([], prim => prim + 1 | 0), []); + Test_utils.eq("File \"bs_array_test.res\", line 126, characters 7-14", Belt_Array.map([], x => x + 1 | 0), []); Test_utils.eq("File \"bs_array_test.res\", line 127, characters 7-14", Belt_Array.mapWithIndex([], add), []); Test_utils.eq("File \"bs_array_test.res\", line 128, characters 7-14", Belt_Array.mapWithIndex([ 1, @@ -269,7 +269,7 @@ Mocha.describe("Bs_array_test", () => { 1, 2, 3 - ], prim => prim + 1 | 0), [ + ], x => x + 1 | 0), [ 2, 3, 4 diff --git a/tests/belt_tests/src/bs_array_test.res b/tests/belt_tests/src/bs_array_test.res index bb30e50ea9..210494f4e8 100644 --- a/tests/belt_tests/src/bs_array_test.res +++ b/tests/belt_tests/src/bs_array_test.res @@ -123,13 +123,13 @@ describe(__MODULE__, () => { eq(__LOC__, makeMatrixExn(0, 3, 1), []) eq(__LOC__, makeMatrixExn(1, 1, 1), [[1]]) eq(__LOC__, A.copy([]), []) - eq(__LOC__, A.map([], succ), []) + eq(__LOC__, A.map([], x => x + 1), []) eq(__LOC__, A.mapWithIndex([], add), []) eq(__LOC__, A.mapWithIndex([1, 2, 3], add), [1, 3, 5]) eq(__LOC__, L.fromArray([]), list{}) eq(__LOC__, L.fromArray([1]), list{1}) eq(__LOC__, L.fromArray([1, 2, 3]), list{1, 2, 3}) - eq(__LOC__, A.map([1, 2, 3], succ), [2, 3, 4]) + eq(__LOC__, A.map([1, 2, 3], x => x + 1), [2, 3, 4]) eq(__LOC__, L.toArray(list{}), []) eq(__LOC__, L.toArray(list{1}), [1]) eq(__LOC__, L.toArray(list{1, 2}), [1, 2]) diff --git a/tests/belt_tests/src/bs_poly_mutable_map_test.res b/tests/belt_tests/src/bs_poly_mutable_map_test.res index 5546f8b147..7f2b888de3 100644 --- a/tests/belt_tests/src/bs_poly_mutable_map_test.res +++ b/tests/belt_tests/src/bs_poly_mutable_map_test.res @@ -33,8 +33,8 @@ describe(__MODULE__, () => { test("mutable map operations with large range", () => { let a0 = f(randomRange(0, 10000)) \".!()<-"(a0, 2000, 33) - a0->M.removeMany(randomRange(0, 1998)->A.map(fst)) - a0->M.removeMany(randomRange(2002, 11000)->A.map(fst)) + a0->M.removeMany(randomRange(0, 1998)->A.map(Stdlib.Pair.first)) + a0->M.removeMany(randomRange(2002, 11000)->A.map(Stdlib.Pair.first)) eq(__LOC__, a0->M.toArray, [(1999, 1999), (2000, 33), (2001, 2001)]) }) }) diff --git a/tests/belt_tests/src/bs_queue_test.res b/tests/belt_tests/src/bs_queue_test.res index ebf3bcc57b..111fbc3188 100644 --- a/tests/belt_tests/src/bs_queue_test.res +++ b/tests/belt_tests/src/bs_queue_test.res @@ -116,7 +116,7 @@ describe(__MODULE__, () => { q, j => { assert(i.contents == j) - incr(i) + Stdlib.Int.Ref.increment(i) }, ) }) diff --git a/tests/belt_tests/src/hash_test.res b/tests/belt_tests/src/hash_test.res index e43eb169d1..7076d2a4b5 100644 --- a/tests/belt_tests/src/hash_test.res +++ b/tests/belt_tests/src/hash_test.res @@ -39,7 +39,7 @@ let test_strings_hash_results = [ 831138595, ] -let normalize = x => land(x, 0x3FFFFFFF) +let normalize = x => Stdlib.Int.bitwiseAnd(x, 0x3FFFFFFF) let caml_hash = x => normalize(Hash_utils.hash(x)) describe(__MODULE__, () => { diff --git a/tests/belt_tests/src/ticker.mjs b/tests/belt_tests/src/ticker.mjs index 7303100f71..aa67bef1bd 100644 --- a/tests/belt_tests/src/ticker.mjs +++ b/tests/belt_tests/src/ticker.mjs @@ -65,7 +65,7 @@ function string_of_rank(x) { return "Visited"; } } else { - return "Ranked(" + x._0 + ")"; + return "Ranked(" + String(x._0) + ")"; } } @@ -132,7 +132,7 @@ function compute_update_sequences(all_tickers) { let ticker_name = ticker.ticker_name; if (typeof type_ !== "object") { let l = Belt_MapString.getExn(map, ticker_name); - return Belt_MapString.set(map, ticker_name, Pervasives.$at(up, l)); + return Belt_MapString.set(map, ticker_name, Belt_List.concat(up, l)); } let match = type_._0; let map$1 = loop({ diff --git a/tests/belt_tests/src/ticker.res b/tests/belt_tests/src/ticker.res index c0411b94de..681004fa37 100644 --- a/tests/belt_tests/src/ticker.res +++ b/tests/belt_tests/src/ticker.res @@ -67,7 +67,7 @@ let string_of_rank = x => switch x { | Uninitialized => "Uninitialized" | Visited => "Visited" - | Ranked(i) => "Ranked(" ++ __unsafe_cast(i) ++ ")" + | Ranked(i) => "Ranked(" ++ Int.toString(i) ++ ")" } let find_ticker_by_name = (all_tickers, ticker) => @@ -141,7 +141,7 @@ let compute_update_sequences = all_tickers => { switch type_ { | Market => let l = map->Ticker_map.getExn(ticker_name) - map->Ticker_map.set(ticker_name, \"@"(up, l)) + map->Ticker_map.set(ticker_name, List.concat(up, l)) | Binary_op({lhs, rhs, _}) => let map = loop(list{ticker, ...up}, map, lhs) loop(list{ticker, ...up}, map, rhs) diff --git a/tests/tests/src/VariantCoercion.res b/tests/tests/src/VariantCoercion.res index f41111b915..48bda60ab4 100644 --- a/tests/tests/src/VariantCoercion.res +++ b/tests/tests/src/VariantCoercion.res @@ -124,7 +124,7 @@ module CoerceFromPolyvariantToVariant = { module CoerceVariantBinaryOp = { type flag = | @as(0) A | @as(2) B - let x = 0->lor((B :> int)) + let x = 0->Int.bitwiseOr((B :> int)) let v = B let f1 = () => diff --git a/tests/tests/src/ari_regress_test.res b/tests/tests/src/ari_regress_test.res index 88a7b1da34..d52952d5c8 100644 --- a/tests/tests/src/ari_regress_test.res +++ b/tests/tests/src/ari_regress_test.res @@ -13,7 +13,7 @@ let gg = (x, y) => { let g1 = (x, y) => { let u = x + y - let () = incr(h) + let () = Int.Ref.increment(h) (xx, yy) => xx + yy + u } let x = gg(3, 5)(6) diff --git a/tests/tests/src/bdd.res b/tests/tests/src/bdd.res index 3428026261..bbea84aa05 100644 --- a/tests/tests/src/bdd.res +++ b/tests/tests/src/bdd.res @@ -41,7 +41,7 @@ let nodeC = ref(1) let sz_1 = ref(initSize_1) let htab = ref(Array.make(~length=sz_1.contents + 1, list{})) let n_items = ref(0) -let hashVal = (x, y, v) => lsl(x, 1) + y + lsl(v, 2) +let hashVal = (x, y, v) => Int.shiftLeft(x, 1) + y + Int.shiftLeft(v, 2) let resize = newSize => { let arr = htab.contents @@ -53,7 +53,7 @@ let resize = newSize => { | list{n, ...ns} => switch n { | Node(l, v, _, h) => - let ind = land(hashVal(getId(l), getId(h), v), newSz_1) + let ind = Int.bitwiseAnd(hashVal(getId(l), getId(h), v), newSz_1) newArr->Array.setUnsafe(ind, list{n, ...newArr->Array.getUnsafe(ind)}) copyBucket(ns) @@ -71,10 +71,10 @@ let resize = newSize => { let rec insert = (idl, idh, v, ind, bucket, newNode) => if n_items.contents <= sz_1.contents { htab.contents->Array.setUnsafe(ind, list{newNode, ...bucket}) - incr(n_items) + Int.Ref.increment(n_items) } else { resize(sz_1.contents + sz_1.contents + 2) - let ind = land(hashVal(idl, idh, v), sz_1.contents) + let ind = Int.bitwiseAnd(hashVal(idl, idh, v), sz_1.contents) htab.contents->Array.setUnsafe(ind, list{newNode, ...htab.contents->Array.getUnsafe(ind)}) } @@ -93,7 +93,7 @@ let mkNode = (low, v, high) => { if idl == idh { low } else { - let ind = land(hashVal(idl, idh, v), sz_1.contents) + let ind = Int.bitwiseAnd(hashVal(idl, idh, v), sz_1.contents) let bucket = htab.contents->Array.getUnsafe(ind) let rec lookup = b => switch b { @@ -102,7 +102,7 @@ let mkNode = (low, v, high) => { low, v, { - incr(nodeC) + Int.Ref.increment(nodeC) nodeC.contents }, high, @@ -152,7 +152,7 @@ let xorslot2 = Array.make(~length=cacheSize, 0) let xorslot3 = Array.make(~length=cacheSize, zero) let notslot1 = Array.make(~length=cacheSize, 0) let notslot2 = Array.make(~length=cacheSize, one) -let hash = (x, y) => mod(lsl(x, 1) + y, cacheSize) +let hash = (x, y) => mod(Int.shiftLeft(x, 1) + y, cacheSize) let rec not = n => switch n { @@ -250,7 +250,7 @@ let seed = ref(0) let random = () => { seed := seed.contents * 25173 + 17431 - land(seed.contents, 1) > 0 + Int.bitwiseAnd(seed.contents, 1) > 0 } let random_vars = n => { @@ -276,7 +276,7 @@ let test_hwb = (bdd, vars) => { let ntrue = ref(0) for i in 0 to Array.length(vars) - 1 { if vars->Array.getUnsafe(i) { - incr(ntrue) + Int.Ref.increment(ntrue) } } bool_equal( diff --git a/tests/tests/src/bench.res b/tests/tests/src/bench.res index 5e025249d3..c626be5c8a 100644 --- a/tests/tests/src/bench.res +++ b/tests/tests/src/bench.res @@ -23,7 +23,7 @@ let init = (l, f) => on whether we create a float array or a regular one... */ let res = Array.make(~length=l, f(0)) - for i in 1 to pred(l) { + for i in 1 to l - 1 { Array.setUnsafe(res, i, f(i)) } res @@ -42,7 +42,7 @@ let fold_left = (f, x, a) => { let fold_left = (f, x, a) => fold_left((x, y) => f(x, y), x, a) let f2 = () => { - let arr = init(3_000_000, i => float_of_int(i)) + let arr = init(3_000_000, i => Int.toFloat(i)) let b = map(i => i +. i -. 1., arr) let v = fold_left(\"+.", 0., b) Console.log2("%f", v) diff --git a/tests/tests/src/bs_ignore_effect.res b/tests/tests/src/bs_ignore_effect.res index 195d73e1af..594bd89899 100644 --- a/tests/tests/src/bs_ignore_effect.res +++ b/tests/tests/src/bs_ignore_effect.res @@ -15,10 +15,10 @@ let v = ref(0) @obj external config: (~hi: int, ~lo: int, unit) => _ = "" -let h = config(~hi=2, ~lo=0, ignore(incr(v))) +let h = config(~hi=2, ~lo=0, ignore(Int.Ref.increment(v))) let z = add( { - incr(v) + Int.Ref.increment(v) Float }, 3.0, diff --git a/tests/tests/src/coercion_module_alias_test.mjs b/tests/tests/src/coercion_module_alias_test.mjs index 5984f94a19..f9a8a078b6 100644 --- a/tests/tests/src/coercion_module_alias_test.mjs +++ b/tests/tests/src/coercion_module_alias_test.mjs @@ -1,35 +1,43 @@ // Generated by ReScript, PLEASE EDIT WITH CARE -import * as Char from "@rescript/runtime/lib/es6/Char.mjs"; import * as Stdlib_List from "@rescript/runtime/lib/es6/Stdlib_List.mjs"; +import * as Stdlib_String from "@rescript/runtime/lib/es6/Stdlib_String.mjs"; function l(prim) { console.log(prim); } -let C$p = Char; +let C$p = Stdlib_String; -console.log(66); +let prim = String.fromCharCode(66); -console.log(66); +console.log(prim); + +let prim$1 = String.fromCharCode(66); + +console.log(prim$1); -let C3 = Char; +let C3 = Stdlib_String; -console.log(66); +let prim$2 = String.fromCharCode(66); + +console.log(prim$2); let f = Stdlib_List.length; function g(x) { - return Stdlib_List.length(Stdlib_List.map(x, prim => prim + 1 | 0)); + return Stdlib_List.length(Stdlib_List.map(x, n => n + 1 | 0)); } function F(X) { - return Char; + return Stdlib_String; } -let C4 = Char; +let C4 = Stdlib_String; + +let prim$3 = String.fromCharCode(66); -console.log(66); +console.log(prim$3); function G(X) { return X; @@ -137,7 +145,7 @@ let M8 = { }; let M9_C = { - chr: prim => prim + fromCharCode: prim => String.fromCharCode(prim) }; let M9 = { @@ -145,25 +153,25 @@ let M9 = { C$p: C$p$1 }; -let prim = M9_C.chr(66); +let prim$4 = M9_C.fromCharCode(66); -console.log(prim); +console.log(prim$4); let M10 = { C$p: { - chr: prim => prim + fromCharCode: prim => String.fromCharCode(prim) } }; -let prim$1 = M10.C$p.chr(66); +let prim$5 = M10.C$p.fromCharCode(66); -console.log(prim$1); +console.log(prim$5); let C; let C$p$p$p = C$p; -let C$p$p = Char; +let C$p$p = Stdlib_String; function G0(funarg) { let N = { @@ -208,4 +216,4 @@ export { M9, M10, } -/* Not a pure module */ +/* prim Not a pure module */ diff --git a/tests/tests/src/coercion_module_alias_test.res b/tests/tests/src/coercion_module_alias_test.res index 26d0970c3f..3645e9810f 100644 --- a/tests/tests/src/coercion_module_alias_test.res +++ b/tests/tests/src/coercion_module_alias_test.res @@ -1,18 +1,18 @@ let l = Console.log -module C = Char +module C = String -module C': module type of Char = C -l(C'.chr(66)) +module C': module type of String = C +l(C'.fromCharCode(66)) module C''': module type of C = C' /* fails */ -module C'': module type of Char = C -l(C''.chr(66)) +module C'': module type of String = C +l(C''.fromCharCode(66)) module C3 = { - include Char + include String } -l(C3.chr(66)) +l(C3.fromCharCode(66)) let f = x => { module M = { @@ -22,12 +22,12 @@ let f = x => { } let g = x => { module L = List - L.length(L.map(x, succ)) + L.length(L.map(x, n => n + 1)) } -module F = (X: {}) => Char +module F = (X: {}) => String module C4 = F() -l(C4.chr(66)) +l(C4.fromCharCode(66)) module G = (X: {}) => X /* does not alias X */ module M = G() @@ -124,24 +124,24 @@ open M6 l(N'.x) module M8 = { - module C = Char + module C = String module C' = C } module M9: { module C: { - let chr: int => char + let fromCharCode: int => string } module C' = C } = M8 -l(M9.C'.chr(66)) +l(M9.C'.fromCharCode(66)) module M10: { module C': { - let chr: int => char + let fromCharCode: int => string } } = (M8: { module C: { - let chr: int => char + let fromCharCode: int => string } module C' = C }) -l(M10.C'.chr(66)) +l(M10.C'.fromCharCode(66)) diff --git a/tests/tests/src/complex_while_loop.res b/tests/tests/src/complex_while_loop.res index d5906ab4a2..8db77e2aa2 100644 --- a/tests/tests/src/complex_while_loop.res +++ b/tests/tests/src/complex_while_loop.res @@ -9,7 +9,7 @@ let f = () => { fib(n.contents) > 10 } { n.contents->Int.toString->Console.log - incr(n) + Int.Ref.increment(n) } } diff --git a/tests/tests/src/condition_compilation_test.res b/tests/tests/src/condition_compilation_test.res index 0950a15c49..8c2050dd03 100644 --- a/tests/tests/src/condition_compilation_test.res +++ b/tests/tests/src/condition_compilation_test.res @@ -24,7 +24,7 @@ let vv = 3 let v = ref(1) let a = { - let () = incr(v) + let () = Int.Ref.increment(v) v.contents } diff --git a/tests/tests/src/cross_module_inline_test.mjs b/tests/tests/src/cross_module_inline_test.mjs index 715b9c6e1d..18deeeb02a 100644 --- a/tests/tests/src/cross_module_inline_test.mjs +++ b/tests/tests/src/cross_module_inline_test.mjs @@ -2,7 +2,7 @@ import * as Test_char from "./test_char.mjs"; -let v = Test_char.caml_is_printable(/* 'a' */97); +let v = Test_char.caml_is_printable("a"); export { v, diff --git a/tests/tests/src/cross_module_inline_test.res b/tests/tests/src/cross_module_inline_test.res index f3b2dcc824..6eab0b5082 100644 --- a/tests/tests/src/cross_module_inline_test.res +++ b/tests/tests/src/cross_module_inline_test.res @@ -1,2 +1,2 @@ open Test_char -let v = caml_is_printable('a') +let v = caml_is_printable("a") diff --git a/tests/tests/src/earger_curry_test.res b/tests/tests/src/earger_curry_test.res index 07cb32b549..88c520c90f 100644 --- a/tests/tests/src/earger_curry_test.res +++ b/tests/tests/src/earger_curry_test.res @@ -25,7 +25,7 @@ let init = (l, f) => on whether we create a float array or a regular one... */ let res = Array.make(~length=l, f(0)) - for i in 1 to pred(l) { + for i in 1 to l - 1 { Array.setUnsafe(res, i, f(i)) } res @@ -50,7 +50,7 @@ let fold_left = (f, x, a) => fold_left((x, y) => f(x, y), x, a) let f = { open Array () => { - let arr = init(10000000, i => float_of_int(i)) + let arr = init(10000000, i => Int.toFloat(i)) let b = arr->map(i => i +. i -. 1.) let v = b->Array.reduceRight(0., \"+.") v->Float.toString->Console.log @@ -59,7 +59,7 @@ let f = { let f2 = () => { open Array - let arr = init(30_000_000, i => float_of_int(i)) + let arr = init(30_000_000, i => Int.toFloat(i)) let b = arr->map(i => i +. i -. 1.) let v = b->Array.reduceRight(0., \"+.") v->Float.toString->Console.log @@ -96,11 +96,11 @@ let f = x => /* let u = */ add5( x, { - incr(v) + Int.Ref.increment(v) 1 }, { - incr(v) + Int.Ref.increment(v) 2 }, ... @@ -113,11 +113,11 @@ let g = x => { add5( x, { - incr(v) + Int.Ref.increment(v) 1 }, { - incr(v) + Int.Ref.increment(v) 2 }, a, diff --git a/tests/tests/src/epsilon_test.mjs b/tests/tests/src/epsilon_test.mjs index 17b6362f9a..1b79ef9bec 100644 --- a/tests/tests/src/epsilon_test.mjs +++ b/tests/tests/src/epsilon_test.mjs @@ -1,13 +1,12 @@ // Generated by ReScript, PLEASE EDIT WITH CARE import * as Mocha from "mocha"; -import * as Pervasives from "@rescript/runtime/lib/es6/Pervasives.mjs"; import * as Test_utils from "./test_utils.mjs"; let v = (Number.EPSILON?Number.EPSILON:2.220446049250313e-16); Mocha.describe("Epsilon_test", () => { - Mocha.test("epsilon", () => Test_utils.eq("File \"epsilon_test.res\", line 8, characters 7-14", Pervasives.epsilon_float, v)); + Mocha.test("epsilon", () => Test_utils.eq("File \"epsilon_test.res\", line 8, characters 7-14", Number.EPSILON, v)); Mocha.test("raw_epsilon", () => Test_utils.eq("File \"epsilon_test.res\", line 11, characters 7-14", 2.220446049250313e-16, v)); }); diff --git a/tests/tests/src/epsilon_test.res b/tests/tests/src/epsilon_test.res index 6e28c1a080..141d869e48 100644 --- a/tests/tests/src/epsilon_test.res +++ b/tests/tests/src/epsilon_test.res @@ -5,7 +5,7 @@ open Test_utils describe(__MODULE__, () => { test("epsilon", () => { - eq(__LOC__, epsilon_float, v) + eq(__LOC__, Float.Constants.epsilon, v) }) test("raw_epsilon", () => { eq(__LOC__, 2.220446049250313e-16, v) diff --git a/tests/tests/src/ext_array_test.res b/tests/tests/src/ext_array_test.res index 4bf4b373e8..1af2cfe258 100644 --- a/tests/tests/src/ext_array_test.res +++ b/tests/tests/src/ext_array_test.res @@ -214,7 +214,7 @@ let exists = (p, a) => { } else if p(Array.getUnsafe(a, i)) { true } else { - loop(succ(i)) + loop(i + 1) } loop(0) } @@ -226,7 +226,7 @@ let rec unsafe_loop = (index, len, p, xs, ys) => true } else { p(Array.getUnsafe(xs, index), Array.getUnsafe(ys, index)) && - unsafe_loop(succ(index), len, p, xs, ys) + unsafe_loop(index + 1, len, p, xs, ys) } let for_all2_no_exn = (p, xs, ys) => { diff --git a/tests/tests/src/ext_pervasives_test.res b/tests/tests/src/ext_pervasives_test.res index 18459aaa9e..205517bac0 100644 --- a/tests/tests/src/ext_pervasives_test.res +++ b/tests/tests/src/ext_pervasives_test.res @@ -40,11 +40,11 @@ let hash_variant = s => { accu := 223 * accu.contents + String.codePointAt(s, i)->Option.getUnsafe } /* reduce to 31 bits */ - accu := land(accu.contents, lsl(1, 31) - 1) + accu := Int.bitwiseAnd(accu.contents, Int.shiftLeft(1, 31) - 1) /* make it signed for 64 bits architectures */ if accu.contents > 0x3FFFFFFF { - accu.contents - lsl(1, 31) + accu.contents - Int.shiftLeft(1, 31) } else { accu.contents } diff --git a/tests/tests/src/ffi_arity_test.res b/tests/tests/src/ffi_arity_test.res index 542553917f..fd652eb541 100644 --- a/tests/tests/src/ffi_arity_test.res +++ b/tests/tests/src/ffi_arity_test.res @@ -27,7 +27,7 @@ let fff = () => { /* No inline */ Console.log("x") Console.log("x") - incr(vvv) + Int.Ref.increment(vvv) } let g = () => fff() diff --git a/tests/tests/src/ffi_js_test.res b/tests/tests/src/ffi_js_test.res index ab33d0f190..5815162545 100644 --- a/tests/tests/src/ffi_js_test.res +++ b/tests/tests/src/ffi_js_test.res @@ -70,7 +70,7 @@ describe(__MODULE__, () => { let u = ref(3) let side_effect_config = config( ~kind={ - incr(u) + Int.Ref.increment(u) Int }, ~hi=3, diff --git a/tests/tests/src/field_flattening_opt.res b/tests/tests/src/field_flattening_opt.res index 150e9409e8..ba7a9a6eb4 100644 --- a/tests/tests/src/field_flattening_opt.res +++ b/tests/tests/src/field_flattening_opt.res @@ -15,6 +15,6 @@ module NoOptionalFields = { let p: pair = ({field: 2}, "") - let x = fst(p) - let y = fst(p) + let x = Pair.first(p) + let y = Pair.first(p) } diff --git a/tests/tests/src/float_test.mjs b/tests/tests/src/float_test.mjs index 1d3507e2be..20d05b1cdb 100644 --- a/tests/tests/src/float_test.mjs +++ b/tests/tests/src/float_test.mjs @@ -1,7 +1,6 @@ // Generated by ReScript, PLEASE EDIT WITH CARE import * as Mocha from "mocha"; -import * as Pervasives from "@rescript/runtime/lib/es6/Pervasives.mjs"; import * as Test_utils from "./test_utils.mjs"; import * as Stdlib_Float from "@rescript/runtime/lib/es6/Stdlib_Float.mjs"; import * as Primitive_float from "@rescript/runtime/lib/es6/Primitive_float.mjs"; @@ -51,7 +50,7 @@ let nan = NaN; Mocha.describe("Float_test", () => { Mocha.test("float_test_1", () => { - Test_utils.eq("File \"float_test.res\", line 22, characters 7-14", Pervasives.classify_float(3), "FP_normal"); + Test_utils.eq("File \"float_test.res\", line 22, characters 7-14", isFinite(3), true); Test_utils.eq("File \"float_test.res\", line 24, characters 6-13", [ -1, 1, @@ -82,10 +81,10 @@ Mocha.describe("Float_test", () => { Test_utils.eq("File \"float_test.res\", line 40, characters 7-14", Stdlib_Float.fromString("3.0"), 3.0); Test_utils.eq("File \"float_test.res\", line 41, characters 7-14", Primitive_float.compare(nan, nan), 0); Test_utils.eq("File \"float_test.res\", line 42, characters 7-14", Primitive_object.compare(nan, nan), 0); - Test_utils.eq("File \"float_test.res\", line 43, characters 7-14", Primitive_float.compare(nan, Pervasives.neg_infinity), -1); - Test_utils.eq("File \"float_test.res\", line 44, characters 7-14", Primitive_object.compare(nan, Pervasives.neg_infinity), -1); - Test_utils.eq("File \"float_test.res\", line 45, characters 7-14", Primitive_float.compare(Pervasives.neg_infinity, nan), 1); - Test_utils.eq("File \"float_test.res\", line 46, characters 7-14", Primitive_object.compare(Pervasives.neg_infinity, nan), 1); + Test_utils.eq("File \"float_test.res\", line 43, characters 7-14", Primitive_float.compare(nan, Number.NEGATIVE_INFINITY), -1); + Test_utils.eq("File \"float_test.res\", line 44, characters 7-14", Primitive_object.compare(nan, Number.NEGATIVE_INFINITY), -1); + Test_utils.eq("File \"float_test.res\", line 45, characters 7-14", Primitive_float.compare(Number.NEGATIVE_INFINITY, nan), 1); + Test_utils.eq("File \"float_test.res\", line 46, characters 7-14", Primitive_object.compare(Number.NEGATIVE_INFINITY, nan), 1); Test_utils.eq("File \"float_test.res\", line 47, characters 7-14", nan === nan, false); Test_utils.eq("File \"float_test.res\", line 48, characters 7-14", Primitive_object.equal(nan, nan), false); Test_utils.eq("File \"float_test.res\", line 49, characters 7-14", 4.2 === nan, false); diff --git a/tests/tests/src/float_test.res b/tests/tests/src/float_test.res index 3f1ce3118a..a0618c51eb 100644 --- a/tests/tests/src/float_test.res +++ b/tests/tests/src/float_test.res @@ -19,7 +19,7 @@ let nan = Float.Constants.nan describe(__MODULE__, () => { test("float_test_1", () => { - eq(__LOC__, classify_float(3.), FP_normal) + eq(__LOC__, Float.isFinite(3.), true) eq( __LOC__, [-1, 1, 1], @@ -36,14 +36,14 @@ describe(__MODULE__, () => { }, ), ) - eq(__LOC__, log10(10.), 1.) + eq(__LOC__, Math.log10(10.), 1.) eq(__LOC__, Float.fromString("3.0"), Some(3.0)) eq(__LOC__, float_compare(nan, nan), 0) eq(__LOC__, generic_compare(nan, nan), 0) - eq(__LOC__, float_compare(nan, neg_infinity), -1) - eq(__LOC__, generic_compare(nan, neg_infinity), -1) - eq(__LOC__, float_compare(neg_infinity, nan), 1) - eq(__LOC__, generic_compare(neg_infinity, nan), 1) + eq(__LOC__, float_compare(nan, Float.Constants.negativeInfinity), -1) + eq(__LOC__, generic_compare(nan, Float.Constants.negativeInfinity), -1) + eq(__LOC__, float_compare(Float.Constants.negativeInfinity, nan), 1) + eq(__LOC__, generic_compare(Float.Constants.negativeInfinity, nan), 1) eq(__LOC__, float_equal(nan, nan), false) eq(__LOC__, generic_equal(nan, nan), false) eq(__LOC__, float_equal(4.2, nan), false) diff --git a/tests/tests/src/for_loop_test.res b/tests/tests/src/for_loop_test.res index 429ff44159..f4c3cfd09e 100644 --- a/tests/tests/src/for_loop_test.res +++ b/tests/tests/src/for_loop_test.res @@ -53,16 +53,16 @@ describe(__MODULE__, () => { let v4 = ref(0) let v5 = ref(0) let inspect_3 = ref(-1) - incr(v4) + Int.Ref.increment(v4) for j in 0 to 1 { - incr(v5) + Int.Ref.increment(v5) let v2 = ref(0) let v3 = u for i in 0 to Array.length(x) - 1 { let _j = i * 2 let k = 2 * u * u let h = 2 * v5.contents - incr(v2) + Int.Ref.increment(v2) arr[i] = _ => v := v.contents + k + v2.contents + v4.contents + v5.contents + h + v3 /* v2 should not be captured */ } @@ -128,7 +128,7 @@ describe(__MODULE__, () => { /* incr v ; */ v := v.contents + i for j in 0 to j_len - 1 { - incr(v) + Int.Ref.increment(v) collect(v.contents) arr[i * j_len + j] = _ => vv := vv.contents + v.contents /* v should not be captured inside, diff --git a/tests/tests/src/functor_def.res b/tests/tests/src/functor_def.res index 2917aed7a4..6c3c3669d6 100644 --- a/tests/tests/src/functor_def.res +++ b/tests/tests/src/functor_def.res @@ -1,7 +1,7 @@ let v = ref(0) let f = (x, x) => { - incr(v) + Int.Ref.increment(v) x + x } diff --git a/tests/tests/src/global_module_alias_test.res b/tests/tests/src/global_module_alias_test.res index aecede20a3..c01b5ddb14 100644 --- a/tests/tests/src/global_module_alias_test.res +++ b/tests/tests/src/global_module_alias_test.res @@ -22,18 +22,18 @@ let v = ref(0) module Make = (U: S) => { let () = { - incr(v) - incr(v) - incr(v) + Int.Ref.increment(v) + Int.Ref.increment(v) + Int.Ref.increment(v) } include U } let f = () => { let () = { - incr(v) - incr(v) - incr(v) + Int.Ref.increment(v) + Int.Ref.increment(v) + Int.Ref.increment(v) } module G = F /* local module is not module alias */ module H = G diff --git a/tests/tests/src/gpr_1072.res b/tests/tests/src/gpr_1072.res index e77023ee9c..7baea30c2d 100644 --- a/tests/tests/src/gpr_1072.res +++ b/tests/tests/src/gpr_1072.res @@ -153,7 +153,7 @@ let () = { again4(~y=(), __LINE__, ()) again4( ~x={ - incr(side_effect) + Int.Ref.increment(side_effect) () }, ~y=(), @@ -162,11 +162,11 @@ let () = { ) again4( ~x={ - incr(side_effect) + Int.Ref.increment(side_effect) () }, ~y={ - decr(side_effect) + Int.Ref.decrement(side_effect) () }, __LINE__, @@ -174,13 +174,13 @@ let () = { ) again4( ~y={ - decr(side_effect) + Int.Ref.decrement(side_effect) () }, __LINE__, (), ) - again4(~x=incr(side_effect), ~y=(), __LINE__, ()) + again4(~x=Int.Ref.increment(side_effect), ~y=(), __LINE__, ()) } /* external again5 : ?x__ignore:([`a of unit -> int | `b of string -> int ] [@string]) */ diff --git a/tests/tests/src/gpr_1409_test.res b/tests/tests/src/gpr_1409_test.res index 6934e2c4b5..fb5732b4ce 100644 --- a/tests/tests/src/gpr_1409_test.res +++ b/tests/tests/src/gpr_1409_test.res @@ -51,7 +51,7 @@ let test6 = (f, x) => { let x = ref(3) mangle( ~_open=?{ - incr(x) + Int.Ref.increment(x) Some(x.contents) }, ~xx__hi=?f(x), diff --git a/tests/tests/src/gpr_1762_test.res b/tests/tests/src/gpr_1762_test.res index 7a45596bf2..6ab203049b 100644 --- a/tests/tests/src/gpr_1762_test.res +++ b/tests/tests/src/gpr_1762_test.res @@ -6,7 +6,7 @@ open Test_utils let v = ref(3) let update = () => { - incr(v) + Int.Ref.increment(v) true } diff --git a/tests/tests/src/gpr_1822_test.res b/tests/tests/src/gpr_1822_test.res index 68a2240c11..d5840a6509 100644 --- a/tests/tests/src/gpr_1822_test.res +++ b/tests/tests/src/gpr_1822_test.res @@ -9,8 +9,8 @@ describe(__MODULE__, () => { test("gpr_1822_test", () => { let myShape = Circle(10) let area = switch myShape { - | Circle(r) => float_of_int(r * r) *. 3.14 - | Rectangle(w, h) => float_of_int(w * h) + | Circle(r) => Int.toFloat(r * r) *. 3.14 + | Rectangle(w, h) => Int.toFloat(w * h) } eq(__LOC__, area, 314.) diff --git a/tests/tests/src/gpr_1946_test.mjs b/tests/tests/src/gpr_1946_test.mjs index bd1b463576..aba433a9bc 100644 --- a/tests/tests/src/gpr_1946_test.mjs +++ b/tests/tests/src/gpr_1946_test.mjs @@ -36,15 +36,11 @@ Test_utils.eq("File \"gpr_1946_test.res\", line 24, characters 3-10", [ f(h)["123_456"] ]); -console.log(({ - _5: 3 - }).TAG); - Mocha.describe("Gpr_1946_test", () => { - Mocha.test("test1", () => Test_utils.eq("File \"gpr_1946_test.res\", line 29, characters 7-14", ({ + Mocha.test("test1", () => Test_utils.eq("File \"gpr_1946_test.res\", line 28, characters 7-14", ({ _5: 3 })._5, 3)); - Mocha.test("test2", () => Test_utils.eq("File \"gpr_1946_test.res\", line 33, characters 7-14", [ + Mocha.test("test2", () => Test_utils.eq("File \"gpr_1946_test.res\", line 32, characters 7-14", [ 2, 3 ], [ diff --git a/tests/tests/src/gpr_1946_test.res b/tests/tests/src/gpr_1946_test.res index 3a185fb2b9..d7e05a3f88 100644 --- a/tests/tests/src/gpr_1946_test.res +++ b/tests/tests/src/gpr_1946_test.res @@ -22,7 +22,6 @@ let f = id => { eq(__LOC__, ({"_5": 3})["_5"], 3) eq(__LOC__, (2, 3), (f(h).a, f(h).b)) -Console.log(Obj.tag(Obj.repr({"_5": 3}))) describe(__MODULE__, () => { test("test1", () => { diff --git a/tests/tests/src/gpr_2413_test.res b/tests/tests/src/gpr_2413_test.res index fdce7e7001..9e76dcc5d2 100644 --- a/tests/tests/src/gpr_2413_test.res +++ b/tests/tests/src/gpr_2413_test.res @@ -20,7 +20,7 @@ let ff = c => switch { let a = 1 let b = 1 - incr(c) + Int.Ref.increment(c) a + c.contents + b } { | 0 => 1 diff --git a/tests/tests/src/gpr_858_unit2_test.res b/tests/tests/src/gpr_858_unit2_test.res index 76a0424018..1126522150 100644 --- a/tests/tests/src/gpr_858_unit2_test.res +++ b/tests/tests/src/gpr_858_unit2_test.res @@ -9,7 +9,7 @@ let () = { let prev = delayed.contents () => { prev() - f(succ(n) + i - i, pred(j)) + f(n + 1 + i - i, j - 1) } } } diff --git a/tests/tests/src/gray_code_test.res b/tests/tests/src/gray_code_test.res index 6f7fa87576..d1fbd2fc11 100644 --- a/tests/tests/src/gray_code_test.res +++ b/tests/tests/src/gray_code_test.res @@ -1,22 +1,22 @@ -let gray_encode = b => lxor(b, lsr(b, 1)) +let gray_encode = b => Int.bitwiseXor(b, Int.shiftRightUnsigned(b, 1)) let gray_decode = n => { let rec aux = (p, n) => if n == 0 { p } else { - aux(lxor(p, n), lsr(n, 1)) + aux(Int.bitwiseXor(p, n), Int.shiftRightUnsigned(n, 1)) } - aux(n, lsr(n, 1)) + aux(n, Int.shiftRightUnsigned(n, 1)) } let next_power = v => { let v = v - 1 - let v = lor(lsr(v, 1), v) - let v = lor(lsr(v, 2), v) - let v = lor(lsr(v, 4), v) - let v = lor(lsr(v, 8), v) - let v = lor(lsr(v, 16), v) + let v = Int.bitwiseOr(Int.shiftRightUnsigned(v, 1), v) + let v = Int.bitwiseOr(Int.shiftRightUnsigned(v, 2), v) + let v = Int.bitwiseOr(Int.shiftRightUnsigned(v, 4), v) + let v = Int.bitwiseOr(Int.shiftRightUnsigned(v, 8), v) + let v = Int.bitwiseOr(Int.shiftRightUnsigned(v, 16), v) v + 1 } diff --git a/tests/tests/src/int_overflow_test.mjs b/tests/tests/src/int_overflow_test.mjs index c1dcee99f4..ea4ed28dec 100644 --- a/tests/tests/src/int_overflow_test.mjs +++ b/tests/tests/src/int_overflow_test.mjs @@ -39,18 +39,18 @@ function fib(x) { } Mocha.describe("Int_overflow_test", () => { - Mocha.test("plus_overflow", () => Test_utils.eq("File \"int_overflow_test.res\", line 51, characters 33-40", true, true)); - Mocha.test("minus_overflow", () => Test_utils.eq("File \"int_overflow_test.res\", line 52, characters 34-41", true, true)); - Mocha.test("flow_again1", () => Test_utils.eq("File \"int_overflow_test.res\", line 53, characters 31-38", 2147483646, 2147483646)); - Mocha.test("flow_again2", () => Test_utils.eq("File \"int_overflow_test.res\", line 54, characters 31-38", -2, -2)); - Mocha.test("hash_test", () => Test_utils.eq("File \"int_overflow_test.res\", line 55, characters 29-36", hash_variant("xxyyzzuuxxzzyy00112233"), 544087776)); - Mocha.test("hash_test2", () => Test_utils.eq("File \"int_overflow_test.res\", line 56, characters 30-37", hash_variant("xxyyzxzzyy"), -449896130)); - Mocha.test("hash_variant_test1", () => Test_utils.eq("File \"int_overflow_test.res\", line 57, characters 38-45", hash_variant2("xxyyzzuuxxzzyy00112233"), 544087776)); - Mocha.test("hash_variant_test2", () => Test_utils.eq("File \"int_overflow_test.res\", line 58, characters 38-45", hash_variant2("xxyyzxzzyy"), -449896130)); - Mocha.test("int_literal_flow", () => Test_utils.eq("File \"int_overflow_test.res\", line 59, characters 36-43", -1, -1)); - Mocha.test("int_literal_flow2", () => Test_utils.eq("File \"int_overflow_test.res\", line 60, characters 37-44", -1, -1)); - Mocha.test("float_conversion_test1", () => Test_utils.eq("File \"int_overflow_test.res\", line 62, characters 7-14", Stdlib_Option.map(Stdlib_Float.fromString("3"), prim => prim | 0), 3)); - Mocha.test("float_conversion_test2", () => Test_utils.eq("File \"int_overflow_test.res\", line 65, characters 7-14", Stdlib_Option.map(Stdlib_Float.fromString("3.2"), prim => prim | 0), 3)); + Mocha.test("plus_overflow", () => Test_utils.eq("File \"int_overflow_test.res\", line 55, characters 33-40", true, true)); + Mocha.test("minus_overflow", () => Test_utils.eq("File \"int_overflow_test.res\", line 56, characters 34-41", true, true)); + Mocha.test("flow_again1", () => Test_utils.eq("File \"int_overflow_test.res\", line 57, characters 31-38", 2147483646, 2147483646)); + Mocha.test("flow_again2", () => Test_utils.eq("File \"int_overflow_test.res\", line 58, characters 31-38", -2, -2)); + Mocha.test("hash_test", () => Test_utils.eq("File \"int_overflow_test.res\", line 59, characters 29-36", hash_variant("xxyyzzuuxxzzyy00112233"), 544087776)); + Mocha.test("hash_test2", () => Test_utils.eq("File \"int_overflow_test.res\", line 60, characters 30-37", hash_variant("xxyyzxzzyy"), -449896130)); + Mocha.test("hash_variant_test1", () => Test_utils.eq("File \"int_overflow_test.res\", line 61, characters 38-45", hash_variant2("xxyyzzuuxxzzyy00112233"), 544087776)); + Mocha.test("hash_variant_test2", () => Test_utils.eq("File \"int_overflow_test.res\", line 62, characters 38-45", hash_variant2("xxyyzxzzyy"), -449896130)); + Mocha.test("int_literal_flow", () => Test_utils.eq("File \"int_overflow_test.res\", line 63, characters 36-43", -1, -1)); + Mocha.test("int_literal_flow2", () => Test_utils.eq("File \"int_overflow_test.res\", line 64, characters 37-44", -1, -1)); + Mocha.test("float_conversion_test1", () => Test_utils.eq("File \"int_overflow_test.res\", line 66, characters 7-14", Stdlib_Option.map(Stdlib_Float.fromString("3"), prim => prim | 0), 3)); + Mocha.test("float_conversion_test2", () => Test_utils.eq("File \"int_overflow_test.res\", line 69, characters 7-14", Stdlib_Option.map(Stdlib_Float.fromString("3.2"), prim => prim | 0), 3)); }); let max_int = 2147483647; diff --git a/tests/tests/src/int_overflow_test.res b/tests/tests/src/int_overflow_test.res index 223cfd8abd..638ff77fa3 100644 --- a/tests/tests/src/int_overflow_test.res +++ b/tests/tests/src/int_overflow_test.res @@ -9,7 +9,11 @@ let min_int = -2147483648 // 0x7FFFFFFF let hash_variant = s => { let accu = ref(0) for i in 0 to String.length(s) - 1 { - accu := land(223 * accu.contents + String.codePointAt(s, i)->Option.getUnsafe, lsl(1, 31) - 1) + accu := + Int.bitwiseAnd( + 223 * accu.contents + String.codePointAt(s, i)->Option.getUnsafe, + Int.shiftLeft(1, 31) - 1, + ) /* Here accu is 31 bits, times 223 will not be than 53 bits.. TODO: we can use `Sys.backend_type` for patching */ @@ -19,7 +23,7 @@ let hash_variant = s => { /* accu := !accu land (1 lsl 31 - 1); */ /* make it signed for 64 bits architectures */ if accu.contents > 0x3FFFFFFF { - lor(accu.contents - lsl(1, 31), 0) + Int.bitwiseOr(accu.contents - Int.shiftLeft(1, 31), 0) } else { accu.contents } @@ -31,11 +35,11 @@ let hash_variant2 = s => { accu := 223 * accu.contents + String.codePointAt(s, i)->Option.getUnsafe } /* reduce to 31 bits */ - accu := land(accu.contents, lsl(1, 31) - 1) + accu := Int.bitwiseAnd(accu.contents, Int.shiftLeft(1, 31) - 1) /* make it signed for 64 bits architectures */ if accu.contents > 0x3FFFFFFF { - accu.contents - lsl(1, 31) + accu.contents - Int.shiftLeft(1, 31) } else { accu.contents } @@ -59,9 +63,9 @@ describe(__MODULE__, () => { test("int_literal_flow", () => eq(__LOC__, -1, 0xffffffff)) test("int_literal_flow2", () => eq(__LOC__, -1, -1)) test("float_conversion_test1", () => - eq(__LOC__, Float.fromString("3")->Option.map(int_of_float), Some(3)) + eq(__LOC__, Float.fromString("3")->Option.map(Float.toInt), Some(3)) ) test("float_conversion_test2", () => - eq(__LOC__, Float.fromString("3.2")->Option.map(int_of_float), Some(3)) + eq(__LOC__, Float.fromString("3.2")->Option.map(Float.toInt), Some(3)) ) }) diff --git a/tests/tests/src/lazy_test.res b/tests/tests/src/lazy_test.res index 3b080de922..aeaf89ef05 100644 --- a/tests/tests/src/lazy_test.res +++ b/tests/tests/src/lazy_test.res @@ -41,7 +41,7 @@ let exotic = x => let l_from_fun = Lazy.make(_ => 3) let forward_test = Lazy.make(() => { let u = ref(3) - incr(u) + Int.Ref.increment(u) u.contents }) diff --git a/tests/tests/src/limits_test.mjs b/tests/tests/src/limits_test.mjs index b83bd873b4..4bad0bfded 100644 --- a/tests/tests/src/limits_test.mjs +++ b/tests/tests/src/limits_test.mjs @@ -1,12 +1,12 @@ // Generated by ReScript, PLEASE EDIT WITH CARE import * as Mocha from "mocha"; -import * as Pervasives from "@rescript/runtime/lib/es6/Pervasives.mjs"; +import * as Stdlib_Int from "@rescript/runtime/lib/es6/Stdlib_Int.mjs"; import * as Test_utils from "./test_utils.mjs"; Mocha.describe("Limits_test", () => { - Mocha.test("max_int", () => Test_utils.eq("File \"limits_test.res\", line 5, characters 27-34", Pervasives.max_int, 2147483647)); - Mocha.test("min_int", () => Test_utils.eq("File \"limits_test.res\", line 6, characters 27-34", Pervasives.min_int, -2147483648)); + Mocha.test("max_int", () => Test_utils.eq("File \"limits_test.res\", line 5, characters 27-34", Stdlib_Int.Constants.maxValue, 2147483647)); + Mocha.test("min_int", () => Test_utils.eq("File \"limits_test.res\", line 6, characters 27-34", Stdlib_Int.Constants.minValue, -2147483648)); }); /* Not a pure module */ diff --git a/tests/tests/src/limits_test.res b/tests/tests/src/limits_test.res index c21b0e921f..c83fe805f1 100644 --- a/tests/tests/src/limits_test.res +++ b/tests/tests/src/limits_test.res @@ -2,6 +2,6 @@ open Mocha open Test_utils describe(__MODULE__, () => { - test("max_int", () => eq(__LOC__, max_int, %raw("2147483647"))) - test("min_int", () => eq(__LOC__, min_int, %raw("-2147483648"))) + test("max_int", () => eq(__LOC__, Int.Constants.maxValue, %raw("2147483647"))) + test("min_int", () => eq(__LOC__, Int.Constants.minValue, %raw("-2147483648"))) }) diff --git a/tests/tests/src/loop_regression_test.res b/tests/tests/src/loop_regression_test.res index ebdd10af89..9e318d1d34 100644 --- a/tests/tests/src/loop_regression_test.res +++ b/tests/tests/src/loop_regression_test.res @@ -10,7 +10,7 @@ let f = () => { acc.contents } else { acc := acc.contents + v.contents - incr(v) + Int.Ref.increment(v) loop(n) } loop(10) diff --git a/tests/tests/src/mario_game.mjs b/tests/tests/src/mario_game.mjs index 1f175463ad..9463f53747 100644 --- a/tests/tests/src/mario_game.mjs +++ b/tests/tests/src/mario_game.mjs @@ -1,6 +1,7 @@ // Generated by ReScript, PLEASE EDIT WITH CARE import * as Pervasives from "@rescript/runtime/lib/es6/Pervasives.mjs"; +import * as Stdlib_Int from "@rescript/runtime/lib/es6/Stdlib_Int.mjs"; import * as Stdlib_List from "@rescript/runtime/lib/es6/Stdlib_List.mjs"; import * as Primitive_int from "@rescript/runtime/lib/es6/Primitive_int.mjs"; import * as Primitive_float from "@rescript/runtime/lib/es6/Primitive_float.mjs"; @@ -790,7 +791,7 @@ let Particle = { }; let id_counter = { - contents: Pervasives.min_int + contents: Stdlib_Int.Constants.minValue }; function setup_obj(has_gravityOpt, speedOpt, param) { @@ -1329,7 +1330,7 @@ function kill(collid, ctx) { hd: make$1(undefined, undefined, "GoombaSquish", pos, ctx), tl: /* [] */0 }) : /* [] */0; - return Pervasives.$at(score, remains); + return Stdlib_List.concat(score, remains); case "Item" : let o$1 = collid._2; if (collid._0 === "Mushroom") { @@ -2225,7 +2226,7 @@ function run_update_collid(state, collid, all_collids) { player = collid; } let evolved = update_collidable(state, player, all_collids); - collid_objs.contents = Pervasives.$at(collid_objs.contents, evolved); + collid_objs.contents = Stdlib_List.concat(collid_objs.contents, evolved); return player; } let obj = collid._2; @@ -2233,11 +2234,11 @@ function run_update_collid(state, collid, all_collids) { if (!obj.kill) { collid_objs.contents = { hd: collid, - tl: Pervasives.$at(collid_objs.contents, evolved$1) + tl: Stdlib_List.concat(collid_objs.contents, evolved$1) }; } let new_parts = obj.kill ? kill(collid, state.ctx) : /* [] */0; - particles.contents = Pervasives.$at(particles.contents, new_parts); + particles.contents = Stdlib_List.concat(particles.contents, new_parts); return collid; } @@ -2430,7 +2431,7 @@ function convert_list(lst) { return /* [] */0; } let h = lst.hd; - return Pervasives.$at({ + return Stdlib_List.concat({ hd: [ h[0], [ @@ -2484,7 +2485,7 @@ function avoid_overlap(_lst, currentLst) { let t = lst.tl; let h = lst.hd; if (!mem_loc(h[1], currentLst)) { - return Pervasives.$at({ + return Stdlib_List.concat({ hd: h, tl: /* [] */0 }, avoid_overlap(t, currentLst)); @@ -2507,7 +2508,7 @@ function trim_edges(_lst, blockw, blockh) { let pixx = blockw * 16; let pixy = blockh * 16; if (!(cx < 128 || pixx - cx < 528 || cy === 0 || pixy - cy < 48)) { - return Pervasives.$at({ + return Stdlib_List.concat({ hd: h, tl: /* [] */0 }, trim_edges(t, blockw, blockh)); @@ -2521,7 +2522,7 @@ function generate_clouds(cbx, cby, typ, num) { if (num === 0) { return /* [] */0; } else { - return Pervasives.$at({ + return Stdlib_List.concat({ hd: [ typ, [ @@ -2546,7 +2547,7 @@ function generate_coins(_block_coord) { if (place_coin === 0) { let xc = h[1][0]; let yc = h[1][1]; - return Pervasives.$at({ + return Stdlib_List.concat({ hd: [ 0, [ @@ -2743,7 +2744,7 @@ function choose_block_pattern(blockw, blockh, cbx, cby, prob) { hd: one_0, tl: /* [] */0 }; - return Pervasives.$at(four, Pervasives.$at(three, Pervasives.$at(two, one))); + return Stdlib_List.concat(four, Stdlib_List.concat(three, Stdlib_List.concat(two, one))); } else { return /* [] */0; } @@ -2821,7 +2822,7 @@ function choose_block_pattern(blockw, blockh, cbx, cby, prob) { hd: one_0$1, tl: one_1 }; - return Pervasives.$at(three$1, Pervasives.$at(two$1, one$1)); + return Stdlib_List.concat(three$1, Stdlib_List.concat(two$1, one$1)); } else if (blockh - cby > 2) { let one_0$2 = [ stair_typ, @@ -2895,7 +2896,7 @@ function choose_block_pattern(blockw, blockh, cbx, cby, prob) { hd: three_0$2, tl: three_1$2 }; - return Pervasives.$at(one$2, Pervasives.$at(two$2, three$2)); + return Stdlib_List.concat(one$2, Stdlib_List.concat(two$2, three$2)); } else { return { hd: [ @@ -3018,7 +3019,7 @@ function generate_enemies(blockw, blockh, _cbx, _cby, acc) { hd: enemy_0, tl: /* [] */0 }; - return Pervasives.$at(enemy, generate_enemies(blockw, blockh, cbx, cby + 1, acc)); + return Stdlib_List.concat(enemy, generate_enemies(blockw, blockh, cbx, cby + 1, acc)); } _cby = cby + 1; continue; @@ -3038,7 +3039,7 @@ function generate_block_enemies(_block_coord) { if (place_enemy === 0) { let xc = h[1][0]; let yc = h[1][1]; - return Pervasives.$at({ + return Stdlib_List.concat({ hd: [ enemy_typ, [ @@ -3078,7 +3079,7 @@ function generate_block_locs(blockw, blockh, _cbx, _cby, _acc) { if (prob < 5) { let newacc = choose_block_pattern(blockw, blockh, cbx, cby, prob); let undup_lst = avoid_overlap(newacc, acc); - let called_acc = Pervasives.$at(acc, undup_lst); + let called_acc = Stdlib_List.concat(acc, undup_lst); _acc = called_acc; _cby = cby + 1; continue; @@ -3107,7 +3108,7 @@ function generate_ground(blockw, blockh, _inc, _acc) { } if (inc > 10) { let skip = int(10); - let newacc = Pervasives.$at(acc, { + let newacc = Stdlib_List.concat(acc, { hd: [ 4, [ @@ -3125,7 +3126,7 @@ function generate_ground(blockw, blockh, _inc, _acc) { _inc = inc + 1; continue; } - let newacc$1 = Pervasives.$at(acc, { + let newacc$1 = Stdlib_List.concat(acc, { hd: [ 4, [ @@ -3151,7 +3152,7 @@ function convert_to_block_obj(lst, context) { TAG: "SBlock", _0: sblock_typ }, context, h[1]); - return Pervasives.$at({ + return Stdlib_List.concat({ hd: ob, tl: /* [] */0 }, convert_to_block_obj(lst.tl, context)); @@ -3167,7 +3168,7 @@ function convert_to_enemy_obj(lst, context) { TAG: "SEnemy", _0: senemy_typ }, context, h[1]); - return Pervasives.$at({ + return Stdlib_List.concat({ hd: ob, tl: /* [] */0 }, convert_to_enemy_obj(lst.tl, context)); @@ -3181,7 +3182,7 @@ function convert_to_coin_obj(lst, context) { TAG: "SItem", _0: "Coin" }, context, lst.hd[1]); - return Pervasives.$at({ + return Stdlib_List.concat({ hd: ob, tl: /* [] */0 }, convert_to_coin_obj(lst.tl, context)); @@ -3193,19 +3194,19 @@ function generate_helper(blockw, blockh, cx, cy, context) { let obj_converted_block_locs = convert_to_block_obj(converted_block_locs, context); let ground_blocks = generate_ground(blockw, blockh, 0, /* [] */0); let obj_converted_ground_blocks = convert_to_block_obj(ground_blocks, context); - let block_locations = Pervasives.$at(block_locs, ground_blocks); - let all_blocks = Pervasives.$at(obj_converted_block_locs, obj_converted_ground_blocks); + let block_locations = Stdlib_List.concat(block_locs, ground_blocks); + let all_blocks = Stdlib_List.concat(obj_converted_block_locs, obj_converted_ground_blocks); let enemy_locs = generate_enemies(blockw, blockh, 0, 0, block_locations); let obj_converted_enemies = convert_to_enemy_obj(enemy_locs, context); let coin_locs = generate_coins(converted_block_locs); let undup_coin_locs = trim_edges(avoid_overlap(coin_locs, converted_block_locs), blockw, blockh); - let converted_block_coin_locs = Pervasives.$at(converted_block_locs, coin_locs); + let converted_block_coin_locs = Stdlib_List.concat(converted_block_locs, coin_locs); let enemy_block_locs = generate_block_enemies(converted_block_locs); let undup_enemy_block_locs = avoid_overlap(enemy_block_locs, converted_block_coin_locs); let obj_enemy_blocks = convert_to_enemy_obj(undup_enemy_block_locs, context); let coin_objects = convert_to_coin_obj(undup_coin_locs, context); let obj_panel = generate_panel(context, blockw, blockh); - return Pervasives.$at(all_blocks, Pervasives.$at(obj_converted_enemies, Pervasives.$at(coin_objects, Pervasives.$at(obj_enemy_blocks, { + return Stdlib_List.concat(all_blocks, Stdlib_List.concat(obj_converted_enemies, Stdlib_List.concat(coin_objects, Stdlib_List.concat(obj_enemy_blocks, { hd: obj_panel, tl: /* [] */0 })))); diff --git a/tests/tests/src/mario_game.res b/tests/tests/src/mario_game.res index 7d8c205e45..20345edbbe 100644 --- a/tests/tests/src/mario_game.res +++ b/tests/tests/src/mario_game.res @@ -704,8 +704,8 @@ module Particle: { /* Converts an x,y [pair] to an Actors.xy record */ let pair_to_xy = pair => { - x: fst(pair), - y: snd(pair), + x: Pair.first(pair), + y: Pair.second(pair), } /* Function wrapper to assist in generating the template paramss for a @@ -910,7 +910,7 @@ module Object: { speed: float, } - let id_counter = ref(min_int) + let id_counter = ref(Int.Constants.minValue) type obj = { params: obj_params, @@ -1083,7 +1083,7 @@ module Object: { player.jumping = true player.grounded = false player.vel.y = max( - player.vel.y -. (player_jump +. abs_float(player.vel.x) *. 0.25), + player.vel.y -. (player_jump +. Math.abs(player.vel.x) *. 0.25), player_max_jump, ) } @@ -1108,10 +1108,10 @@ module Object: { *Mario sprites/collidables should be used. */ let update_player = (player, keys, context) => { let prev_jumping = player.jumping - let prev_dir = player.dir and prev_vx = abs_float(player.vel.x) + let prev_dir = player.dir and prev_vx = Math.abs(player.vel.x) keys->List.forEach(update_player_keys(player, ...)) let v = player.vel.x *. friction - let vel_damped = if abs_float(v) < 0.1 { + let vel_damped = if Math.abs(v) < 0.1 { 0. } else { v @@ -1125,7 +1125,7 @@ module Object: { if !prev_jumping && player.jumping { Some(pl_typ, Sprite.make(SPlayer(pl_typ, Jumping), player.dir, context)) } else if ( - prev_dir != player.dir || (prev_vx == 0. && abs_float(player.vel.x) > 0. && !player.jumping) + prev_dir != player.dir || (prev_vx == 0. && Math.abs(player.vel.x) > 0. && !player.jumping) ) { Some(pl_typ, Sprite.make(SPlayer(pl_typ, Running), player.dir, context)) } else if prev_dir != player.dir && (player.jumping && prev_jumping) { @@ -1144,7 +1144,7 @@ module Object: { if obj.grounded { obj.vel.y = 0. } else if obj.params.has_gravity { - obj.vel.y = min(obj.vel.y +. gravity +. abs_float(obj.vel.y) *. 0.01, max_y_vel) + obj.vel.y = min(obj.vel.y +. gravity +. Math.abs(obj.vel.y) *. 0.01, max_y_vel) } let update_pos = obj => { @@ -1271,7 +1271,7 @@ module Object: { let spawn_above = (player_dir, obj, typ, context) => { let item = spawn(SItem(typ), context, (obj.pos.x, obj.pos.y)) let item_obj = get_obj(item) - item_obj.pos.y = item_obj.pos.y -. snd(get_sprite(item).params.frame_size) + item_obj.pos.y = item_obj.pos.y -. Pair.second(get_sprite(item).params.frame_size) item_obj.dir = opposite_dir(player_dir) set_vel_to_speed(item_obj) item @@ -1320,9 +1320,9 @@ module Object: { let vy = b1.center.y -. b2.center.y let hwidths = b1.half.x +. b2.half.x let hheights = b1.half.y +. b2.half.y - if abs_float(vx) < hwidths && abs_float(vy) < hheights { - let ox = hwidths -. abs_float(vx) - let oy = hheights -. abs_float(vy) + if Math.abs(vx) < hwidths && Math.abs(vy) < hheights { + let ox = hwidths -. Math.abs(vx) + let oy = hheights -. Math.abs(vy) if ox >= oy { if vy > 0. { o1.pos.y = o1.pos.y +. oy @@ -1358,7 +1358,7 @@ module Object: { | Goomba => list{Particle.make(GoombaSquish, pos, ctx)} | _ => list{} } - \"@"(score, remains) + List.concat(score, remains) | Block(t, s, o) => switch t { | Brick => @@ -1433,7 +1433,7 @@ module Draw: { let (sw, sh) = sprite.params.frame_size let (dx, dy) = (posx, posy) let (dw, dh) = sprite.params.frame_size - let sx = sx +. float_of_int(sprite.frame.contents) *. sw + let sx = sx +. Int.toFloat(sprite.frame.contents) *. sw /* Console.log(sprite.frame) */ /* context##clearRect(0.,0.,sw, sh); */ context["drawImage"](sprite.img, sx, sy, sw, sh, dx, dy, dw, dh) @@ -1444,15 +1444,15 @@ module Draw: { *between two background images. */ let draw_bgd = (bgd, off_x) => { render(bgd, (-.off_x, 0.)) - render(bgd, (fst(bgd.params.frame_size) -. off_x, 0.)) + render(bgd, (Pair.first(bgd.params.frame_size) -. off_x, 0.)) } /* Used for animation updating. Canvas is cleared each frame and redrawn. */ let clear_canvas = canvas => { let canvas = Dom_html.canvasElementToJsObj(canvas) let context = Dom_html.canvasRenderingContext2DToJsObj(canvas["getContext"]("2d")) - let cwidth = float_of_int(canvas["width"]) - let cheight = float_of_int(canvas["height"]) + let cwidth = Int.toFloat(canvas["width"]) + let cheight = Int.toFloat(canvas["height"]) ignore(context["clearRect"](0., 0., cwidth, cheight)) } @@ -1464,7 +1464,7 @@ module Draw: { let context = Dom_html.canvasRenderingContext2DToJsObj(canvas["getContext"]("2d")) ignore(context["font"] = "10px 'Press Start 2P'") ignore( - context["fillText"]("Score: " ++ score_string, float_of_int(canvas["width"]) -. 140., 18.), + context["fillText"]("Score: " ++ score_string, Int.toFloat(canvas["width"]) -. 140., 18.), ) ignore(context["fillText"]("Coins: " ++ coin_string, 120., 18.)) } @@ -1551,7 +1551,7 @@ module Viewport: { * centered about the origin point. */ let calc_viewport_point = (cc, vc, mc) => { let vc_half = vc /. 2. - min(max(cc -. vc_half, 0.), min(mc -. vc, abs_float(cc -. vc_half))) + min(max(cc -. vc_half, 0.), min(mc -. vc, Math.abs(cc -. vc_half))) } /* Returns whether a coordinate pair [pos] is inside the viewport [v] */ @@ -2001,8 +2001,8 @@ module Director: { let k = pressed_keys let ctrls = list{(k.left, CLeft), (k.right, CRight), (k.up, CUp), (k.down, CDown)} ctrls->List.reduceReverse(list{}, (a, x) => - if fst(x) { - list{snd(x), ...a} + if Pair.first(x) { + list{Pair.second(x), ...a} } else { a } @@ -2025,20 +2025,20 @@ module Director: { Player(new_typ, new_spr, o) } let evolved = update_collidable(state, player, all_collids) - collid_objs := \"@"(collid_objs.contents, evolved) + collid_objs := List.concat(collid_objs.contents, evolved) player | _ => let obj = get_obj(collid) let evolved = update_collidable(state, collid, all_collids) if !obj.kill { - collid_objs := list{collid, ...\"@"(collid_objs.contents, evolved)} + collid_objs := list{collid, ...List.concat(collid_objs.contents, evolved)} } let new_parts = if obj.kill { Object.kill(collid, state.ctx) } else { list{} } - particles := \"@"(particles.contents, new_parts) + particles := List.concat(particles.contents, new_parts) collid } @@ -2057,8 +2057,8 @@ module Director: { let update_loop = (canvas, (player, objs), map_dim) => { let scale = 1. let ctx = Dom_html.canvasElementToJsObj(canvas)["getContext"]("2d") - let cwidth = float_of_int(Dom_html.canvasElementToJsObj(canvas)["width"]) /. scale - let cheight = float_of_int(Dom_html.canvasElementToJsObj(canvas)["height"]) /. scale + let cwidth = Int.toFloat(Dom_html.canvasElementToJsObj(canvas)["width"]) /. scale + let cheight = Int.toFloat(Dom_html.canvasElementToJsObj(canvas)["height"]) /. scale let viewport = Viewport.make((cwidth, cheight), map_dim) let state = { bgd: Sprite.make_bgd(ctx), @@ -2067,7 +2067,7 @@ module Director: { score: 0, coins: 0, multiplier: 1, - map: snd(map_dim), + map: Pair.second(map_dim), game_over: false, } Dom_html.canvasRenderingContext2DToJsObj(state.ctx)["scale"](scale, scale) @@ -2084,9 +2084,9 @@ module Director: { Draw.clear_canvas(canvas) /* Parallax background */ - let vpos_x_int = int_of_float(state.vpt.pos.x /. 5.) - let bgd_width = int_of_float(fst(state.bgd.params.frame_size)) - Draw.draw_bgd(state.bgd, float_of_int(mod(vpos_x_int, bgd_width))) + let vpos_x_int = Float.toInt(state.vpt.pos.x /. 5.) + let bgd_width = Float.toInt(Pair.first(state.bgd.params.frame_size)) + Draw.draw_bgd(state.bgd, Int.toFloat(mod(vpos_x_int, bgd_width))) let player = run_update_collid(state, player, objs) @@ -2163,7 +2163,7 @@ module Procedural_generator: { switch loclist { | list{} => false | list{h, ...t} => - if checkloc == snd(h) { + if checkloc == Pair.second(h) { true } else { mem_loc(checkloc, t) @@ -2176,7 +2176,12 @@ module Procedural_generator: { switch lst { | list{} => list{} | list{h, ...t} => - \"@"(list{(fst(h), (fst(snd(h)) *. 16., snd(snd(h)) *. 16.))}, convert_list(t)) + List.concat( + list{ + (Pair.first(h), (Pair.first(Pair.second(h)) *. 16., Pair.second(Pair.second(h)) *. 16.)), + }, + convert_list(t), + ) } /* Chooses what type of enemy should be instantiated given typ number */ @@ -2205,10 +2210,10 @@ module Procedural_generator: { switch lst { | list{} => list{} | list{h, ...t} => - if mem_loc(snd(h), currentLst) { + if mem_loc(Pair.second(h), currentLst) { avoid_overlap(t, currentLst) } else { - \"@"(list{h}, avoid_overlap(t, currentLst)) + List.concat(list{h}, avoid_overlap(t, currentLst)) } } @@ -2218,14 +2223,14 @@ module Procedural_generator: { switch lst { | list{} => list{} | list{h, ...t} => - let cx = fst(snd(h)) - let cy = snd(snd(h)) + let cx = Pair.first(Pair.second(h)) + let cy = Pair.second(Pair.second(h)) let pixx = blockw *. 16. let pixy = blockh *. 16. if cx < 128. || (pixx -. cx < 528. || (cy == 0. || pixy -. cy < 48.)) { trim_edges(t, blockw, blockh) } else { - \"@"(list{h}, trim_edges(t, blockw, blockh)) + List.concat(list{h}, trim_edges(t, blockw, blockh)) } } @@ -2245,7 +2250,7 @@ module Procedural_generator: { } let two = list{(typ, (cbx +. 2., cby -. 2.)), (typ, (cbx +. 3., cby -. 2.))} let one = list{(typ, (cbx +. 3., cby -. 3.))} - \"@"(four, \"@"(three, \"@"(two, one))) + List.concat(four, List.concat(three, List.concat(two, one))) } /* Generates a stair formation going upwards. */ @@ -2257,7 +2262,7 @@ module Procedural_generator: { (typ, (cbx +. 5., cby -. 2.)), (typ, (cbx +. 6., cby -. 2.)), } - \"@"(one, \"@"(two, three)) + List.concat(one, List.concat(two, three)) } /* Generates a stair formation going downwards */ @@ -2265,7 +2270,7 @@ module Procedural_generator: { let three = list{(typ, (cbx, cby)), (typ, (cbx +. 1., cby)), (typ, (cbx +. 2., cby))} let two = list{(typ, (cbx +. 2., cby +. 1.)), (typ, (cbx +. 3., cby +. 1.))} let one = list{(typ, (cbx +. 5., cby +. 2.)), (typ, (cbx +. 6., cby +. 2.))} - \"@"(three, \"@"(two, one)) + List.concat(three, List.concat(two, one)) } /* Generates a cloud block platform with some length num. */ @@ -2273,7 +2278,7 @@ module Procedural_generator: { if num == 0 { list{} } else { - \"@"(list{(typ, (cbx, cby))}, generate_clouds(cbx +. 1., cby, typ, num - 1)) + List.concat(list{(typ, (cbx, cby))}, generate_clouds(cbx +. 1., cby, typ, num - 1)) } /* Generates an obj_coord list (typ, coordinates) of coins to be placed. */ @@ -2283,9 +2288,9 @@ module Procedural_generator: { | list{} => list{} | list{h, ...t} => if place_coin == 0 { - let xc = fst(snd(h)) - let yc = snd(snd(h)) - \"@"(list{(0, (xc, yc -. 16.))}, generate_coins(t)) + let xc = Pair.first(Pair.second(h)) + let yc = Pair.second(Pair.second(h)) + List.concat(list{(0, (xc, yc -. 16.))}, generate_coins(t)) } else { generate_coins(t) } @@ -2390,7 +2395,7 @@ module Procedural_generator: { let enem_prob = 3 if prob < enem_prob && blockh -. 1. == cby { let enemy = list{(prob, (cbx *. 16., cby *. 16.))} - \"@"(enemy, generate_enemies(blockw, blockh, cbx, cby +. 1., acc)) + List.concat(enemy, generate_enemies(blockw, blockh, cbx, cby +. 1., acc)) } else { generate_enemies(blockw, blockh, cbx, cby +. 1., acc) } @@ -2404,9 +2409,9 @@ module Procedural_generator: { | list{} => list{} | list{h, ...t} => if place_enemy == 0 { - let xc = fst(snd(h)) - let yc = snd(snd(h)) - \"@"(list{(enemy_typ, (xc, yc -. 16.))}, generate_block_enemies(t)) + let xc = Pair.first(Pair.second(h)) + let yc = Pair.second(Pair.second(h)) + List.concat(list{(enemy_typ, (xc, yc -. 16.))}, generate_block_enemies(t)) } else { generate_block_enemies(t) } @@ -2433,7 +2438,7 @@ module Procedural_generator: { if prob < block_prob { let newacc = choose_block_pattern(blockw, blockh, cbx, cby, prob) let undup_lst = avoid_overlap(newacc, acc) - let called_acc = \"@"(acc, undup_lst) + let called_acc = List.concat(acc, undup_lst) generate_block_locs(blockw, blockh, cbx, cby +. 1., called_acc) } else { generate_block_locs(blockw, blockh, cbx, cby +. 1., acc) @@ -2464,14 +2469,14 @@ module Procedural_generator: { acc } else if inc > 10. { let skip = Random.int(10) - let newacc = \"@"(acc, list{(4, (inc *. 16., blockh *. 16.))}) + let newacc = List.concat(acc, list{(4, (inc *. 16., blockh *. 16.))}) if skip == 7 && blockw -. inc > 32. { generate_ground(blockw, blockh, inc +. 1., acc) } else { generate_ground(blockw, blockh, inc +. 1., newacc) } } else { - let newacc = \"@"(acc, list{(4, (inc *. 16., blockh *. 16.))}) + let newacc = List.concat(acc, list{(4, (inc *. 16., blockh *. 16.))}) generate_ground(blockw, blockh, inc +. 1., newacc) } @@ -2484,9 +2489,9 @@ module Procedural_generator: { switch lst { | list{} => list{} | list{h, ...t} => - let sblock_typ = choose_sblock_typ(fst(h)) - let ob = Object.spawn(SBlock(sblock_typ), context, snd(h)) - \"@"(list{ob}, convert_to_block_obj(t, context)) + let sblock_typ = choose_sblock_typ(Pair.first(h)) + let ob = Object.spawn(SBlock(sblock_typ), context, Pair.second(h)) + List.concat(list{ob}, convert_to_block_obj(t, context)) } /* Converts the obj_coord list called by generate_enemies to a list of objects @@ -2498,9 +2503,9 @@ module Procedural_generator: { switch lst { | list{} => list{} | list{h, ...t} => - let senemy_typ = choose_enemy_typ(fst(h)) - let ob = Object.spawn(SEnemy(senemy_typ), context, snd(h)) - \"@"(list{ob}, convert_to_enemy_obj(t, context)) + let senemy_typ = choose_enemy_typ(Pair.first(h)) + let ob = Object.spawn(SEnemy(senemy_typ), context, Pair.second(h)) + List.concat(list{ob}, convert_to_enemy_obj(t, context)) } /* Converts the list of coordinates into a list of Coin objects */ @@ -2512,8 +2517,8 @@ module Procedural_generator: { | list{} => list{} | list{h, ...t} => let sitem_typ = Coin - let ob = Object.spawn(SItem(sitem_typ), context, snd(h)) - \"@"(list{ob}, convert_to_coin_obj(t, context)) + let ob = Object.spawn(SItem(sitem_typ), context, Pair.second(h)) + List.concat(list{ob}, convert_to_coin_obj(t, context)) } /* Procedurally generates a list of collidables given canvas width, height and @@ -2531,21 +2536,24 @@ module Procedural_generator: { let obj_converted_block_locs = convert_to_block_obj(converted_block_locs, context) let ground_blocks = generate_ground(blockw, blockh, 0., list{}) let obj_converted_ground_blocks = convert_to_block_obj(ground_blocks, context) - let block_locations = \"@"(block_locs, ground_blocks) - let all_blocks = \"@"(obj_converted_block_locs, obj_converted_ground_blocks) + let block_locations = List.concat(block_locs, ground_blocks) + let all_blocks = List.concat(obj_converted_block_locs, obj_converted_ground_blocks) let enemy_locs = generate_enemies(blockw, blockh, 0., 0., block_locations) let obj_converted_enemies = convert_to_enemy_obj(enemy_locs, context) let coin_locs = generate_coins(converted_block_locs) let undup_coin_locs = trim_edges(avoid_overlap(coin_locs, converted_block_locs), blockw, blockh) - let converted_block_coin_locs = \"@"(converted_block_locs, coin_locs) + let converted_block_coin_locs = List.concat(converted_block_locs, coin_locs) let enemy_block_locs = generate_block_enemies(converted_block_locs) let undup_enemy_block_locs = avoid_overlap(enemy_block_locs, converted_block_coin_locs) let obj_enemy_blocks = convert_to_enemy_obj(undup_enemy_block_locs, context) let coin_objects = convert_to_coin_obj(undup_coin_locs, context) let obj_panel = generate_panel(context, blockw, blockh) - \"@"( + List.concat( all_blocks, - \"@"(obj_converted_enemies, \"@"(coin_objects, \"@"(obj_enemy_blocks, list{obj_panel}))), + List.concat( + obj_converted_enemies, + List.concat(coin_objects, List.concat(obj_enemy_blocks, list{obj_panel})), + ), ) } diff --git a/tests/tests/src/mutable_obj_test.res b/tests/tests/src/mutable_obj_test.res index e4c3904a1f..99ff9f3f80 100644 --- a/tests/tests/src/mutable_obj_test.res +++ b/tests/tests/src/mutable_obj_test.res @@ -9,4 +9,4 @@ let f = (x: {@set({no_get: no_get}) "height": int}) => x["height"] = 3 type v = {@set "dec": int => {"x": int, "y": float}} -let f = (x: v) => x["dec"] = x => {"x": x, "y": float_of_int(x)} +let f = (x: v) => x["dec"] = x => {"x": x, "y": Int.toFloat(x)} diff --git a/tests/tests/src/obj_magic_test.res b/tests/tests/src/obj_magic_test.res index f589851ea6..616a8a5378 100644 --- a/tests/tests/src/obj_magic_test.res +++ b/tests/tests/src/obj_magic_test.res @@ -6,7 +6,7 @@ /* let empty_backtrace = Obj.obj (Obj.new_block Obj.abstract_tag 0) */ -let is_block = x => typeof(Obj.repr(x)) != #number +let is_block = x => typeof(Obj.magic(x)) != #number open Mocha open Test_utils diff --git a/tests/tests/src/optional_ffi_test.res b/tests/tests/src/optional_ffi_test.res index 148e6d091c..72b9825364 100644 --- a/tests/tests/src/optional_ffi_test.res +++ b/tests/tests/src/optional_ffi_test.res @@ -11,7 +11,7 @@ function hey(x, y) { let counter = ref(0) let side_effect = x => { - incr(x) + Int.Ref.increment(x) x.contents } @@ -21,7 +21,7 @@ let bug_to_fix2 = (f, x) => xx(~x=?f(x), ~y=3, ()) /* : [f x] is done once */ let counter2 = ref(0) let side_effect2 = x => { - incr(x) + Int.Ref.increment(x) Some(x.contents) } diff --git a/tests/tests/src/rbset.res b/tests/tests/src/rbset.res index 75b803920d..e4311d1386 100644 --- a/tests/tests/src/rbset.res +++ b/tests/tests/src/rbset.res @@ -190,7 +190,7 @@ let rec remove_aux = (x, n) => } } -let remove = (x, s) => fst(remove_aux(x, s)) +let remove = (x, s) => Pair.first(remove_aux(x, s)) let rec cardinal = x => switch x { diff --git a/tests/tests/src/rec_fun_test.res b/tests/tests/src/rec_fun_test.res index 57a91f30c6..006db5cd2b 100644 --- a/tests/tests/src/rec_fun_test.res +++ b/tests/tests/src/rec_fun_test.res @@ -6,7 +6,7 @@ let called = ref(0) let g = () => { let rec v = ref(next) and next = (i, b) => { - incr(called) + Int.Ref.increment(called) if b { ignore(v.contents(i, false)) } diff --git a/tests/tests/src/set_gen.mjs b/tests/tests/src/set_gen.mjs index 62e5d2de7e..f3a850fbf8 100644 --- a/tests/tests/src/set_gen.mjs +++ b/tests/tests/src/set_gen.mjs @@ -206,7 +206,7 @@ function check_height_and_diff(x) { Error: new Error() }; } - let diff = Pervasives.abs(hl - hr | 0); + let diff = Math.abs(hl - hr | 0); if (diff > 2) { throw { RE_EXN_ID: Height_diff_borken, diff --git a/tests/tests/src/set_gen.res b/tests/tests/src/set_gen.res index 3701a5db8d..19a78b92d1 100644 --- a/tests/tests/src/set_gen.res +++ b/tests/tests/src/set_gen.res @@ -133,7 +133,7 @@ let rec check_height_and_diff = x => if h != max_int_2(hl, hr) + 1 { throw(Height_invariant_broken) } else { - let diff = abs(hl - hr) + let diff = Math.Int.abs(hl - hr) if diff > 2 { throw(Height_diff_borken) } else { @@ -451,7 +451,7 @@ let of_sorted_list = l => { } } - fst(sub(List.length(l), l)) + Pair.first(sub(List.length(l), l)) } let of_sorted_array = l => { diff --git a/tests/tests/src/stdlib/Stdlib_FloatTests.mjs b/tests/tests/src/stdlib/Stdlib_FloatTests.mjs index 52ebed00c9..1f8eb067e6 100644 --- a/tests/tests/src/stdlib/Stdlib_FloatTests.mjs +++ b/tests/tests/src/stdlib/Stdlib_FloatTests.mjs @@ -1,16 +1,21 @@ // Generated by ReScript, PLEASE EDIT WITH CARE import * as Test from "./Test.mjs"; -import * as Pervasives from "@rescript/runtime/lib/es6/Pervasives.mjs"; import * as Stdlib_Float from "@rescript/runtime/lib/es6/Stdlib_Float.mjs"; import * as Primitive_object from "@rescript/runtime/lib/es6/Primitive_object.mjs"; let eq = Primitive_object.equal; +let nan = NaN; + +let infinity = Number.POSITIVE_INFINITY; + +let neg_infinity = Number.NEGATIVE_INFINITY; + Test.run([ [ "Stdlib_FloatTests.res", - 3, + 6, 20, 27 ], @@ -20,7 +25,7 @@ Test.run([ Test.run([ [ "Stdlib_FloatTests.res", - 4, + 7, 20, 35 ], @@ -30,7 +35,7 @@ Test.run([ Test.run([ [ "Stdlib_FloatTests.res", - 5, + 8, 20, 35 ], @@ -40,7 +45,7 @@ Test.run([ Test.run([ [ "Stdlib_FloatTests.res", - 6, + 9, 20, 35 ], @@ -50,7 +55,7 @@ Test.run([ Test.run([ [ "Stdlib_FloatTests.res", - 7, + 10, 20, 35 ], @@ -60,7 +65,7 @@ Test.run([ Test.run([ [ "Stdlib_FloatTests.res", - 8, + 11, 20, 42 ], @@ -70,7 +75,7 @@ Test.run([ Test.run([ [ "Stdlib_FloatTests.res", - 9, + 12, 20, 42 ], @@ -80,7 +85,7 @@ Test.run([ Test.run([ [ "Stdlib_FloatTests.res", - 10, + 13, 20, 42 ], @@ -90,7 +95,7 @@ Test.run([ Test.run([ [ "Stdlib_FloatTests.res", - 11, + 14, 20, 42 ], @@ -100,147 +105,147 @@ Test.run([ Test.run([ [ "Stdlib_FloatTests.res", - 12, + 15, 20, 33 ], "clamp - nan" -], Number.isNaN(Stdlib_Float.clamp(4.1, 4.3, Number.NaN)), eq, true); +], Number.isNaN(Stdlib_Float.clamp(4.1, 4.3, nan)), eq, true); Test.run([ [ "Stdlib_FloatTests.res", - 13, + 16, 20, 38 ], "clamp - infinity" -], Stdlib_Float.clamp(4.1, 4.3, Pervasives.infinity), eq, 4.3); +], Stdlib_Float.clamp(4.1, 4.3, infinity), eq, 4.3); Test.run([ [ "Stdlib_FloatTests.res", - 14, + 17, 20, 39 ], "clamp - -infinity" -], Stdlib_Float.clamp(4.1, 4.3, Pervasives.neg_infinity), eq, 4.1); +], Stdlib_Float.clamp(4.1, 4.3, neg_infinity), eq, 4.1); Test.run([ [ "Stdlib_FloatTests.res", - 15, + 18, 20, 37 ], "clamp - min nan" -], Stdlib_Float.clamp(Number.NaN, undefined, 4.2), eq, 4.2); +], Stdlib_Float.clamp(nan, undefined, 4.2), eq, 4.2); Test.run([ [ "Stdlib_FloatTests.res", - 16, + 19, 20, 37 ], "clamp - max nan" -], Stdlib_Float.clamp(undefined, Number.NaN, 4.2), eq, 4.2); +], Stdlib_Float.clamp(undefined, nan, 4.2), eq, 4.2); Test.run([ [ "Stdlib_FloatTests.res", - 17, + 20, 20, 46 ], "clamp - min nan, max nan" -], Stdlib_Float.clamp(Number.NaN, Number.NaN, 4.2), eq, 4.2); +], Stdlib_Float.clamp(nan, nan, 4.2), eq, 4.2); Test.run([ [ "Stdlib_FloatTests.res", - 18, + 21, 20, 42 ], "clamp - min infinity" -], Stdlib_Float.clamp(Pervasives.infinity, undefined, 4.2), eq, Pervasives.infinity); +], Stdlib_Float.clamp(infinity, undefined, 4.2), eq, infinity); Test.run([ [ "Stdlib_FloatTests.res", - 19, + 22, 20, 42 ], "clamp - max infinity" -], Stdlib_Float.clamp(undefined, Pervasives.infinity, 4.2), eq, 4.2); +], Stdlib_Float.clamp(undefined, infinity, 4.2), eq, 4.2); Test.run([ [ "Stdlib_FloatTests.res", - 20, + 23, 20, 43 ], "clamp - min -infinity" -], Stdlib_Float.clamp(Pervasives.neg_infinity, undefined, 4.2), eq, 4.2); +], Stdlib_Float.clamp(neg_infinity, undefined, 4.2), eq, 4.2); Test.run([ [ "Stdlib_FloatTests.res", - 21, + 24, 20, 43 ], "clamp - max -infinity" -], Stdlib_Float.clamp(undefined, Pervasives.neg_infinity, 4.2), eq, Pervasives.neg_infinity); +], Stdlib_Float.clamp(undefined, neg_infinity, 4.2), eq, neg_infinity); Test.run([ [ "Stdlib_FloatTests.res", - 23, + 26, 13, 49 ], "clamp - min infinity, max infinity" -], Stdlib_Float.clamp(Pervasives.infinity, Pervasives.infinity, 4.2), eq, Pervasives.infinity); +], Stdlib_Float.clamp(infinity, infinity, 4.2), eq, infinity); Test.run([ [ "Stdlib_FloatTests.res", - 29, + 32, 13, 50 ], "clamp - min -infinity, max infinity" -], Stdlib_Float.clamp(Pervasives.neg_infinity, Pervasives.infinity, 4.2), eq, 4.2); +], Stdlib_Float.clamp(neg_infinity, infinity, 4.2), eq, 4.2); Test.run([ [ "Stdlib_FloatTests.res", - 35, + 38, 13, 50 ], "clamp - min infinity, max -infinity" -], Stdlib_Float.clamp(Pervasives.infinity, Pervasives.neg_infinity, 4.2), eq, Pervasives.infinity); +], Stdlib_Float.clamp(infinity, neg_infinity, 4.2), eq, infinity); Test.run([ [ "Stdlib_FloatTests.res", - 41, + 44, 13, 51 ], "clamp - min -infinity, max -infinity" -], Stdlib_Float.clamp(Pervasives.neg_infinity, Pervasives.neg_infinity, 4.2), eq, Pervasives.neg_infinity); +], Stdlib_Float.clamp(neg_infinity, neg_infinity, 4.2), eq, neg_infinity); Test.run([ [ "Stdlib_FloatTests.res", - 47, + 50, 20, 46 ], @@ -249,5 +254,8 @@ Test.run([ export { eq, + nan, + infinity, + neg_infinity, } -/* Not a pure module */ +/* nan Not a pure module */ diff --git a/tests/tests/src/stdlib/Stdlib_FloatTests.res b/tests/tests/src/stdlib/Stdlib_FloatTests.res index 1632c2dffa..45b390e23c 100644 --- a/tests/tests/src/stdlib/Stdlib_FloatTests.res +++ b/tests/tests/src/stdlib/Stdlib_FloatTests.res @@ -1,4 +1,7 @@ let eq = (a, b) => a == b +let nan = Float.Constants.nan +let infinity = Float.Constants.positiveInfinity +let neg_infinity = Float.Constants.negativeInfinity Test.run(__POS_OF__("clamp"), Float.clamp(4.2), eq, 4.2) Test.run(__POS_OF__("clamp - < min"), Float.clamp(~min=4.3, 4.1), eq, 4.3) diff --git a/tests/tests/src/stdlib/Stdlib_TestSuite.mjs b/tests/tests/src/stdlib/Stdlib_TestSuite.mjs index d543249086..1d33e63055 100644 --- a/tests/tests/src/stdlib/Stdlib_TestSuite.mjs +++ b/tests/tests/src/stdlib/Stdlib_TestSuite.mjs @@ -70,6 +70,12 @@ let areSame = Stdlib_TypedArrayTests.areSame; let o = Stdlib_TypedArrayTests.o; +let nan = Stdlib_FloatTests.nan; + +let infinity = Stdlib_FloatTests.infinity; + +let neg_infinity = Stdlib_FloatTests.neg_infinity; + let decodeJsonTest = Stdlib_JsonTests.decodeJsonTest; let shouldHandleNullableValues = Stdlib_NullableTests.shouldHandleNullableValues; @@ -194,6 +200,9 @@ export { assertWillThrow, areSame, o, + nan, + infinity, + neg_infinity, decodeJsonTest, shouldHandleNullableValues, someString, diff --git a/tests/tests/src/stdlib/Stdlib_TestTests.mjs b/tests/tests/src/stdlib/Stdlib_TestTests.mjs index 3f33104ade..3f5ed23ec5 100644 --- a/tests/tests/src/stdlib/Stdlib_TestTests.mjs +++ b/tests/tests/src/stdlib/Stdlib_TestTests.mjs @@ -1,13 +1,16 @@ // Generated by ReScript, PLEASE EDIT WITH CARE import * as Test from "./Test.mjs"; -import * as Pervasives from "@rescript/runtime/lib/es6/Pervasives.mjs"; import * as Stdlib_BigInt from "@rescript/runtime/lib/es6/Stdlib_BigInt.mjs"; import * as Stdlib_Option from "@rescript/runtime/lib/es6/Stdlib_Option.mjs"; import * as Primitive_object from "@rescript/runtime/lib/es6/Primitive_object.mjs"; let eq = Primitive_object.equal; +let nan = NaN; + +let infinity = Number.POSITIVE_INFINITY; + let bign = Stdlib_Option.getOr(Stdlib_BigInt.fromFloat(Number.MAX_VALUE), 0n); let bign$1 = bign + bign; @@ -15,7 +18,7 @@ let bign$1 = bign + bign; Test.run([ [ "Stdlib_TestTests.res", - 6, + 8, 20, 32 ], @@ -25,7 +28,7 @@ Test.run([ Test.run([ [ "Stdlib_TestTests.res", - 7, + 9, 20, 37 ], @@ -35,27 +38,27 @@ Test.run([ Test.run([ [ "Stdlib_TestTests.res", - 8, + 10, 20, 31 ], "print NaN" -], Test.print(Number.NaN), eq, "NaN"); +], Test.print(nan), eq, "NaN"); Test.run([ [ "Stdlib_TestTests.res", - 9, + 11, 20, 36 ], "print infinity" -], Test.print(Pervasives.infinity), eq, "Infinity"); +], Test.print(infinity), eq, "Infinity"); Test.run([ [ "Stdlib_TestTests.res", - 10, + 12, 20, 29 ], @@ -65,7 +68,7 @@ Test.run([ Test.run([ [ "Stdlib_TestTests.res", - 11, + 13, 20, 31 ], @@ -75,7 +78,7 @@ Test.run([ Test.run([ [ "Stdlib_TestTests.res", - 12, + 14, 20, 33 ], @@ -85,7 +88,7 @@ Test.run([ Test.run([ [ "Stdlib_TestTests.res", - 13, + 15, 20, 34 ], @@ -95,7 +98,7 @@ Test.run([ Test.run([ [ "Stdlib_TestTests.res", - 14, + 16, 20, 32 ], @@ -105,7 +108,7 @@ Test.run([ Test.run([ [ "Stdlib_TestTests.res", - 15, + 17, 20, 34 ], @@ -117,7 +120,7 @@ Test.run([ Test.run([ [ "Stdlib_TestTests.res", - 16, + 18, 20, 33 ], @@ -131,7 +134,7 @@ Test.run([ Test.run([ [ "Stdlib_TestTests.res", - 17, + 19, 20, 34 ], @@ -141,7 +144,7 @@ Test.run([ Test.run([ [ "Stdlib_TestTests.res", - 18, + 20, 20, 36 ], @@ -151,7 +154,7 @@ Test.run([ Test.run([ [ "Stdlib_TestTests.res", - 19, + 21, 20, 40 ], @@ -161,7 +164,7 @@ Test.run([ Test.run([ [ "Stdlib_TestTests.res", - 21, + 23, 13, 27 ], @@ -171,7 +174,7 @@ Test.run([ Test.run([ [ "Stdlib_TestTests.res", - 26, + 28, 20, 31 ], @@ -185,6 +188,8 @@ Test.run([ export { eq, + nan, + infinity, bign$1 as bign, } -/* bign Not a pure module */ +/* nan Not a pure module */ diff --git a/tests/tests/src/stdlib/Stdlib_TestTests.res b/tests/tests/src/stdlib/Stdlib_TestTests.res index 1bf71d566a..977583ccf8 100644 --- a/tests/tests/src/stdlib/Stdlib_TestTests.res +++ b/tests/tests/src/stdlib/Stdlib_TestTests.res @@ -1,4 +1,6 @@ let eq = (a, b) => a == b +let nan = Float.Constants.nan +let infinity = Float.Constants.positiveInfinity let bign = BigInt.fromFloat(Float.Constants.maxValue)->Option.getOr(0n) let bign = BigInt.add(bign, bign) diff --git a/tests/tests/src/stdlib/Test.mjs b/tests/tests/src/stdlib/Test.mjs index 9dafeeb30c..05e5a9c041 100644 --- a/tests/tests/src/stdlib/Test.mjs +++ b/tests/tests/src/stdlib/Test.mjs @@ -40,7 +40,7 @@ function run(loc, left, comparator, right) { }); let errorMessage = ` \u001b[31mTest Failure! - \u001b[36m` + file + `\u001b[0m:\u001b[2m` + String(line) + ` + \u001b[36m` + file + `\u001b[0m:\u001b[2m` + line.toString() + ` ` + codeFrame + ` \u001b[39mLeft: \u001b[31m` + left$1 + ` \u001b[39mRight: \u001b[31m` + right$1 + `\u001b[0m diff --git a/tests/tests/src/stdlib/Test.res b/tests/tests/src/stdlib/Test.res index cd94b2c6cd..6bd7c8659f 100644 --- a/tests/tests/src/stdlib/Test.res +++ b/tests/tests/src/stdlib/Test.res @@ -30,7 +30,7 @@ let run = (loc, left, comparator, right) => { ) let errorMessage = ` \u001b[31mTest Failure! - \u001b[36m${file}\u001b[0m:\u001b[2m${string_of_int(line)} + \u001b[36m${file}\u001b[0m:\u001b[2m${Int.toString(line)} ${codeFrame} \u001b[39mLeft: \u001b[31m${left} \u001b[39mRight: \u001b[31m${right}\u001b[0m diff --git a/tests/tests/src/test_char.mjs b/tests/tests/src/test_char.mjs index 24448c4a27..51f56fa656 100644 --- a/tests/tests/src/test_char.mjs +++ b/tests/tests/src/test_char.mjs @@ -2,8 +2,9 @@ function caml_is_printable(c) { - if (c > 31) { - return c < 127; + let code = c.charCodeAt(0); + if (code > 31) { + return code < 127; } else { return false; } diff --git a/tests/tests/src/test_char.res b/tests/tests/src/test_char.res index 22d0122223..be0369be39 100644 --- a/tests/tests/src/test_char.res +++ b/tests/tests/src/test_char.res @@ -1,4 +1,4 @@ let caml_is_printable = c => { - let code = Char.code(c) + let code = String.charCodeAtUnsafe(c, 0) code > 31 && code < 127 } diff --git a/tests/tests/src/test_const_elim.res b/tests/tests/src/test_const_elim.res index ff7f399701..c2db0576e1 100644 --- a/tests/tests/src/test_const_elim.res +++ b/tests/tests/src/test_const_elim.res @@ -3,7 +3,7 @@ include ( let f = x => { let u = (1, 2) let v = (x, x) - (fst(u), snd(v)) + (Pair.first(u), Pair.second(v)) } }: {} ) diff --git a/tests/tests/src/test_fib.res b/tests/tests/src/test_fib.res index 1311d611ee..f3702806e8 100644 --- a/tests/tests/src/test_fib.res +++ b/tests/tests/src/test_fib.res @@ -56,7 +56,7 @@ let f = x => { let sum = ref(0) while v.contents > 0 { sum := sum.contents + v.contents - decr(v) + Int.Ref.decrement(v) } sum.contents } diff --git a/tests/tests/src/test_for_loop.res b/tests/tests/src/test_for_loop.res index a30681c48f..ad548ae2cd 100644 --- a/tests/tests/src/test_for_loop.res +++ b/tests/tests/src/test_for_loop.res @@ -52,16 +52,16 @@ let for_6 = (x, u) => { let arr = x->Array.map(_ => _ => ()) let v4 = ref(0) let v5 = ref(0) - incr(v4) + Int.Ref.increment(v4) for j in 0 to 1 { - incr(v5) + Int.Ref.increment(v5) let v2 = ref(0) let v3 = u for i in 0 to Array.length(x) { let _j = i * 2 let k = 2 * u * u let h = 2 * v5.contents - incr(v2) + Int.Ref.increment(v2) arr[i] = _ => v := v.contents + k + v2.contents + v3 + v4.contents + v5.contents + h } } diff --git a/tests/tests/src/test_incr_ref.res b/tests/tests/src/test_incr_ref.res index 938e94eff1..8605ac49a1 100644 --- a/tests/tests/src/test_incr_ref.res +++ b/tests/tests/src/test_incr_ref.res @@ -1,7 +1,7 @@ include ( { let u = ref(0) - let v = incr(u) + let v = Int.Ref.increment(u) }: { let v: unit } diff --git a/tests/tests/src/test_list.mjs b/tests/tests/src/test_list.mjs index f0ebcad40e..5410ffd374 100644 --- a/tests/tests/src/test_list.mjs +++ b/tests/tests/src/test_list.mjs @@ -79,7 +79,7 @@ function rev(l) { function flatten(x) { if (x !== 0) { - return Pervasives.$at(x.hd, flatten(x.tl)); + return Stdlib_List.concat(x.hd, flatten(x.tl)); } else { return /* [] */0; } @@ -1409,7 +1409,7 @@ function isEmpty2(x) { let u = Stdlib_List.length; -let append = Pervasives.$at; +let append = Stdlib_List.concat; let concat = flatten; diff --git a/tests/tests/src/test_list.res b/tests/tests/src/test_list.res index 47adfae7cc..3a06990134 100644 --- a/tests/tests/src/test_list.res +++ b/tests/tests/src/test_list.res @@ -51,7 +51,7 @@ let nth = (l, n) => nth_aux(l, n) } -let append = \"@" +let append = List.concat let rec rev_append = (l1, l2) => switch l1 { @@ -64,7 +64,7 @@ let rev = l => rev_append(l, list{}) let rec flatten = x => switch x { | list{} => list{} - | list{l, ...r} => \"@"(l, flatten(r)) + | list{l, ...r} => List.concat(l, flatten(r)) } let concat = flatten @@ -394,7 +394,7 @@ let stable_sort = (cmp, l) => { list{x3, x2, x1} } | (n, l) => - let n1 = asr(n, 1) + let n1 = Int.shiftRight(n, 1) let n2 = n - n1 let l2 = chop(n1, l) let s1 = rev_sort(n1, l) @@ -426,7 +426,7 @@ let stable_sort = (cmp, l) => { list{x3, x2, x1} } | (n, l) => - let n1 = asr(n, 1) + let n1 = Int.shiftRight(n, 1) let n2 = n - n1 let l2 = chop(n1, l) let s1 = sort(n1, l) @@ -534,7 +534,7 @@ let sort_uniq = (cmp, l) => { } } | (n, l) => - let n1 = asr(n, 1) + let n1 = Int.shiftRight(n, 1) let n2 = n - n1 let l2 = chop(n1, l) let s1 = rev_sort(n1, l) @@ -597,7 +597,7 @@ let sort_uniq = (cmp, l) => { } } | (n, l) => - let n1 = asr(n, 1) + let n1 = Int.shiftRight(n, 1) let n2 = n - n1 let l2 = chop(n1, l) let s1 = sort(n1, l) diff --git a/tests/tests/src/test_per.res b/tests/tests/src/test_per.res index b53ba0515d..c66bf84a4c 100644 --- a/tests/tests/src/test_per.res +++ b/tests/tests/src/test_per.res @@ -81,13 +81,13 @@ external land: (int, int) => int = "%andint" external lor: (int, int) => int = "%orint" external lxor: (int, int) => int = "%xorint" -let lnot = x => lxor(x, -1) +let lnot = x => Int.bitwiseXor(x, -1) external lsl: (int, int) => int = "%lslint" external lsr: (int, int) => int = "%lsrint" external asr: (int, int) => int = "%asrint" -let max_int = lsr(-1, 1) +let max_int = Int.shiftRightUnsigned(-1, 1) let min_int = max_int + 1 /* Floating-point operations */ diff --git a/tests/tests/src/test_pervasive.mjs b/tests/tests/src/test_pervasive.mjs index 0014f94443..6ed0caf27c 100644 --- a/tests/tests/src/test_pervasive.mjs +++ b/tests/tests/src/test_pervasive.mjs @@ -65,22 +65,7 @@ let Pervasives$1 = { sort: Stdlib_List.sort, failwith: Pervasives.failwith, invalid_arg: Pervasives.invalid_arg, - Exit: Pervasives.Exit, - abs: Pervasives.abs, - max_int: Pervasives.max_int, - min_int: Pervasives.min_int, - infinity: Pervasives.infinity, - neg_infinity: Pervasives.neg_infinity, - max_float: Pervasives.max_float, - min_float: Pervasives.min_float, - epsilon_float: Pervasives.epsilon_float, - classify_float: Pervasives.classify_float, - char_of_int: Pervasives.char_of_int, - string_of_bool: Pervasives.string_of_bool, - bool_of_string: Pervasives.bool_of_string, - bool_of_string_opt: Pervasives.bool_of_string_opt, - int_of_string_opt: Pervasives.int_of_string_opt, - $at: Pervasives.$at + Exit: Pervasives.Exit }; function a0(prim) { @@ -159,7 +144,7 @@ function a18(prim0, prim1) { return prim0 ** prim1 | 0; } -let f = Pervasives.$at; +let f = Stdlib_List.concat; export { Pervasives$1 as Pervasives, diff --git a/tests/tests/src/test_pervasive.res b/tests/tests/src/test_pervasive.res index 7463c6d426..eefa2ae4b6 100644 --- a/tests/tests/src/test_pervasive.res +++ b/tests/tests/src/test_pervasive.res @@ -3,26 +3,26 @@ module Pervasives = { include Pervasives } -let f = Pervasives.\"@" +let f = List.concat -let a0 = abs_float -let a1 = acos -let a2 = tan -let a3 = tanh -let a4 = asin -let a5 = atan2 -let a6 = atan -let a7 = ceil -let a8 = cos -let a9 = cosh -let a10 = exp -let a11 = sin -let a12 = sinh -let a13 = sqrt -let a14 = floor -let a15 = log -let a16 = log10 -let a17 = log1p +let a0 = Math.abs +let a1 = Math.acos +let a2 = Math.tan +let a3 = Math.tanh +let a4 = Math.asin +let a5 = Math.atan2 +let a6 = Math.atan +let a7 = Math.ceil +let a8 = Math.cos +let a9 = Math.cosh +let a10 = Math.exp +let a11 = Math.sin +let a12 = Math.sinh +let a13 = Math.sqrt +let a14 = Math.floor +let a15 = Math.log +let a16 = Math.log10 +let a17 = Math.log1p let a18 = \"**" /* local variables: */ /* compile-command: "ocamlc -dlambda -c test_pervasive.ml" */ diff --git a/tests/tests/src/test_pervasives3.mjs b/tests/tests/src/test_pervasives3.mjs index 2170f649e5..8eec9e8367 100644 --- a/tests/tests/src/test_pervasives3.mjs +++ b/tests/tests/src/test_pervasives3.mjs @@ -7,21 +7,6 @@ let Pervasives$1 = { failwith: Pervasives.failwith, invalid_arg: Pervasives.invalid_arg, Exit: Pervasives.Exit, - abs: Pervasives.abs, - max_int: Pervasives.max_int, - min_int: Pervasives.min_int, - infinity: Pervasives.infinity, - neg_infinity: Pervasives.neg_infinity, - max_float: Pervasives.max_float, - min_float: Pervasives.min_float, - epsilon_float: Pervasives.epsilon_float, - classify_float: Pervasives.classify_float, - char_of_int: Pervasives.char_of_int, - string_of_bool: Pervasives.string_of_bool, - bool_of_string: Pervasives.bool_of_string, - bool_of_string_opt: Pervasives.bool_of_string_opt, - int_of_string_opt: Pervasives.int_of_string_opt, - $at: Pervasives.$at, length: Stdlib_List.length, size: Stdlib_List.size, head: Stdlib_List.head, @@ -84,7 +69,7 @@ let Pervasives$1 = { sort: Stdlib_List.sort }; -let v = Pervasives.$at; +let v = Stdlib_List.concat; export { Pervasives$1 as Pervasives, diff --git a/tests/tests/src/test_pervasives3.res b/tests/tests/src/test_pervasives3.res index d9118e4a6c..fc83cc54fc 100644 --- a/tests/tests/src/test_pervasives3.res +++ b/tests/tests/src/test_pervasives3.res @@ -2,4 +2,4 @@ module Pervasives = { include Pervasives include List } -let v = Pervasives.\"@" +let v = List.concat diff --git a/tests/tests/src/test_primitive.mjs b/tests/tests/src/test_primitive.mjs index 8c2283ac57..5679fcfc89 100644 --- a/tests/tests/src/test_primitive.mjs +++ b/tests/tests/src/test_primitive.mjs @@ -28,8 +28,6 @@ function a6(prim) { ]; } -let test_float = 3; - let test_abs = Math.abs(3.0); let v = [ @@ -88,6 +86,8 @@ let a2 = 27; let a3 = "Test_primitive"; +let test_float = 3; + let xx = [ 0, 0 diff --git a/tests/tests/src/test_primitive.res b/tests/tests/src/test_primitive.res index 0b4b4c9c20..8c2d8dc3a6 100644 --- a/tests/tests/src/test_primitive.res +++ b/tests/tests/src/test_primitive.res @@ -29,8 +29,8 @@ let a3 = __MODULE__ let a4 = __LOC_OF__ let a5 = __LINE_OF__ let a6 = __POS_OF__ -let test_float = float(3) -let test_abs = abs_float(3.0) +let test_float = Int.toFloat(3) +let test_abs = Math.abs(3.0) /* Clflags.dump_lambda:=true */ let v = [1.0, 2.0] let xxx = "a" diff --git a/tests/tests/src/test_seq.mjs b/tests/tests/src/test_seq.mjs index 6fbb76012d..740f20bcd3 100644 --- a/tests/tests/src/test_seq.mjs +++ b/tests/tests/src/test_seq.mjs @@ -1,6 +1,6 @@ // Generated by ReScript, PLEASE EDIT WITH CARE -import * as Pervasives from "@rescript/runtime/lib/es6/Pervasives.mjs"; +import * as Stdlib_List from "@rescript/runtime/lib/es6/Stdlib_List.mjs"; import * as Primitive_object from "@rescript/runtime/lib/es6/Primitive_object.mjs"; import * as Primitive_exceptions from "@rescript/runtime/lib/es6/Primitive_exceptions.mjs"; @@ -93,7 +93,7 @@ function add_help(speclist) { throw exn$1; } } - return Pervasives.$at(speclist, Pervasives.$at(add1, add2)); + return Stdlib_List.concat(speclist, Stdlib_List.concat(add1, add2)); } export { diff --git a/tests/tests/src/test_seq.res b/tests/tests/src/test_seq.res index fd9bead672..1059cc2718 100644 --- a/tests/tests/src/test_seq.res +++ b/tests/tests/src/test_seq.res @@ -89,7 +89,7 @@ let add_help = speclist => { | Not_found => list{("--help", Unit(help_action), " Display this list of options")} } - \"@"(speclist, \"@"(add1, add2)) + List.concat(speclist, List.concat(add1, add2)) } /* FIXME- not compatible with strict mode */ diff --git a/tests/tests/src/test_set.res b/tests/tests/src/test_set.res index 852f1f40e9..39f5942a45 100644 --- a/tests/tests/src/test_set.res +++ b/tests/tests/src/test_set.res @@ -501,7 +501,7 @@ module Make = (Ord: OrderedType) => { } } - fst(sub(List.length(l), l)) + Pair.first(sub(List.length(l), l)) } let of_list = l => diff --git a/tests/tests/src/test_side_effect_functor.res b/tests/tests/src/test_side_effect_functor.res index efa395b89c..c4db841757 100644 --- a/tests/tests/src/test_side_effect_functor.res +++ b/tests/tests/src/test_side_effect_functor.res @@ -3,7 +3,7 @@ include ( module M = () => { let v = ref(0) { - incr(v) + Int.Ref.increment(v) v.contents->Int.toString->Console.log } let u = 3 diff --git a/tests/tests/src/test_simple_ref.res b/tests/tests/src/test_simple_ref.res index c0b11c4c06..40682cb8eb 100644 --- a/tests/tests/src/test_simple_ref.res +++ b/tests/tests/src/test_simple_ref.res @@ -3,7 +3,7 @@ include ( let v = ref(0) let gen = () => { - incr(v) + Int.Ref.increment(v) v.contents } let h = ref(0) diff --git a/tests/tests/src/test_u.res b/tests/tests/src/test_u.res index 50e01af9c8..d7279ea888 100644 --- a/tests/tests/src/test_u.res +++ b/tests/tests/src/test_u.res @@ -3,7 +3,7 @@ let f = x => { let sum = ref(0) while v.contents > 0 { sum := sum.contents + v.contents - decr(v) + Int.Ref.decrement(v) } sum.contents } diff --git a/tests/tests/src/test_while_closure.res b/tests/tests/src/test_while_closure.res index 0d31a9f0ae..f76afc4195 100644 --- a/tests/tests/src/test_while_closure.res +++ b/tests/tests/src/test_while_closure.res @@ -44,7 +44,7 @@ let f = () => { while n.contents < count { let j = n.contents arr[j] = _ => v := v.contents + j - incr(n) + Int.Ref.increment(n) } } diff --git a/tests/tests/src/test_while_side_effect.res b/tests/tests/src/test_while_side_effect.res index 0b1e7717c1..38f1613165 100644 --- a/tests/tests/src/test_while_side_effect.res +++ b/tests/tests/src/test_while_side_effect.res @@ -2,7 +2,7 @@ let v = ref(0) while { v.contents->Int.toString->Console.log - incr(v) + Int.Ref.increment(v) v.contents < 10 } { ignore() @@ -18,8 +18,8 @@ let x = ref(3) while { let y = ref(3) x.contents->Int.toString->Console.log - incr(y) - incr(x) + Int.Ref.increment(y) + Int.Ref.increment(x) fib(x.contents) + fib(x.contents) < 20 } { 3->Int.toString->Console.log diff --git a/tests/tests/src/to_string_test.mjs b/tests/tests/src/to_string_test.mjs index b1242e6da2..47251abf3c 100644 --- a/tests/tests/src/to_string_test.mjs +++ b/tests/tests/src/to_string_test.mjs @@ -1,7 +1,6 @@ // Generated by ReScript, PLEASE EDIT WITH CARE import * as Mocha from "mocha"; -import * as Pervasives from "@rescript/runtime/lib/es6/Pervasives.mjs"; import * as Test_utils from "./test_utils.mjs"; function ff(v) { @@ -13,8 +12,8 @@ function f(v) { } Mocha.describe("To_string_test", () => { - Mocha.test("infinity to string", () => Test_utils.eq("File \"to_string_test.res\", line 8, characters 38-45", Pervasives.infinity.toString(), "Infinity")); - Mocha.test("neg_infinity to string", () => Test_utils.eq("File \"to_string_test.res\", line 9, characters 42-49", Pervasives.neg_infinity.toString(), "-Infinity")); + Mocha.test("infinity to string", () => Test_utils.eq("File \"to_string_test.res\", line 8, characters 38-45", Number.POSITIVE_INFINITY.toString(), "Infinity")); + Mocha.test("neg_infinity to string", () => Test_utils.eq("File \"to_string_test.res\", line 10, characters 7-14", Number.NEGATIVE_INFINITY.toString(), "-Infinity")); }); export { diff --git a/tests/tests/src/to_string_test.res b/tests/tests/src/to_string_test.res index 0b9df5278f..fa4fd0b43a 100644 --- a/tests/tests/src/to_string_test.res +++ b/tests/tests/src/to_string_test.res @@ -5,6 +5,8 @@ let ff = v => Float.toString(v) let f = v => Int.toString(v) describe(__MODULE__, () => { - test("infinity to string", () => eq(__LOC__, ff(infinity), "Infinity")) - test("neg_infinity to string", () => eq(__LOC__, ff(neg_infinity), "-Infinity")) + test("infinity to string", () => eq(__LOC__, ff(Float.Constants.positiveInfinity), "Infinity")) + test("neg_infinity to string", () => + eq(__LOC__, ff(Float.Constants.negativeInfinity), "-Infinity") + ) }) diff --git a/tests/tests/src/topsort_test.mjs b/tests/tests/src/topsort_test.mjs index d75ea6233a..6bb0c9b498 100644 --- a/tests/tests/src/topsort_test.mjs +++ b/tests/tests/src/topsort_test.mjs @@ -1,6 +1,5 @@ // Generated by ReScript, PLEASE EDIT WITH CARE -import * as Pervasives from "@rescript/runtime/lib/es6/Pervasives.mjs"; import * as Stdlib_List from "@rescript/runtime/lib/es6/Stdlib_List.mjs"; import * as Primitive_object from "@rescript/runtime/lib/es6/Primitive_object.mjs"; import * as Primitive_exceptions from "@rescript/runtime/lib/es6/Primitive_exceptions.mjs"; @@ -86,7 +85,7 @@ function dfs1(_nodes, graph, _visited) { hd: x, tl: visited }; - _nodes = Pervasives.$at(nexts(x, graph), xs); + _nodes = Stdlib_List.concat(nexts(x, graph), xs); continue; }; } diff --git a/tests/tests/src/topsort_test.res b/tests/tests/src/topsort_test.res index a7bd936d14..14a822caf9 100644 --- a/tests/tests/src/topsort_test.res +++ b/tests/tests/src/topsort_test.res @@ -28,7 +28,7 @@ let rec dfs1 = (nodes, graph, visited) => dfs1(xs, graph, visited) } else { Console.log(x) - dfs1(\"@"(nexts(x, graph), xs), graph, list{x, ...visited}) + dfs1(List.concat(nexts(x, graph), xs), graph, list{x, ...visited}) } } diff --git a/tests/tests/src/tuple_alloc.mjs b/tests/tests/src/tuple_alloc.mjs index 8709386cca..49361183d7 100644 --- a/tests/tests/src/tuple_alloc.mjs +++ b/tests/tests/src/tuple_alloc.mjs @@ -22,7 +22,7 @@ function reset2() { } function incr2() { - v.contents = v.contents + 1 | 0; + vv.contents = vv.contents + 1 | 0; } function f(a, b, d, e) { diff --git a/tests/tests/src/tuple_alloc.res b/tests/tests/src/tuple_alloc.res index 4ae3738961..50287bdef9 100644 --- a/tests/tests/src/tuple_alloc.res +++ b/tests/tests/src/tuple_alloc.res @@ -1,10 +1,10 @@ let v = ref(0) -let (reset, incr) = (_ => v := 0, _ => incr(v)) +let (reset, incr) = (_ => v := 0, _ => Int.Ref.increment(v)) let (reset2, incr2) = { let vv = ref(0) - (() => vv := 0, () => incr(vv)) + (() => vv := 0, () => Int.Ref.increment(vv)) } let f = (a, b, d, e) => { diff --git a/tests/tests/src/unboxed_attribute_test.res b/tests/tests/src/unboxed_attribute_test.res index ee7c0f69be..6d564b5655 100644 --- a/tests/tests/src/unboxed_attribute_test.res +++ b/tests/tests/src/unboxed_attribute_test.res @@ -16,8 +16,8 @@ let get = (A(x)) => x let x = A("foo") eq( __LOC__, - Obj.repr(x), - Obj.repr( + Obj.magic(x), + Obj.magic( switch x { | A(s) => s }, @@ -30,7 +30,7 @@ let get = (A(x)) => x { let x = {f: "foo"} - eq(__LOC__, Obj.repr(x), Obj.repr(x.f)) + eq(__LOC__, Obj.magic(x), Obj.magic(x.f)) } /* For inline records */ @@ -40,8 +40,8 @@ let get = (A(x)) => x let x = B({g: "foo"}) eq( __LOC__, - Obj.repr(x), - Obj.repr( + Obj.magic(x), + Obj.magic( switch x { | B({g}) => g }, diff --git a/tests/tests/src/update_record_test.mjs b/tests/tests/src/update_record_test.mjs index b40b6f5afa..5e327d7019 100644 --- a/tests/tests/src/update_record_test.mjs +++ b/tests/tests/src/update_record_test.mjs @@ -4,14 +4,19 @@ import * as Mocha from "mocha"; import * as Test_utils from "./test_utils.mjs"; function f(x) { - let y = {...x}; + let y_a0 = x.a0; + let y_a1 = x.a1; + let y_a2 = x.a2; + let y_a3 = x.a3; + let y_a4 = x.a4; + let y_a5 = x.a5; return { a0: 1, - a1: y.a1, - a2: y.a2, - a3: y.a3, - a4: y.a4, - a5: y.a5 + a1: y_a1, + a2: y_a2, + a3: y_a3, + a4: y_a4, + a5: y_a5 }; } diff --git a/tests/tests/src/update_record_test.res b/tests/tests/src/update_record_test.res index 15d7cde393..40c1e8f9ff 100644 --- a/tests/tests/src/update_record_test.res +++ b/tests/tests/src/update_record_test.res @@ -15,7 +15,7 @@ type t = { type invalidRecord = {invalid_js_id': int, x: int} let f = (x: t) => { - let y: t = Obj.magic(Obj.dup(Obj.repr(x))) + let y: t = {...x, a0: x.a0} {...y, a0: 1} } diff --git a/tests/tools_tests/src/migrate/StdlibMigration_StdlibArray.res b/tests/tools_tests/src/migrate/StdlibMigration_StdlibArray.res index c54b9d4781..a280f164fc 100644 --- a/tests/tools_tests/src/migrate/StdlibMigration_StdlibArray.res +++ b/tests/tools_tests/src/migrate/StdlibMigration_StdlibArray.res @@ -17,4 +17,4 @@ let f1 = [1, 2, 3, 4]->Array.sliceToEnd(~start=2) let g1 = [1, 2]->Array.lastIndexOfFrom(1, 1) -let h1 = [1, 2]->Array.unsafe_get(1) +let h1 = [1, 2]->Array.getUnsafe(1)