Example #1
0
 public function testConflicted()
 {
     $table1 = harness_Native::table($this->data1);
     $table2 = harness_Native::table($this->data2);
     $table3 = harness_Native::table($this->data3b);
     $table4 = harness_Native::table($this->data4b);
     $flags = new coopy_CompareFlags();
     $merger = new coopy_Merger($table1, $table2, $table3, $flags);
     $conflicts = $merger->apply();
     $this->assertEquals($conflicts, 1, _hx_anonymous(array("fileName" => "MergeTest.hx", "lineNumber" => 64, "className" => "harness.MergeTest", "methodName" => "testConflicted")));
     $this->assertEquals(coopy_SimpleTable::tableToString($table2), coopy_SimpleTable::tableToString($table4), _hx_anonymous(array("fileName" => "MergeTest.hx", "lineNumber" => 65, "className" => "harness.MergeTest", "methodName" => "testConflicted")));
 }
Example #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;
 }
Example #3
0
 public function toString()
 {
     return coopy_SimpleTable::tableToString($this);
 }
Example #4
0
 public function testThreeWay()
 {
     $flags = new coopy_CompareFlags();
     $table1 = harness_Native::table($this->data1);
     $table2 = harness_Native::table($this->data2);
     $table3 = harness_Native::table($this->data3);
     $table4 = harness_Native::table($this->data4);
     $flags->parent = $table1;
     $out = coopy_Coopy::diff($table2, $table3, $flags);
     $table2b = $table2->hclone();
     coopy_Coopy::patch($table2b, $out, null);
     $this->assertTrue(coopy_SimpleTable::tableIsSimilar($table4, $table2b), _hx_anonymous(array("fileName" => "BasicTest.hx", "lineNumber" => 130, "className" => "harness.BasicTest", "methodName" => "testThreeWay")));
 }
 static function tableIsSimilar($tab1, $tab2)
 {
     if ($tab1->get_height() === -1 || $tab2->get_height() === -1) {
         $txt1 = coopy_SimpleTable::tableToString($tab1);
         $txt2 = coopy_SimpleTable::tableToString($tab2);
         return $txt1 === $txt2;
     }
     if ($tab1->get_width() !== $tab2->get_width()) {
         return false;
     }
     if ($tab1->get_height() !== $tab2->get_height()) {
         return false;
     }
     $v = $tab1->getCellView();
     $_g1 = 0;
     $_g = $tab1->get_height();
     while ($_g1 < $_g) {
         $i = $_g1++;
         $_g3 = 0;
         $_g2 = $tab1->get_width();
         while ($_g3 < $_g2) {
             $j = $_g3++;
             if (!$v->equals($tab1->getCell($j, $i), $tab2->getCell($j, $i))) {
                 return false;
             }
             unset($j);
         }
         unset($_g3, $_g2);
         unset($i);
     }
     return true;
 }
Example #6
0
 public function jsonToTable($json)
 {
     $output = null;
     $_g = 0;
     $_g1 = Reflect::fields($json);
     while ($_g < $_g1->length) {
         $name = $_g1[$_g];
         ++$_g;
         $t = Reflect::field($json, $name);
         $columns = Reflect::field($t, "columns");
         if ($columns === null) {
             continue;
         }
         $rows = Reflect::field($t, "rows");
         if ($rows === null) {
             continue;
         }
         $output = new coopy_SimpleTable($columns->length, $rows->length);
         $has_hash = false;
         $has_hash_known = false;
         $_g3 = 0;
         $_g2 = $rows->length;
         while ($_g3 < $_g2) {
             $i = $_g3++;
             $row = $rows[$i];
             if (!$has_hash_known) {
                 if (Reflect::fields($row)->length === $columns->length) {
                     $has_hash = true;
                 }
                 $has_hash_known = true;
             }
             if (!$has_hash) {
                 $lst = $row;
                 $_g5 = 0;
                 $_g4 = $columns->length;
                 while ($_g5 < $_g4) {
                     $j = $_g5++;
                     $val = $lst[$j];
                     $output->setCell($j, $i, coopy_Coopy::cellFor($val));
                     unset($val, $j);
                 }
                 unset($_g5, $_g4);
                 unset($lst);
             } else {
                 $_g51 = 0;
                 $_g41 = $columns->length;
                 while ($_g51 < $_g41) {
                     $j1 = $_g51++;
                     $val1 = Reflect::field($row, $columns[$j1]);
                     $output->setCell($j1, $i, coopy_Coopy::cellFor($val1));
                     unset($val1, $j1);
                 }
                 unset($_g51, $_g41);
             }
             unset($row, $i);
         }
         unset($_g3, $_g2);
         unset($t, $rows, $name, $has_hash_known, $has_hash, $columns);
     }
     if ($output !== null) {
         $output->trimBlank();
     }
     return $output;
 }
Example #7
0
 public function asTable()
 {
     if ($this->has_properties && $this->metadata === null) {
         return $this->t;
     }
     if ($this->metadata === null) {
         return null;
     }
     $w = $this->t->get_width();
     $props = new _hx_array(array());
     if (null == $this->keys) {
         throw new HException('null iterable');
     }
     $__hx__it = $this->keys->keys();
     while ($__hx__it->hasNext()) {
         unset($k);
         $k = $__hx__it->next();
         $props->push($k);
     }
     $props->sort(isset(Reflect::$compare) ? Reflect::$compare : array("Reflect", "compare"));
     $mt = new coopy_SimpleTable($w + 1, $props->length + 1);
     $mt->setCell(0, 0, "@");
     $_g = 0;
     while ($_g < $w) {
         $x = $_g++;
         $name = $this->t->getCell($x, 0);
         $mt->setCell(1 + $x, 0, $name);
         if (!$this->metadata->exists($name)) {
             continue;
         }
         $vals = $this->metadata->get($name);
         $_g2 = 0;
         $_g1 = $props->length;
         while ($_g2 < $_g1) {
             $i = $_g2++;
             if ($vals->exists($props[$i])) {
                 $mt->setCell(1 + $x, $i + 1, $vals->get($props[$i]));
             }
             unset($i);
         }
         unset($_g2, $_g1);
         unset($x, $vals, $name);
     }
     $_g11 = 0;
     $_g3 = $props->length;
     while ($_g11 < $_g3) {
         $y = $_g11++;
         $mt->setCell(0, $y + 1, $props[$y]);
         unset($y);
     }
     return $mt;
 }
Example #8
0
 public function asTable()
 {
     $pct = 3;
     $this->getColumns();
     $w = $this->columnNames->length;
     $mt = new coopy_SimpleTable($w + 1, $pct);
     $mt->setCell(0, 0, "@");
     $mt->setCell(0, 1, "type");
     $mt->setCell(0, 2, "key");
     $_g = 0;
     while ($_g < $w) {
         $x = $_g++;
         $i = $x + 1;
         $mt->setCell($i, 0, $this->columnNames[$x]);
         $mt->setCell($i, 1, _hx_array_get($this->columns, $x)->type_value);
         $mt->setCell($i, 2, _hx_array_get($this->columns, $x)->primary ? "primary" : "");
         unset($x, $i);
     }
     return $mt;
 }