Spaces:
Running
Running
File size: 1,024 Bytes
87b3b3a |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
describe("Scheduler", function() {
var A50 = {getSpeed: function() { return 50; }};
var A100a = {getSpeed: function() { return 100; }};
var A100b = {getSpeed: function() { return 100; }};
var A200 = {getSpeed: function() { return 200; }};
var s = new ROT.Scheduler();
beforeEach(function() {
s.clear();
this.addMatchers({
toSchedule: function(expected) {
for (var i=0;i<Math.max(expected.length, this.actual.length);i++) {
if (this.actual[i] !== expected[i]) { return false; }
}
return true;
}
});
});
it("should schedule same speed evenly", function() {
s.add(A100a);
s.add(A100b);
var result = [];
for (var i=0;i<4;i++) { result.push(s.next()); }
expect(result).toSchedule([A100a, A100b, A100a, A100b]);
});
it("should schedule different speeds properly", function() {
s.add(A50);
s.add(A100a);
s.add(A200);
var result = [];
for (var i=0;i<7;i++) { result.push(s.next()); }
expect(result).toSchedule([A200, A200, A100a, A200, A50, A200, A100a]);
});
});
|