Esempio n. 1
0
 public function testMedium()
 {
     $table1 = harness_Native::table($this->data1);
     $table2 = harness_Native::table($this->data2);
     $flags = new coopy_CompareFlags();
     $flags->unchanged_column_context = 3;
     $align = coopy_Coopy::compareTables($table1, $table2, null)->align();
     $diff = harness_Native::table(new _hx_array(array()));
     $highlighter = new coopy_TableDiff($align, $flags);
     $flags->ordered = false;
     $highlighter->hilite($diff);
     $this->assertEquals(1, 1, _hx_anonymous(array("fileName" => "SpeedTest.hx", "lineNumber" => 59, "className" => "harness.SpeedTest", "methodName" => "testMedium")));
 }
Esempio n. 2
0
 protected function _quickDiff($data1, $data2)
 {
     $table1 = new coopy_PhpTableView($data1);
     $table2 = new coopy_PhpTableView($data2);
     $data_diff = [];
     $table_diff = new coopy_PhpTableView($data_diff);
     $highlighter = new coopy_TableDiff(coopy_Coopy::compareTables($table1, $table2)->align(), new coopy_CompareFlags());
     $highlighter->hilite($table_diff);
     $diff2html = new coopy_DiffRender();
     $diff2html->usePrettyArrows(false);
     $diff2html->render($table_diff);
     return $diff2html->html();
 }
Esempio n. 3
0
 public function testRowOrder()
 {
     $data1 = new _hx_array(array(new _hx_array(array("Country", "Capital")), new _hx_array(array("Ireland", "Dublin")), new _hx_array(array("France", "Paris")), new _hx_array(array("Spain", "Barcelona"))));
     $data2 = new _hx_array(array(new _hx_array(array("Country", "Code", "Capital")), new _hx_array(array("Ireland", "ie", "Dublin")), new _hx_array(array("France", "fr", "Paris")), new _hx_array(array("Spain", "es", "Madrid")), new _hx_array(array("Germany", "de", "Berlin"))));
     $table1 = harness_Native::table($data1);
     $table2 = harness_Native::table($data2);
     $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();
     $flags->always_show_order = true;
     $flags->never_show_order = false;
     $highlighter = new coopy_TableDiff($alignment, $flags);
     $highlighter->hilite($table_diff);
     $this->assertEquals("-:4", $table_diff->getCell(0, 6), _hx_anonymous(array("fileName" => "RowOrderTest.hx", "lineNumber" => 26, "className" => "harness.RowOrderTest", "methodName" => "testRowOrder")));
 }
Esempio n. 4
0
 /**
  * Test rows are ordered correctly when a row is removed
  */
 public function testIssue11()
 {
     $data1 = [['Country', 'Capital'], ['Ireland', 'Dublin'], ['France', 'Paris'], ['Spain', 'Barcelona']];
     $data2 = [['Country', 'Capital'], ['Ireland', 'Dublin'], ['Spain', 'Madrid']];
     $table1 = new coopy_PhpTableView($data1);
     $table2 = new coopy_PhpTableView($data2);
     $data_diff = [];
     $table_diff = new coopy_PhpTableView($data_diff);
     $highlighter = new coopy_TableDiff(coopy_Coopy::compareTables($table1, $table2)->align(), new coopy_CompareFlags());
     $highlighter->hilite($table_diff);
     foreach ($table_diff->data as $row) {
         $sortedRow = $row;
         ksort($sortedRow, SORT_NUMERIC);
         $this->assertEquals($row, $sortedRow);
     }
 }
Esempio n. 5
0
 public function testList()
 {
     $data1 = new _hx_array(array(new _hx_array(array("id", "color", "length")), new _hx_array(array(15, "Red", 11.2))));
     $table1 = harness_Native::table($data1);
     $flags = new coopy_CompareFlags();
     $align = coopy_Coopy::compareTables($table1, $table1, null)->align();
     $diff = harness_Native::table(new _hx_array(array()));
     $highlighter = new coopy_TableDiff($align, $flags);
     $flags->always_show_order = true;
     $flags->never_show_order = false;
     $highlighter->hilite($diff);
     if ($diff->getData() !== null) {
         $this->assertTrue(harness_Native::isList($diff->getData()), _hx_anonymous(array("fileName" => "TypeTest.hx", "lineNumber" => 35, "className" => "harness.TypeTest", "methodName" => "testList")));
         $this->assertTrue(harness_Native::isList(harness_Native::row($diff->getData(), 0)), _hx_anonymous(array("fileName" => "TypeTest.hx", "lineNumber" => 36, "className" => "harness.TypeTest", "methodName" => "testList")));
         $this->assertTrue(harness_Native::isList(harness_Native::row($diff->getData(), 1)), _hx_anonymous(array("fileName" => "TypeTest.hx", "lineNumber" => 37, "className" => "harness.TypeTest", "methodName" => "testList")));
     }
 }
Esempio n. 6
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. 7
0
 public function testNestedOutputHtml()
 {
     $table1 = harness_Native::table($this->data1);
     $table2 = harness_Native::table($this->data2);
     $alignment = coopy_Coopy::compareTables($table1, $table2, null)->align();
     $table_diff1 = harness_Native::table(new _hx_array(array()));
     $table_diff2 = harness_Native::table(new _hx_array(array()));
     $flags = new coopy_CompareFlags();
     $highlighter1 = new coopy_TableDiff($alignment, $flags);
     $highlighter1->hilite($table_diff1);
     $flags->allow_nested_cells = true;
     $highlighter2 = new coopy_TableDiff($alignment, $flags);
     $highlighter2->hilite($table_diff2);
     $render1 = _hx_deref(new coopy_DiffRender())->render($table_diff1)->html();
     $render2 = _hx_deref(new coopy_DiffRender())->render($table_diff2)->html();
     $this->assertEquals($render1, $render2, _hx_anonymous(array("fileName" => "BasicTest.hx", "lineNumber" => 117, "className" => "harness.BasicTest", "methodName" => "testNestedOutputHtml")));
 }
Esempio n. 8
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();