Skip to content
This repository was archived by the owner on Jul 1, 2023. It is now read-only.

Commit 9e18d9a

Browse files
committed
Basic unit testing
1 parent 369e9f3 commit 9e18d9a

File tree

6 files changed

+463
-19
lines changed

6 files changed

+463
-19
lines changed

.travis.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,5 @@ composer install --ignore-platform-reqs
66

77
hh_client
88

9-
#hhvm vendor/bin/phpunit
9+
hhvm vendor/bin/hacktest tests/
1010
hhvm vendor/bin/hhast-lint

composer.json

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,17 @@
11
{
22
"name": "facebook/difflib",
33
"license": "MIT",
4+
"extra": {
5+
"branch-alias": {
6+
"dev-master": "0.2.x-dev"
7+
}
8+
},
49
"require": {
510
"hhvm/hsl": "^3.28"
611
},
712
"require-dev": {
8-
"hhvm/hhast": "^3.28"
13+
"hhvm/hhast": "^3.28",
14+
"hhvm/hacktest": "^1.0",
15+
"facebook/fbexpect": "^2.1.2"
916
}
1017
}

composer.lock

Lines changed: 213 additions & 17 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

tests/ClusterTest.php

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
<?hh // strict
2+
/*
3+
* Copyright (c) 2017-present, Facebook, Inc.
4+
* All rights reserved.
5+
*
6+
* This source code is licensed under the MIT license found in the
7+
* LICENSE file in the root directory of this source tree.
8+
*
9+
*/
10+
11+
namespace Facebook\DiffLib;
12+
13+
use namespace HH\Lib\{C, Vec};
14+
use function Facebook\FBExpect\expect;
15+
16+
final class ClusterTest extends \Facebook\HackTest\HackTest {
17+
public function testReplaceTrailing(): void {
18+
$diff = StringDiff::characters('abc', 'ade')->getDiff()
19+
|> cluster($$);
20+
expect(C\count($diff))->toBeSame(3);
21+
expect($diff[0])->toBeInstanceOf(DiffKeepOp::class);
22+
expect($diff[1])->toBeInstanceOf(DiffDeleteOp::class);
23+
expect($diff[2])->toBeInstanceOf(DiffInsertOp::class);
24+
25+
expect(Vec\map($diff, $op ==> $op->getContent()))->toBeSame(
26+
vec[vec['a'], vec['b', 'c'], vec['d', 'e']],
27+
);
28+
}
29+
}

0 commit comments

Comments
 (0)