Skip to content

Commit 750a5b7

Browse files
authored
Merge pull request #3071 from apple/stdlib-fix-indentation
2 parents 6e28eab + 0892c22 commit 750a5b7

File tree

1 file changed

+104
-98
lines changed

1 file changed

+104
-98
lines changed

stdlib/private/StdlibCollectionUnittest/CheckCollectionType.swift.gyb

Lines changed: 104 additions & 98 deletions
Original file line numberDiff line numberDiff line change
@@ -1596,83 +1596,87 @@ extension TestSuite {
15961596
}
15971597
}
15981598
% end
1599-
1599+
16001600
self.test("\(testNamePrefix)/distance(from:to:)/semantics")
1601-
.forEach(in: distanceFromToTests) { (test) in
1602-
let c = toCollection(0..<20)
1603-
let backwards = (test.startOffset > test.endOffset)
1604-
if backwards && !collectionIsBidirectional {
1605-
expectCrashLater()
1606-
}
1601+
.forEach(in: distanceFromToTests) {
1602+
test in
1603+
let c = toCollection(0..<20)
1604+
let backwards = (test.startOffset > test.endOffset)
1605+
if backwards && !collectionIsBidirectional {
1606+
expectCrashLater()
1607+
}
16071608

1608-
let d = c.distance(
1609-
from: c.nthIndex(test.startOffset), to: c.nthIndex(test.endOffset))
1610-
expectEqual(
1611-
numericCast(test.expectedDistance),
1612-
d, stackTrace: SourceLocStack().with(test.loc))
1609+
let d = c.distance(
1610+
from: c.nthIndex(test.startOffset), to: c.nthIndex(test.endOffset))
1611+
expectEqual(
1612+
numericCast(test.expectedDistance),
1613+
d, stackTrace: SourceLocStack().with(test.loc))
16131614
}
16141615

16151616
self.test("\(testNamePrefix)/index(_:offsetBy: n)/semantics")
1616-
.forEach(in: indexOffsetByTests.filter(
1617-
{$0.limit == nil && $0.distance >= 0}
1618-
)) { (test) in
1619-
let max = 10
1620-
let c = toCollection(0..<max)
1621-
1622-
if test.expectedOffset! >= max {
1623-
expectCrashLater()
1624-
}
1625-
let new = c.index(
1626-
c.nthIndex(test.startOffset),
1627-
offsetBy: numericCast(test.distance))
1628-
1629-
// Since the `nthIndex(offset:)` method performs the same operation
1630-
// (i.e. advances `c.startIndex` by `test.distance`, it would be
1631-
// silly to compare index values. Luckily the underlying collection
1632-
// contains exactly index offsets.
1633-
expectEqual(test.expectedOffset!, extractValue(c[new]).value,
1634-
stackTrace: SourceLocStack().with(test.loc))
1617+
.forEach(
1618+
in: indexOffsetByTests.filter { $0.limit == nil && $0.distance >= 0 }
1619+
) {
1620+
test in
1621+
let max = 10
1622+
let c = toCollection(0..<max)
1623+
1624+
if test.expectedOffset! >= max {
1625+
expectCrashLater()
1626+
}
1627+
let new = c.index(
1628+
c.nthIndex(test.startOffset),
1629+
offsetBy: numericCast(test.distance))
1630+
1631+
// Since the `nthIndex(offset:)` method performs the same operation
1632+
// (i.e. advances `c.startIndex` by `test.distance`, it would be
1633+
// silly to compare index values. Luckily the underlying collection
1634+
// contains exactly index offsets.
1635+
expectEqual(test.expectedOffset!, extractValue(c[new]).value,
1636+
stackTrace: SourceLocStack().with(test.loc))
16351637
}
16361638

16371639
self.test("\(testNamePrefix)/formIndex(_:offsetBy: n)/semantics")
1638-
.forEach(in: indexOffsetByTests.filter(
1639-
{$0.limit == nil && $0.distance >= 0}
1640-
)) { (test) in
1641-
let max = 10
1642-
let c = toCollection(0..<max)
1640+
.forEach(
1641+
in: indexOffsetByTests.filter { $0.limit == nil && $0.distance >= 0 }
1642+
) {
1643+
test in
1644+
let max = 10
1645+
let c = toCollection(0..<max)
16431646

1644-
var new = c.nthIndex(test.startOffset)
1647+
var new = c.nthIndex(test.startOffset)
16451648

1646-
if test.expectedOffset! >= max {
1647-
expectCrashLater()
1648-
}
1649-
c.formIndex(&new, offsetBy: numericCast(test.distance))
1650-
expectEqual(test.expectedOffset!, extractValue(c[new]).value,
1651-
stackTrace: SourceLocStack().with(test.loc))
1649+
if test.expectedOffset! >= max {
1650+
expectCrashLater()
1651+
}
1652+
c.formIndex(&new, offsetBy: numericCast(test.distance))
1653+
expectEqual(test.expectedOffset!, extractValue(c[new]).value,
1654+
stackTrace: SourceLocStack().with(test.loc))
16521655
}
16531656

16541657
% for function_name in ['index', 'formIndex']:
16551658
self.test("\(testNamePrefix)/${function_name}(_:offsetBy: -n)/semantics")
1656-
.forEach(in: indexOffsetByTests.filter(
1657-
{$0.limit == nil && $0.distance < 0}
1658-
)) { (test) in
1659-
let c = toCollection(0..<20)
1659+
.forEach(
1660+
in: indexOffsetByTests.filter { $0.limit == nil && $0.distance < 0 }
1661+
) {
1662+
test in
1663+
let c = toCollection(0..<20)
16601664
% if function_name is 'index':
1661-
let start = c.nthIndex(test.startOffset)
1665+
let start = c.nthIndex(test.startOffset)
16621666
% else:
1663-
var new = c.nthIndex(test.startOffset)
1667+
var new = c.nthIndex(test.startOffset)
16641668
% end
16651669

1666-
if test.expectedOffset! < 0 || !collectionIsBidirectional {
1667-
expectCrashLater()
1668-
}
1670+
if test.expectedOffset! < 0 || !collectionIsBidirectional {
1671+
expectCrashLater()
1672+
}
16691673
% if function_name is 'index':
1670-
let new = c.index(start, offsetBy: numericCast(test.distance))
1674+
let new = c.index(start, offsetBy: numericCast(test.distance))
16711675
% else:
1672-
c.formIndex(&new, offsetBy: numericCast(test.distance))
1676+
c.formIndex(&new, offsetBy: numericCast(test.distance))
16731677
% end
1674-
expectEqual(test.expectedOffset!, extractValue(c[new]).value,
1675-
stackTrace: SourceLocStack().with(test.loc))
1678+
expectEqual(test.expectedOffset!, extractValue(c[new]).value,
1679+
stackTrace: SourceLocStack().with(test.loc))
16761680
}
16771681
% end
16781682

@@ -1716,55 +1720,57 @@ extension TestSuite {
17161720
}
17171721

17181722
self.test("\(testNamePrefix)/index(_:offsetBy: -n, limitedBy:)/semantics")
1719-
.forEach(in: indexOffsetByTests.filter(
1720-
{$0.limit != nil && $0.distance < 0}
1721-
)) { (test) in
1722-
let c = toCollection(0..<20)
1723-
let limit = c.nthIndex(test.limit.unsafelyUnwrapped)
1724-
if collectionIsBidirectional {
1725-
let new = c.index(
1726-
c.nthIndex(test.startOffset),
1727-
offsetBy: numericCast(test.distance),
1728-
limitedBy: limit)
1729-
if let expectedOffset = test.expectedOffset {
1730-
expectEqual(c.nthIndex(expectedOffset), new!,
1731-
stackTrace: SourceLocStack().with(test.loc))
1732-
} else {
1733-
expectEmpty(new)
1734-
}
1723+
.forEach(
1724+
in: indexOffsetByTests.filter { $0.limit != nil && $0.distance < 0 }
1725+
) {
1726+
test in
1727+
let c = toCollection(0..<20)
1728+
let limit = c.nthIndex(test.limit.unsafelyUnwrapped)
1729+
if collectionIsBidirectional {
1730+
let new = c.index(
1731+
c.nthIndex(test.startOffset),
1732+
offsetBy: numericCast(test.distance),
1733+
limitedBy: limit)
1734+
if let expectedOffset = test.expectedOffset {
1735+
expectEqual(c.nthIndex(expectedOffset), new!,
1736+
stackTrace: SourceLocStack().with(test.loc))
17351737
} else {
1736-
expectCrashLater()
1737-
_ = c.index(
1738-
c.nthIndex(test.startOffset),
1739-
offsetBy: numericCast(test.distance),
1740-
limitedBy: limit)
1738+
expectEmpty(new)
17411739
}
1740+
} else {
1741+
expectCrashLater()
1742+
_ = c.index(
1743+
c.nthIndex(test.startOffset),
1744+
offsetBy: numericCast(test.distance),
1745+
limitedBy: limit)
1746+
}
17421747
}
17431748

17441749
self.test("\(testNamePrefix)/formIndex(_:offsetBy: -n, limitedBy:)/semantics")
1745-
.forEach(in: indexOffsetByTests.filter(
1746-
{$0.limit != nil && $0.distance < 0}
1747-
)) { (test) in
1748-
let c = toCollection(0..<20)
1749-
let limit = c.nthIndex(test.limit.unsafelyUnwrapped)
1750-
var new = c.nthIndex(test.startOffset)
1751-
if collectionIsBidirectional {
1752-
let exact = c.formIndex(
1753-
&new,
1754-
offsetBy: numericCast(test.distance),
1755-
limitedBy: limit)
1756-
if let expectedOffset = test.expectedOffset {
1757-
expectEqual(c.nthIndex(expectedOffset), new,
1758-
stackTrace: SourceLocStack().with(test.loc))
1759-
expectTrue(exact, stackTrace: SourceLocStack().with(test.loc))
1760-
} else {
1761-
expectEqual(limit, new, stackTrace: SourceLocStack().with(test.loc))
1762-
expectFalse(exact, stackTrace: SourceLocStack().with(test.loc))
1763-
}
1750+
.forEach(
1751+
in: indexOffsetByTests.filter { $0.limit != nil && $0.distance < 0 }
1752+
) {
1753+
test in
1754+
let c = toCollection(0..<20)
1755+
let limit = c.nthIndex(test.limit.unsafelyUnwrapped)
1756+
var new = c.nthIndex(test.startOffset)
1757+
if collectionIsBidirectional {
1758+
let exact = c.formIndex(
1759+
&new,
1760+
offsetBy: numericCast(test.distance),
1761+
limitedBy: limit)
1762+
if let expectedOffset = test.expectedOffset {
1763+
expectEqual(c.nthIndex(expectedOffset), new,
1764+
stackTrace: SourceLocStack().with(test.loc))
1765+
expectTrue(exact, stackTrace: SourceLocStack().with(test.loc))
17641766
} else {
1765-
expectCrashLater()
1766-
_ = c.formIndex(&new, offsetBy: numericCast(test.distance), limitedBy: limit)
1767+
expectEqual(limit, new, stackTrace: SourceLocStack().with(test.loc))
1768+
expectFalse(exact, stackTrace: SourceLocStack().with(test.loc))
17671769
}
1770+
} else {
1771+
expectCrashLater()
1772+
_ = c.formIndex(&new, offsetBy: numericCast(test.distance), limitedBy: limit)
1773+
}
17681774
}
17691775

17701776
}

0 commit comments

Comments
 (0)