mirror of
https://github.com/meteor/meteor.git
synced 2026-05-02 03:01:46 -04:00
The previous algorithm had the problem that if you had builds
A = browser+os.linux.x86_64
B = browser+os.osx.x86_64
available and came in looking for "something that satisfies 'browser'
and 'os.osx.x86_64'", Meteor would happily say:
"Neato-keen! 'A' satisfies 'browser'. And 'B' satisfies
'os.osx.x86_64'! Hey, that's all I needed! Let's download
both 'A' and 'B'! Hooray!"
when choosing just 'B' would have been good enough.
34 lines
688 B
JavaScript
34 lines
688 B
JavaScript
var selftest = require('../selftest.js');
|
|
var utils = require('../utils.js');
|
|
|
|
selftest.define('subset generator', function () {
|
|
var out = [];
|
|
utils.generateSubsetsOfIncreasingSize(['a', 'b', 'c'], function (x) {
|
|
out.push(x);
|
|
});
|
|
selftest.expectEqual(out, [
|
|
[],
|
|
[ 'a' ],
|
|
[ 'b' ],
|
|
[ 'c' ],
|
|
[ 'a', 'b' ],
|
|
[ 'a', 'c' ],
|
|
[ 'b', 'c' ],
|
|
[ 'a', 'b', 'c' ]
|
|
]);
|
|
out = [];
|
|
utils.generateSubsetsOfIncreasingSize(['a', 'b', 'c'], function (x) {
|
|
out.push(x);
|
|
if (x[1] === 'c')
|
|
return true; // stop iterating
|
|
});
|
|
selftest.expectEqual(out, [
|
|
[],
|
|
[ 'a' ],
|
|
[ 'b' ],
|
|
[ 'c' ],
|
|
[ 'a', 'b' ],
|
|
[ 'a', 'c' ]
|
|
]);
|
|
});
|