Skip to content

Commit 7c13fe3

Browse files
committed
Adapt the last of the Darwin- and XCTest-specific code in the diffing tests
1 parent 1af14db commit 7c13fe3

File tree

1 file changed

+19
-16
lines changed

1 file changed

+19
-16
lines changed

test/stdlib/Diffing.swift

Lines changed: 19 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -574,7 +574,7 @@ TestSuite(suite).test("Three way diff demo code") {
574574

575575
TestSuite(suite).test("Diff reversal demo code") {
576576
let diff = OrderedCollectionDifference<Int>([])!
577-
let reversed = OrderedCollectionDifference<Int>(
577+
let _ = OrderedCollectionDifference<Int>(
578578
diff.map({(change) -> OrderedCollectionDifference<Int>.Change in
579579
switch change {
580580
case .insert(offset: let o, element: let e, associatedWith: let a):
@@ -584,7 +584,6 @@ TestSuite(suite).test("Diff reversal demo code") {
584584
}
585585
})
586586
)!
587-
// print(reversed)
588587
}
589588

590589
TestSuite(suite).test("Naive application by enumeration") {
@@ -637,27 +636,31 @@ TestSuite(suite).test("Fast applicator boundary conditions") {
637636
}
638637

639638
TestSuite(suite).test("Fast applicator fuzzer") {
640-
func makeArray() -> [UInt32] {
641-
var arr = [UInt32]()
642-
for _ in 0..<arc4random_uniform(10) {
643-
arr.append(arc4random_uniform(20))
639+
func makeArray() -> [Int] {
640+
var arr = [Int]()
641+
for _ in 0..<Int.random(in: 0..<10) {
642+
arr.append(Int.random(in: 0..<20))
644643
}
645644
return arr
646645
}
647646
for _ in 0..<1000 {
648647
let a = makeArray()
649648
let b = makeArray()
650649
let d = b.shortestEditScript(from: a)
651-
expectEqual(b, a.applying(d)!)
652-
if self.testRun!.failureCount > 0 {
653-
print("""
654-
// repro:
655-
let a = \(a)
656-
let b = \(b)
657-
let d = b.shortestEditScript(from: a)
658-
expectEqual(b, a.applying(d))
659-
""")
660-
break
650+
let applied = a.applying(d)
651+
expectNotNil(applied)
652+
if let applied = applied {
653+
expectEqual(b, applied)
654+
if (b != applied) {
655+
print("""
656+
// repro:
657+
let a = \(a)
658+
let b = \(b)
659+
let d = b.shortestEditScript(from: a)
660+
expectEqual(b, a.applying(d))
661+
""")
662+
break
663+
}
661664
}
662665
}
663666
}

0 commit comments

Comments
 (0)