strips
Version:
Basic AI planning with STRIPS and PDDL.
63 lines (62 loc) • 1.51 kB
JavaScript
/*
* use mocha to test me
* http://visionmedia.github.com/mocha/
*/
var assert, Combinatorics;
if (this['window'] !== this) {
assert = require("assert");
Combinatorics = require('../combinatorics.js').Combinatorics;
}
var is_deeply = function (a, e, m) {
return function () {
assert.equal(JSON.stringify(a), JSON.stringify(e), m)
}
};
describe('Combinatorics.cartesianProduct', function () {
var c = Combinatorics.cartesianProduct(
[ ], [0, 10, 20], [0, 100, 200]);
it(c, is_deeply(c.toArray(), [
[ ],
[ ],
[ ],
[ ],
[ ],
[ ],
[ ],
[ ],
[ ],
[ ],
[ ],
[ ],
[ ],
[ ],
[ ],
[ ],
[ ],
[ ],
[ ],
[ ],
[ ],
[ ],
[ ],
[ ],
[ ],
[ ],
[ ]
]));
it(0 + c, is_deeply(0 + c, c.toArray().length));
it(c.length, is_deeply(c.length, c.toArray().length));
it(c, is_deeply(c.filter(function (a) {
return a[0] === 0
}), [
[ ],
[ ],
[ ],
[ ],
[ ],
[ ],
[ ],
[ ],
[ ]
]));
});