Skip to content

Commit 9499875

Browse files
committed
Fix tests
1 parent 63ba4a3 commit 9499875

File tree

6 files changed

+20
-8
lines changed

6 files changed

+20
-8
lines changed

runtime/Stdlib_Iterator.res

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ external filter: (t<'a>, 'a => bool) => t<'a> = "filter"
2929
external find: (t<'a>, 'a => bool) => option<'a> = "find"
3030

3131
@send
32-
external flatMap: (t<'a>, 'a => array<'b>) => t<'b> = "flatMap"
32+
external flatMap: (t<'a>, 'a => t<'b>) => t<'b> = "flatMap"
3333

3434
@send
3535
external map: (t<'a>, 'a => 'b) => t<'b> = "map"

runtime/Stdlib_Iterator.resi

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -194,14 +194,15 @@ let map1 = Map.fromArray([("a", 1), ("b", 2), ("c", 3)])
194194
let map2 = Map.fromArray([("d", 4), ("e", 5), ("f", 6)])
195195

196196
let letters =
197-
[map1->Map.values, map2->Map.values]
198-
->Iterator.flatMap(m => Map.values(m))
197+
[map1, map2]
198+
->Array.values
199+
->Iterator.flatMap(m => Map.keys(m))
199200
->Array.fromIterator
200201
Console.log(letters) // ["a", "b", "c", "d", "e", "f"]
201202
```
202203
*/
203204
@send
204-
external flatMap: (t<'a>, 'a => array<'b>) => t<'b> = "flatMap"
205+
external flatMap: (t<'a>, 'a => t<'b>) => t<'b> = "flatMap"
205206

206207
/**
207208
`map(iterator, fn)` returns a new iterator helper object that yields elements of the iterator, each transformed by a mapping function.

tests/analysis_tests/tests/src/expected/Completion.res.txt

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -328,6 +328,12 @@ Path Array.
328328
"tags": [],
329329
"detail": "(array<'a>, int) => 'a",
330330
"documentation": {"kind": "markdown", "value": "\n`getUnsafe(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.getUnsafe` only when you are sure the `index` exists (i.e. when using for-loop).\n\n## Examples\n```rescript\nlet array = [1, 2, 3]\nfor index in 0 to array->Array.length - 1 {\n let value = array->Array.getUnsafe(index)\n Console.log(value)\n}\n```\n"}
331+
}, {
332+
"label": "entries",
333+
"kind": 12,
334+
"tags": [],
335+
"detail": "array<'a> => Iterator.t<'a>",
336+
"documentation": {"kind": "markdown", "value": "\n`entries(array)` returns a new array iterator object that contains the key/value pairs for each index in the array.\n\nSee [Array.prototype.entries](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/entries) on MDN.\n\n## Examples\n\n```rescript\nlet array = [5, 6, 7]\nlet iterator : Iterator.t<int> = array->Array.entries\nConsole.log(iterator->Iterator.next) // {done: false, value: [0,5]}\nConsole.log(iterator->Iterator.next) // {done: false, value: [1,6]}\n```\n"}
331337
}, {
332338
"label": "unshiftMany",
333339
"kind": 12,
@@ -376,6 +382,12 @@ Path Array.
376382
"tags": [],
377383
"detail": "'a => bool",
378384
"documentation": null
385+
}, {
386+
"label": "values",
387+
"kind": 12,
388+
"tags": [],
389+
"detail": "array<'a> => Iterator.t<'a>",
390+
"documentation": {"kind": "markdown", "value": "\n`values(array)` returns a new array iterator object that contains the values for each index in the array.\n\nSee [Array.prototype.values](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/values) on MDN.\n\n## Examples\n\n```rescript\nlet array = [5, 6, 7]\nlet iterator : Iterator.t<int> = array->Array.values\nConsole.log(iterator->Iterator.next) // {done: false, value: 5}\nConsole.log(iterator->Iterator.next) // {done: false, value: 6}\n```\n "}
379391
}, {
380392
"label": "indexOfOpt",
381393
"kind": 12,

tests/tests/src/core/Core_IteratorTests.mjs

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

33
import * as Test from "./Test.mjs";
4-
import * as Stdlib_Iterator from "rescript/lib/es6/Stdlib_Iterator.js";
54
import * as Primitive_object from "rescript/lib/es6/Primitive_object.js";
65
import * as Stdlib_AsyncIterator from "rescript/lib/es6/Stdlib_AsyncIterator.js";
76

@@ -17,7 +16,7 @@ let syncResult = {
1716
contents: undefined
1817
};
1918

20-
Stdlib_Iterator.forEach(iterator, v => {
19+
iterator.forEach(v => {
2120
if (v === "b") {
2221
syncResult.contents = "b";
2322
return;

tests/tests/src/core/Core_IteratorTests.res

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ let iterator: Iterator.t<string> = %raw(`
1111
let syncResult = ref(None)
1212

1313
iterator->Iterator.forEach(v => {
14-
if v === Some("b") {
14+
if v == "b" {
1515
syncResult.contents = Some("b")
1616
}
1717
})

tests/tests/src/core/Core_TempTests.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -249,7 +249,7 @@ let x = Symbol.for("Foo");
249249

250250
console.log(x);
251251

252-
let array$1 = Array.from("foo"[Symbol.iterator]());
252+
let array$1 = "foo"[Symbol.iterator]().toArray();
253253

254254
console.log(array$1);
255255

0 commit comments

Comments
 (0)