⚙️ Retour explicite de true ou false pour les valeurs booléennes
oui | nonpull/281/head
parent
5d4a7d0d6e
commit
03d950cca7
|
@ -237,7 +237,6 @@ let evolveCond = (name, rule, rules) => value => {
|
|||
),
|
||||
nodeValue = explanation.nodeValue,
|
||||
missingVariables = explanation.missingVariables
|
||||
|
||||
return rewriteNode(node, nodeValue, explanation, missingVariables)
|
||||
}
|
||||
|
||||
|
|
|
@ -18,8 +18,10 @@ let evaluateBottomUp = situationGate => startingFragments => {
|
|||
])
|
||||
: situationGate(query) == expectedResult
|
||||
}
|
||||
|
||||
return rec(startingFragments)
|
||||
}
|
||||
let formatBooleanValue = { oui: true, non: false }
|
||||
|
||||
/* Evalue la valeur d'une variable
|
||||
en utilisant la fonction situationGate qui donne accès à la situation courante*/
|
||||
|
@ -27,12 +29,11 @@ export let evaluateVariable = (situationGate, variableName, rule) => {
|
|||
// test rec
|
||||
let value = situationGate(variableName)
|
||||
|
||||
return rule.format != null
|
||||
? value
|
||||
: !rule.formule
|
||||
? // c'est une variante, eg. motifs . classique . accroissement d'activité
|
||||
evaluateBottomUp(situationGate)(splitName(variableName))
|
||||
: rule.formule['une possibilité']
|
||||
? evaluateBottomUp(situationGate)(splitName(variableName))
|
||||
: value
|
||||
if (rule.format != null) return value
|
||||
//boolean variables don't have a format prop, it's the default
|
||||
if (formatBooleanValue[value] !== undefined) return formatBooleanValue[value]
|
||||
if (rule.formule && rule.formule['une possibilité'])
|
||||
return evaluateBottomUp(situationGate)(splitName(variableName))
|
||||
|
||||
return value
|
||||
}
|
||||
|
|
|
@ -29,4 +29,4 @@
|
|||
dégradation mineure: non
|
||||
dégradation majeure: non
|
||||
valeur attendue: 3000
|
||||
variables manquantes: []
|
||||
variables manquantes: []
|
||||
|
|
|
@ -18,9 +18,9 @@ describe('evaluateVariable', function() {
|
|||
expect(evaluateVariable(situationGate, 'condition', rule)).to.be.true
|
||||
})
|
||||
|
||||
it("should interpret rules without a formula as boolean-valued, with values other than 'oui' meaning false", function() {
|
||||
it("should interpret rules without a formula as boolean-valued, with 'non' meaning false", function() {
|
||||
let rule = {},
|
||||
state = { condition: 'nope' },
|
||||
state = { condition: 'non' },
|
||||
situationGate = name => state[name]
|
||||
|
||||
expect(evaluateVariable(situationGate, 'condition', rule)).to.be.false
|
||||
|
|
Loading…
Reference in New Issue