🐛 Ne pas remonter de variables manquantes d'autres conditions si une est satisfaite

pull/21/head
Laurent Bossavit 2017-07-28 10:55:19 +02:00
parent 38a21ff91e
commit 34977eb234
2 changed files with 13 additions and 1 deletions

View File

@ -23,7 +23,7 @@ export let evaluateArray = (reducer, start, nullable = true) => (situationGate,
values = R.pluck("nodeValue",explanation),
nodeValue = (nullable && R.any(R.equals(null),values)) ? null : R.reduce(reducer, start, values)
let collectMissing = node => R.chain(collectNodeMissing,node.explanation)
let collectMissing = node => node.nodeValue == null ? R.chain(collectNodeMissing,node.explanation) : []
return rewriteNode(node,nodeValue,explanation,collectMissing)
}

View File

@ -65,6 +65,18 @@ describe('collectMissingVariables', function() {
expect(result).to.be.empty
});
it('should not report missing variables when "one of these" short-circuits', function() {
let rawRules = [
{nom: "startHere", formule: {somme: [2, "deux"]}, espace: "sum"},
{nom: "deux", formule: "trois", "non applicable si" : {"une de ces conditions": ["3 > 2", "trois"]}, espace: "sum"},
{nom: "trois", espace: "sum"}],
rules = rawRules.map(enrichRule),
situation = analyseTopDown(rules,"startHere")(stateSelector),
result = collectMissingVariables()(stateSelector,situation)
expect(result).to.be.empty
});
});
describe('buildNextSteps', function() {