4
4
import Swift
5
5
import StdlibUnittest
6
6
7
- let suite = " Diffing "
7
+ let suite = TestSuite ( " Diffing " )
8
8
9
- TestSuite ( suite) . test ( " Diffing empty collections " ) {
9
+ suite. test ( " Diffing empty collections " ) {
10
10
let a = [ Int] ( )
11
11
let b = [ Int] ( )
12
12
let diff = b. difference ( from: a)
13
13
expectEqual ( diff, a. difference ( from: a) )
14
14
expectTrue ( diff. isEmpty)
15
15
}
16
16
17
- TestSuite ( suite) . test ( " Basic diffing algorithm validators " ) {
17
+ suite. test ( " Basic diffing algorithm validators " ) {
18
18
let expectedChanges : [ (
19
19
source: [ String ] ,
20
20
target: [ String ] ,
@@ -340,7 +340,7 @@ TestSuite(suite).test("Basic diffing algorithm validators") {
340
340
}
341
341
}
342
342
343
- TestSuite ( suite) . test ( " Empty diffs have sane behaviour " ) {
343
+ suite. test ( " Empty diffs have sane behaviour " ) {
344
344
guard let diff = CollectionDifference < String > ( [ ] ) else {
345
345
expectUnreachable ( )
346
346
return
@@ -354,7 +354,7 @@ TestSuite(suite).test("Empty diffs have sane behaviour") {
354
354
expectEqual ( 0 , c)
355
355
}
356
356
357
- TestSuite ( suite) . test ( " Happy path tests for the change validator " ) {
357
+ suite. test ( " Happy path tests for the change validator " ) {
358
358
// Base case: one insert and one remove with legal offsets
359
359
expectNotNil ( CollectionDifference< Int> . init( [
360
360
. insert( offset: 0 , element: 0 , associatedWith: nil ) ,
@@ -372,7 +372,7 @@ TestSuite(suite).test("Happy path tests for the change validator") {
372
372
] ) )
373
373
}
374
374
375
- TestSuite ( suite) . test ( " Exhaustive edge case tests for the change validator " ) {
375
+ suite. test ( " Exhaustive edge case tests for the change validator " ) {
376
376
// Base case: two inserts sharing the same offset
377
377
expectNil ( CollectionDifference< Int> . init( [
378
378
. insert( offset: 0 , element: 0 , associatedWith: nil ) ,
@@ -430,7 +430,7 @@ TestSuite(suite).test("Exhaustive edge case tests for the change validator") {
430
430
] ) )
431
431
}
432
432
433
- TestSuite ( suite) . test ( " Enumeration order is safe " ) {
433
+ suite. test ( " Enumeration order is safe " ) {
434
434
let safelyOrderedChanges : [ CollectionDifference < Int > . Change ] = [
435
435
. remove( offset: 2 , element: 0 , associatedWith: nil ) ,
436
436
. remove( offset: 1 , element: 0 , associatedWith: 0 ) ,
@@ -447,7 +447,7 @@ TestSuite(suite).test("Enumeration order is safe") {
447
447
expectEqual ( safelyOrderedChanges, enumerationOrderedChanges)
448
448
}
449
449
450
- TestSuite ( suite) . test ( " Change validator rejects bad associations " ) {
450
+ suite. test ( " Change validator rejects bad associations " ) {
451
451
// .remove(1) → .insert(1)
452
452
// ↑ ↓
453
453
// .insert(0) ← .remove(0)
@@ -472,7 +472,7 @@ TestSuite(suite).test("Change validator rejects bad associations") {
472
472
}
473
473
474
474
// Full-coverage test for CollectionDifference.Change.==()
475
- TestSuite ( suite) . test ( " Exhaustive testing for equatable conformance " ) {
475
+ suite. test ( " Exhaustive testing for equatable conformance " ) {
476
476
// Differs by type:
477
477
expectNotEqual (
478
478
CollectionDifference< Int> . Change. insert ( offset: 0 , element: 0 , associatedWith: 0 ) ,
@@ -522,11 +522,11 @@ TestSuite(suite).test("Exhaustive testing for equatable conformance") {
522
522
)
523
523
}
524
524
525
- TestSuite ( suite) . test ( " Compile-time test of hashable conformance " ) {
525
+ suite. test ( " Compile-time test of hashable conformance " ) {
526
526
let _ = Set < CollectionDifference < String > > ( ) ;
527
527
}
528
528
529
- TestSuite ( suite) . test ( " Move inference " ) {
529
+ suite. test ( " Move inference " ) {
530
530
let n = CollectionDifference< String> . init( [
531
531
. insert( offset: 3 , element: " Sike " , associatedWith: nil ) ,
532
532
. insert( offset: 4 , element: " Sike " , associatedWith: nil ) ,
@@ -546,7 +546,7 @@ TestSuite(suite).test("Move inference") {
546
546
expectEqual ( w, n? . inferringMoves ( ) )
547
547
}
548
548
549
- TestSuite ( suite) . test ( " Three way diff demo code " ) {
549
+ suite. test ( " Three way diff demo code " ) {
550
550
let base = " Is \n it \n time \n already? "
551
551
let theirs = " Hi \n there \n is \n it \n time \n already? "
552
552
let mine = " Is \n it \n review \n time \n already? "
@@ -571,7 +571,7 @@ TestSuite(suite).test("Three way diff demo code") {
571
571
// print(patched)
572
572
}
573
573
574
- TestSuite ( suite) . test ( " Diff reversal demo code " ) {
574
+ suite. test ( " Diff reversal demo code " ) {
575
575
let diff = CollectionDifference < Int > ( [ ] ) !
576
576
let _ = CollectionDifference < Int > (
577
577
diff. map ( { ( change) -> CollectionDifference < Int > . Change in
@@ -585,7 +585,7 @@ TestSuite(suite).test("Diff reversal demo code") {
585
585
) !
586
586
}
587
587
588
- TestSuite ( suite) . test ( " Naive application by enumeration " ) {
588
+ suite. test ( " Naive application by enumeration " ) {
589
589
let base = " Is \n it \n time \n already? "
590
590
let theirs = " Hi \n there \n is \n it \n time \n already? "
591
591
@@ -608,7 +608,7 @@ TestSuite(suite).test("Naive application by enumeration") {
608
608
expectEqual ( arr, theirLines)
609
609
}
610
610
611
- TestSuite ( suite) . test ( " Fast applicator boundary conditions " ) {
611
+ suite. test ( " Fast applicator boundary conditions " ) {
612
612
let a = [ 1 , 2 , 3 , 4 , 5 , 6 , 7 , 8 ]
613
613
for removeMiddle in [ false , true ] {
614
614
for insertMiddle in [ false , true ] {
@@ -634,7 +634,7 @@ TestSuite(suite).test("Fast applicator boundary conditions") {
634
634
} } } } } }
635
635
}
636
636
637
- TestSuite ( suite) . test ( " Fast applicator fuzzer " ) {
637
+ suite. test ( " Fast applicator fuzzer " ) {
638
638
func makeArray( ) -> [ Int ] {
639
639
var arr = [ Int] ( )
640
640
for _ in 0 ..< Int . random ( in: 0 ..< 10 ) {
0 commit comments