You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
metatests.test('unpredictable search result',test=>{constdata=[{name: 'Bob',age: 34},{name: 'Bob',age: 45}];constexpected=34;// actual search result - 45constpredicate=msec=>{letdelay=true;return(item,callback)=>{if(delay){delay=false;setTimeout(()=>callback(null,item.name==='Bob'),msec);return;}process.nextTick(()=>callback(null,item.name==='Bob'));};};metasync.find(data,predicate(200),(_,result)=>{test.strictSame(result.age,expected);test.end();});});
Copy & past above snippet to the test/array.find.js
Enter to the terminal npx metatests test/array.find.js
In my opinion, method find should have sequential (series) semantics. Otherwise, we will obtain unpredictable search result depends on non deterministic delay of non-blocking operation
The text was updated successfully, but these errors were encountered:
test/array.find.js
npx metatests test/array.find.js
In my opinion, method
find
should havesequential (series)
semantics. Otherwise, we will obtain unpredictable search result depends on non deterministic delay of non-blocking operationThe text was updated successfully, but these errors were encountered: