public function testEvaluator()
 {
     $booleanExpressions = array("1" => true, "0" => false, "" => false, "1 == 1" => true, "0 == 1" => false, "1 && 0" => false, "1 && 1" => true, "1 || 0" => true, "0 || 0" => false);
     foreach ($booleanExpressions as $expr => $expected) {
         $this->assertEquals($expected, $this->em->ProcessBooleanExpression($expr), "Expression: '{$expr}'");
     }
 }
Esempio n. 2
0
 private function _ProcessGroupRelevance($groupSeq)
 {
     // These will be called in the order that questions are supposed to be asked
     if ($groupSeq == -1) {
         return;
         // invalid group, so ignore
     }
     $eqn = isset($this->gseq2info[$groupSeq]['grelevance']) ? $this->gseq2info[$groupSeq]['grelevance'] : 1;
     if (is_null($eqn) || trim($eqn == '') || trim($eqn) == '1') {
         $this->gRelInfo[$groupSeq] = array('gseq' => $groupSeq, 'eqn' => '', 'result' => 1, 'numJsVars' => 0, 'relevancejs' => '', 'relevanceVars' => '', 'prettyPrint' => '');
         return;
     }
     $stringToParse = htmlspecialchars_decode($eqn, ENT_QUOTES);
     $result = $this->em->ProcessBooleanExpression($stringToParse, $groupSeq);
     $hasErrors = $this->em->HasErrors();
     $jsVars = $this->em->GetJSVarsUsed();
     $relevanceVars = implode('|', $this->em->GetJSVarsUsed());
     $relevanceJS = $this->em->GetJavaScriptEquivalentOfExpression();
     $prettyPrint = $this->em->GetPrettyPrintString();
     $this->gRelInfo[$groupSeq] = array('gseq' => $groupSeq, 'eqn' => $stringToParse, 'result' => $result, 'numJsVars' => count($jsVars), 'relevancejs' => $relevanceJS, 'relevanceVars' => $relevanceVars, 'prettyPrint' => $prettyPrint, 'hasErrors' => $hasErrors);
     $_SESSION['relevanceStatus']['G' . $groupSeq] = $result;
 }