Пример #1
0
exports.test_rules_current_guard_can_disqualify = function (tester) {
    console.log('disqualification test starting');
    var maker = new MockMaker(tester);
    var to_test = new Rules();
    var first_guard = maker.guard({
	expect_start: true,
	expect_get: true, answer: false
    });
    var second_guard = maker.guard({
	expect_start: true,
	expect_get: true, answer: true
    });
    var second_action = maker.command({
	parent: to_test
    });
    var third_guard = maker.guard({
	expect_start: true,
	expect_get: true, answer: true
    });
    to_test.add(first_guard, maker.command({}));
    to_test.add(second_guard, second_action);
    to_test.add(third_guard, maker.command({
	parent: to_test,
	expect_handle: true, device: 't_device'
    }));
    tester.expect(12);
    to_test.start(maker.handler({
	expect_done: true, plan: to_test
    }));
    second_guard.answer = false;
    to_test.signal_changed();
    second_action.expect_handle = true;
    to_test.handle('t_device');
    tester.done();
};
Пример #2
0
exports.test_rules_earlier_rules_can_preempt = function (tester) {
    console.log('preemption test starting');
    var maker = new MockMaker(tester);
    var to_test = new Rules();
    var first_guard = maker.guard({
	expect_start: true,
	expect_get: true, answer: false
    });
    to_test.add(first_guard, maker.command({
	parent: to_test
    }));
    to_test.add(maker.guard({
	expect_start: true,
	expect_get: true, answer: true,
	expect_stop: true
    }), maker.command({
	parent: to_test,
	expect_stop: true
    }));
    tester.expect(9);
    to_test.start(maker.handler({}));
    first_guard.answer = true;
    to_test.signal_changed();
    tester.done();
};
Пример #3
0
exports.test_rules_delegates_signal_if_guard_is_true = function (tester) {
    var maker = new MockMaker(tester);
    var to_test = new Rules();
    to_test.add(maker.guard({
	expect_get: true, answer: true,
	expect_start: true
    }), maker.command({
	expect_start: true, parent: to_test,
	expect_signal: true
    }));
    tester.expect(5);
    to_test.start(maker.handler({}));
    to_test.signal_changed();
    tester.done();
};