From 8c752c1398910348150dce0b98c1d3b37da89640 Mon Sep 17 00:00:00 2001 From: Cristiano Calcagno Date: Tue, 31 May 2022 15:53:18 +0200 Subject: [PATCH] tweak example --- example-async/src/AA.mjs | 33 +++++++++++++++++---------------- example-async/src/AA.res | 33 +++++++++++++++++---------------- 2 files changed, 34 insertions(+), 32 deletions(-) diff --git a/example-async/src/AA.mjs b/example-async/src/AA.mjs index eea176489..8d802c5a8 100644 --- a/example-async/src/AA.mjs +++ b/example-async/src/AA.mjs @@ -184,22 +184,23 @@ async function ff(url) { } async function testFetchMany() { - return Belt_List.forEach(await map({ - hd: "https://www.google.com", - tl: { - hd: "https://www.google.com", - tl: { - hd: "https://www.google.com", - tl: { - hd: "https://www.google.com", - tl: { - hd: "https://www.google.com", - tl: /* [] */0 - } - } - } - } - }, ff), (function (param) { + var fetchedItems = await map({ + hd: "https://www.google.com", + tl: { + hd: "https://www.google.com", + tl: { + hd: "https://www.google.com", + tl: { + hd: "https://www.google.com", + tl: { + hd: "https://www.google.com", + tl: /* [] */0 + } + } + } + } + }, ff); + return Belt_List.forEach(fetchedItems, (function (param) { console.log("Fetched", param[0], param[1]); })); } diff --git a/example-async/src/AA.res b/example-async/src/AA.res index fa52566af..a0ea0e2a8 100644 --- a/example-async/src/AA.res +++ b/example-async/src/AA.res @@ -75,10 +75,9 @@ let nestedPromise = // Test error handling in fetch module Fetch = { - @raises(JsError) + //@raises(JsError) let fetch = url => Fetch.fetch(url) - @raises([]) let status = response => Fetch.Response.status(response) } @@ -149,19 +148,21 @@ let fetchAndCount = { let testFetchMany = @async - (. ()) => - @await - AsyncList.map(. - list{ - "https://www.google.com", - "https://www.google.com", - "https://www.google.com", - "https://www.google.com", - "https://www.google.com", - }, - fetchAndCount, - )->Belt.List.forEach(((i, s)) => Js.log3("Fetched", i, s)) - + (. ()) => { + let fetchedItems = + @await + AsyncList.map(. + list{ + "https://www.google.com", + "https://www.google.com", + "https://www.google.com", + "https://www.google.com", + "https://www.google.com", + }, + fetchAndCount, + ) + fetchedItems->Belt.List.forEach(((i, s)) => Js.log3("Fetched", i, s)) + } testFetchMany->addTest // @@ -219,7 +220,7 @@ let rec runAllTests = (. n) => { if n >= 0 && n < Array.length(tests) { @await - tests[n](.) + (@doesNotRaise tests[n])(.) @await runAllTests(. n + 1)