Esempio n. 1
0
 public function testEmpty()
 {
     $table1 = harness_Native::table($this->data1);
     $table2 = harness_Native::table(new _hx_array(array()));
     $alignment = coopy_Coopy::compareTables($table1, $table2, null)->align();
     $data_diff = new _hx_array(array());
     $table_diff = harness_Native::table($data_diff);
     $flags = new coopy_CompareFlags();
     $highlighter = new coopy_TableDiff($alignment, $flags);
     $highlighter->hilite($table_diff);
     $table3 = $table1->hclone();
     $patcher = new coopy_HighlightPatch($table3, $table_diff, null);
     $patcher->apply();
     $this->assertEquals(0, $table3->get_height(), _hx_anonymous(array("fileName" => "BasicTest.hx", "lineNumber" => 80, "className" => "harness.BasicTest", "methodName" => "testEmpty")));
 }
Esempio n. 2
0
 public function checkDiff($e1, $e2, $verbose = null)
 {
     if ($verbose === null) {
         $verbose = false;
     }
     $table1 = harness_Native::table($e1);
     $table2 = harness_Native::table($e2);
     $data_diff = new _hx_array(array());
     $table_diff = harness_Native::table($data_diff);
     $flags = new coopy_CompareFlags();
     $alignment = coopy_Coopy::compareTables($table1, $table2, $flags)->align();
     if ($verbose) {
         haxe_Log::trace("Alignment: " . Std::string($alignment), _hx_anonymous(array("fileName" => "SmallTableTest.hx", "lineNumber" => 18, "className" => "harness.SmallTableTest", "methodName" => "checkDiff")));
     }
     $highlighter = new coopy_TableDiff($alignment, $flags);
     $highlighter->hilite($table_diff);
     if ($verbose) {
         haxe_Log::trace("Diff: " . Std::string($table_diff), _hx_anonymous(array("fileName" => "SmallTableTest.hx", "lineNumber" => 21, "className" => "harness.SmallTableTest", "methodName" => "checkDiff")));
     }
     $o = coopy_Coopy::diff($table1, $table2, null);
     $this->assertTrue(coopy_SimpleTable::tableIsSimilar($table_diff, $o), _hx_anonymous(array("fileName" => "SmallTableTest.hx", "lineNumber" => 25, "className" => "harness.SmallTableTest", "methodName" => "checkDiff")));
     $table3 = $table1->hclone();
     $patcher = new coopy_HighlightPatch($table3, $table_diff, null);
     $patcher->apply();
     if ($verbose) {
         haxe_Log::trace("Desired " . _hx_string_rec($table2->get_height(), "") . "x" . _hx_string_rec($table2->get_width(), "") . ": " . Std::string($table2), _hx_anonymous(array("fileName" => "SmallTableTest.hx", "lineNumber" => 30, "className" => "harness.SmallTableTest", "methodName" => "checkDiff")));
     }
     if ($verbose) {
         haxe_Log::trace("Got " . _hx_string_rec($table3->get_height(), "") . "x" . _hx_string_rec($table3->get_width(), "") . ": " . Std::string($table3), _hx_anonymous(array("fileName" => "SmallTableTest.hx", "lineNumber" => 31, "className" => "harness.SmallTableTest", "methodName" => "checkDiff")));
     }
     if ($verbose) {
         haxe_Log::trace("Base " . _hx_string_rec($table1->get_height(), "") . "x" . _hx_string_rec($table1->get_width(), "") . ": " . Std::string($table1), _hx_anonymous(array("fileName" => "SmallTableTest.hx", "lineNumber" => 32, "className" => "harness.SmallTableTest", "methodName" => "checkDiff")));
     }
     $this->assertTrue(coopy_SimpleTable::tableIsSimilar($table3, $table2), _hx_anonymous(array("fileName" => "SmallTableTest.hx", "lineNumber" => 33, "className" => "harness.SmallTableTest", "methodName" => "checkDiff")));
     return $table_diff;
 }
Esempio n. 3
0
 static function patch($local, $patch, $flags = null)
 {
     $patcher = new coopy_HighlightPatch(coopy_Coopy::tablify($local), coopy_Coopy::tablify($patch), null);
     return $patcher->apply();
 }
Esempio n. 4
0
<?php

if (version_compare(PHP_VERSION, '5.1.0', '<')) {
    exit('Your current PHP version is: ' . PHP_VERSION . '. Haxe/PHP generates code for version 5.1.0 or later');
}
require_once dirname(__FILE__) . '/lib/php/Boot.class.php';
$data1 = [['Country', 'Capital'], ['Ireland', 'Dublin'], ['France', 'Paris'], ['Spain', 'Barcelona']];
$data2 = [['Country', 'Code', 'Capital'], ['Ireland', 'ie', 'Dublin'], ['France', 'fr', 'Paris'], ['Spain', 'es', 'Madrid'], ['Germany', 'de', 'Berlin']];
$table1 = new coopy_PhpTableView($data1);
$table2 = new coopy_PhpTableView($data2);
$alignment = coopy_Coopy::compareTables($table1, $table2)->align();
$data_diff = [];
$table_diff = new coopy_PhpTableView($data_diff);
$flags = new coopy_CompareFlags();
$highlighter = new coopy_TableDiff($alignment, $flags);
$highlighter->hilite($table_diff);
$diff2html = new coopy_DiffRender();
$diff2html->usePrettyArrows(false);
$diff2html->render($table_diff);
$table_diff_html = $diff2html->html();
echo $table_diff_html;
$patcher = new coopy_HighlightPatch($table1, $table_diff);
$patcher->apply();
Esempio n. 5
0
 static function patch($local, $patch, $flags = null)
 {
     $patcher = new coopy_HighlightPatch($local, $patch, null);
     return $patcher->apply();
 }