| Server IP : 85.214.239.14 / Your IP : 216.73.216.27 Web Server : Apache/2.4.65 (Debian) System : Linux h2886529.stratoserver.net 4.9.0 #1 SMP Mon Sep 30 15:36:27 MSK 2024 x86_64 User : www-data ( 33) PHP Version : 8.2.29 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : ON | Pkexec : OFF Directory : /lib/node_modules/pm2/node_modules/lazy/test/ |
Upload File : |
var assert = require('assert');
var Lazy = require('..');
var expresso = expresso;
function range(i, j) {
var r = [];
for (;i<j;i++) r.push(i);
return r;
}
exports['foldr'] = function () {
var lazy = new Lazy;
var executed = 0;
lazy.foldr(function (x, acc) { return acc + x; }, 0, function (y) {
executed++;
assert.equal(y, 45);
})
range(0,10).forEach(function (x) {
lazy.emit('data', x);
});
lazy.emit('end');
assert.equal(executed, 1, 'foldr failed to execute');
}