0] vs ['a'=>''] differs", count(array_recursive_diff(['a'=>0], ['a'=>''])) > 0); check("['a'=>null] vs ['a'=>0] differs", count(array_recursive_diff(['a'=>null], ['a'=>0])) > 0); check("['a'=>'10'] vs ['a'=>'1e1'] differs", count(array_recursive_diff(['a'=>'10'], ['a'=>'1e1'])) > 0); check("['a'=>'1e3'] vs ['a'=>'1000'] differs", count(array_recursive_diff(['a'=>'1e3'], ['a'=>'1000'])) > 0); check("['a'=>5] vs ['a'=>'5'] same", count(array_recursive_diff(['a'=>5], ['a'=>'5'])) === 0); check("['a'=>null] vs ['a'=>''] same", count(array_recursive_diff(['a'=>null], ['a'=>''])) === 0); check("['a'=>false] vs ['a'=>'0'] same", count(array_recursive_diff(['a'=>false], ['a'=>'0'])) === 0); check("['a'=>true] vs ['a'=>1] same", count(array_recursive_diff(['a'=>true], ['a'=>1])) === 0); } /* ---- Part (b): ZM_Object::changes() ---- */ $objSrc = file_get_contents($root.'/web/includes/Object.php'); $changes = extract_function($objSrc, 'changes'); check('changes() found in Object.php', $changes !== null); if ($changes !== null) { $classCode = 'class ChangesProbe {' . ' protected $defaults = array();' . ' public $Foo = 0;' . ' public $bar = null;' . ' public function Bar() { return $this->bar; }' . ' public function isSetter($f) { return true; }' . ' ' . $changes . ' }'; $ok = eval($classCode); check('changes() evals into a probe class', $ok !== false); if ($ok !== false) { $probe = new ChangesProbe(); $probe->Foo = 0; check("changes(['Foo'=>'']) on Foo=0 reports a change", count($probe->changes(['Foo'=>''])) > 0); $probe->Foo = 0; check("changes(['Foo'=>'0']) on Foo=0 reports no change", count($probe->changes(['Foo'=>'0'])) === 0); $probe->bar = null; check("changes(['Bar'=>'']) on Bar()===null reports no change", count($probe->changes(['Bar'=>''])) === 0); $probe->bar = 0; check("changes(['Bar'=>'']) on Bar()===0 reports a change", count($probe->changes(['Bar'=>''])) > 0); $probe->bar = '10'; check("changes(['Bar'=>'1e1']) on Bar()==='10' reports a change", count($probe->changes(['Bar'=>'1e1'])) > 0); $probe->Foo = '10'; check("changes(['Foo'=>'1e1']) on Foo='10' reports a change", count($probe->changes(['Foo'=>'1e1'])) > 0); } } echo "\n$tests tests, $failures failures\n"; exit($failures ? 1 : 0);