本文整理汇总了PHP中Diff::cleanupSemanticLossless方法的典型用法代码示例。如果您正苦于以下问题:PHP Diff::cleanupSemanticLossless方法的具体用法?PHP Diff::cleanupSemanticLossless怎么用?PHP Diff::cleanupSemanticLossless使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Diff
的用法示例。
在下文中一共展示了Diff::cleanupSemanticLossless方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testCleanupSemanticLossless
public function testCleanupSemanticLossless()
{
// Slide diffs to match logical boundaries.
// Null case.
$this->d->setChanges(array());
$this->d->cleanupSemanticLossless();
$this->assertEquals(array(), $this->d->getChanges());
// Blank lines.
$this->d->setChanges(array(array(Diff::EQUAL, "AAA\r\n\r\nBBB"), array(Diff::INSERT, "\r\nDDD\r\n\r\nBBB"), array(Diff::EQUAL, "\r\nEEE")));
$this->d->cleanupSemanticLossless();
$this->assertEquals(array(array(Diff::EQUAL, "AAA\r\n\r\n"), array(Diff::INSERT, "BBB\r\nDDD\r\n\r\n"), array(Diff::EQUAL, "BBB\r\nEEE")), $this->d->getChanges());
// Line boundaries.
$this->d->setChanges(array(array(Diff::EQUAL, "AAA\r\nBBB"), array(Diff::INSERT, " DDD\r\nBBB"), array(Diff::EQUAL, " EEE")));
$this->d->cleanupSemanticLossless();
$this->assertEquals(array(array(Diff::EQUAL, "AAA\r\n"), array(Diff::INSERT, "BBB DDD\r\n"), array(Diff::EQUAL, "BBB EEE")), $this->d->getChanges());
// Word boundaries.
$this->d->setChanges(array(array(Diff::EQUAL, "The c"), array(Diff::INSERT, "ow and the c"), array(Diff::EQUAL, "at.")));
$this->d->cleanupSemanticLossless();
$this->assertEquals(array(array(Diff::EQUAL, "The "), array(Diff::INSERT, "cow and the "), array(Diff::EQUAL, "cat.")), $this->d->getChanges());
// Alphanumeric boundaries.
$this->d->setChanges(array(array(Diff::EQUAL, "The-c"), array(Diff::INSERT, "ow-and-the-c"), array(Diff::EQUAL, "at.")));
$this->d->cleanupSemanticLossless();
$this->assertEquals(array(array(Diff::EQUAL, "The-"), array(Diff::INSERT, "cow-and-the-"), array(Diff::EQUAL, "cat.")), $this->d->getChanges());
// Hitting the start.
$this->d->setChanges(array(array(Diff::EQUAL, "a"), array(Diff::DELETE, "a"), array(Diff::EQUAL, "ax")));
$this->d->cleanupSemanticLossless();
$this->assertEquals(array(array(Diff::DELETE, "a"), array(Diff::EQUAL, "aax")), $this->d->getChanges());
// Hitting the end.
$this->d->setChanges(array(array(Diff::EQUAL, "xa"), array(Diff::DELETE, "a"), array(Diff::EQUAL, "a")));
$this->d->cleanupSemanticLossless();
$this->assertEquals(array(array(Diff::EQUAL, "xaa"), array(Diff::DELETE, "a")), $this->d->getChanges());
// Sentence boundaries.
$this->d->setChanges(array(array(Diff::EQUAL, "The xxx. The "), array(Diff::INSERT, "zzz. The "), array(Diff::EQUAL, "yyy.")));
$this->d->cleanupSemanticLossless();
$this->assertEquals(array(array(Diff::EQUAL, "The xxx."), array(Diff::INSERT, " The zzz."), array(Diff::EQUAL, " The yyy.")), $this->d->getChanges());
}