示例#1
0
文件: main.php 项目: nian2go/fatfree
 function misc()
 {
     $this->set('title', 'Miscellaneous');
     $this->expect(is_null($this->get('ERROR')), 'No errors expected at this point', 'ERROR variable is set: ' . $this->get('ERROR.text'));
     $str = Code::snake('helloWorld');
     $this->expect($str == 'hello_world', 'Snakecase conversion is correct: ' . $str, 'Snakecase conversion failed: ' . $str);
     $str = Code::camel($str);
     $this->expect($str == 'helloWorld', 'camelCase conversion is correct: ' . $str, 'camelCase conversion failed: ' . $str);
     $old = trim(file_get_contents('inc/diff1.txt'));
     $new = trim(file_get_contents('inc/diff2.txt'));
     foreach (array('character-based comparison' => '', 'space as delimiter' => ' ', 'line-by-line comparison' => "\n") as $desc => $delim) {
         $diff = Text::diff($old, $new, $delim);
         $build = Text::patch($old, $diff['patch'], $delim);
         $this->expect($build == $new, 'Patch worked (' . $desc . ')', 'Patch failed: <pre>' . $build . '</pre>');
         $build = Text::patch($new, $diff['patch'], $delim, TRUE);
         $this->expect($build == $old, 'Reverse patch applied correctly', 'Reverse patch failed: <pre>' . $build . '</pre>');
     }
     echo $this->render('basic/results.htm');
 }