Tester la logique d'applicabilité

pull/14/head
Laurent Bossavit 2017-06-27 23:44:20 +02:00
parent 9a4afd4f68
commit a7d5f3dc55
1 changed files with 26 additions and 4 deletions

View File

@ -3,9 +3,9 @@ import {enrichRule} from '../source/engine/rules'
import {treatRuleRoot} from '../source/engine/traverse'
import {analyseSituation} from '../source/engine/traverse'
describe('treatRuleRoot', function() {
let stateSelector = (state, name) => null
let stateSelector = (state, name) => null
describe('treatRuleRoot', function() {
it('should directly return simple numerical values', function() {
let rule = {formule: 3269}
@ -16,8 +16,6 @@ describe('treatRuleRoot', function() {
describe('analyseSituation', function() {
let stateSelector = (state, name) => null
it('should directly return simple numerical values', function() {
let rule = {name: "startHere", formule: 3269}
let rules = [rule]
@ -30,6 +28,10 @@ describe('analyseSituation', function() {
expect(analyseSituation(rules,"startHere")(stateSelector)).to.have.property('nodeValue',101)
});
});
describe('analyseSituation on raw rules', function() {
it('should handle expressions referencing other rules', function() {
let rawRules = [
{nom: "startHere", formule: "3259 + dix", espace: "top"},
@ -38,4 +40,24 @@ describe('analyseSituation', function() {
expect(analyseSituation(rules,"startHere")(stateSelector)).to.have.property('nodeValue',3269)
});
it('should handle applicability conditions', function() {
let rawRules = [
{nom: "startHere", formule: "3259 + dix", espace: "top"},
{nom: "dix", formule: 10, espace: "top", "non applicable si" : "vrai"},
{nom: "vrai", formule: "2 > 1", espace: "top"}],
rules = rawRules.map(enrichRule)
expect(analyseSituation(rules,"startHere")(stateSelector)).to.have.property('nodeValue',3259)
});
/* TODO: make this pass
it('should handle applicability conditions', function() {
let rawRules = [
{nom: "startHere", formule: "3259 + dix", espace: "top"},
{nom: "dix", formule: 10, espace: "top", "non applicable si" : "vrai"},
{nom: "vrai", formule: "1", espace: "top"}],
rules = rawRules.map(enrichRule)
expect(analyseSituation(rules,"startHere")(stateSelector)).to.have.property('nodeValue',3259)
});
*/
});