Files
meteor/tools/tests/utils-tests.js
David Glasser f52c975de1 Less greedy algorithm for choosing builds
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.
2014-06-20 18:12:40 -07:00

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' ]
]);
});