From 1426af4f6b11c627f37f32c942ff7dac1af10303 Mon Sep 17 00:00:00 2001 From: Laurent Bossavit Date: Thu, 7 Sep 2017 23:26:31 +0200 Subject: [PATCH] =?UTF-8?q?:gear:=20Fournit=20un=20op=C3=A9rateur=20d'in?= =?UTF-8?q?=C3=A9galit=C3=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- source/engine/grammar.ne | 2 +- source/engine/traverse.js | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/source/engine/grammar.ne b/source/engine/grammar.ne index 103c04153..a3bb326b8 100644 --- a/source/engine/grammar.ne +++ b/source/engine/grammar.ne @@ -18,7 +18,7 @@ Comparison -> Comparable _ ComparisonOperator _ Comparable {% d => ({ Comparable -> (int | CalcExpression | Variable | Constant) {% d => d[0][0] %} -ComparisonOperator -> ">" | "<" | ">=" | "<=" | "=" +ComparisonOperator -> ">" | "<" | ">=" | "<=" | "=" | "!=" NegatedVariable -> "≠" _ Variable {% d => ({category: 'negatedVariable', variable: d[2] }) %} diff --git a/source/engine/traverse.js b/source/engine/traverse.js index 563ec80e0..709ab1f43 100644 --- a/source/engine/traverse.js +++ b/source/engine/traverse.js @@ -201,12 +201,13 @@ let treat = (rules, rule) => rawNode => { '<=': 'lte', '>': 'gt', '>=': 'gte', - '=': 'equals' + '=': 'equals', + '!=': 'equals' }[node.operator], explanation = R.map(R.curry(evaluateNode)(situation,parsedRules),node.explanation), value1 = explanation[0].nodeValue, value2 = explanation[1].nodeValue, - operatorFunction = R[operatorFunctionName], + operatorFunction = operatorFunctionName == "!=" ? (a => b => !R.equals(a,b)) : R[operatorFunctionName], nodeValue = value1 == null || value2 == null ? null : operatorFunction(value1, value2)