Skip to content

Commit c099c1a

Browse files
author
Dave Abrahams
committed
[stdlib] More precise testing for traps
Let's only detect the traps we're really interested in.
1 parent 4e4480a commit c099c1a

File tree

1 file changed

+4
-6
lines changed

1 file changed

+4
-6
lines changed

Diff for: validation-test/stdlib/Index.swift.gyb

+4-6
Original file line numberDiff line numberDiff line change
@@ -149,8 +149,9 @@ Index.test("${Kind}Collection/index(_:stepsFrom: n)/semantics") {
149149
Index.test("${Kind}Collection/index(_:stepsFrom: -n)/semantics") {
150150
for test in indexStepsFromTests.filter({$0.limit == nil && $0.distance < 0}) {
151151
let c = ${Kind}Collection(elements: Array(0..<10))
152+
let start = c.nthIndex(test.startOffset)
152153
expectCrashLater()
153-
_ = c.location(c.nthIndex(test.startOffset), offsetBy: test.distance)
154+
_ = c.location(start, offsetBy: test.distance)
154155
}
155156
}
156157
% end
@@ -160,12 +161,9 @@ Index.test("${Kind}Collection/advance(by: -n, limitedBy:)/semantics") {
160161
for test in indexStepsFromTests.filter({$0.limit != nil && $0.distance < 0}) {
161162
let c = ${Kind}Collection(elements: Array(0..<10))
162163
let limit = c.nthIndex(test.limit.unsafelyUnwrapped)
163-
164+
let start = c.nthIndex(test.startOffset)
164165
expectCrashLater()
165-
_ = c.location(
166-
c.nthIndex(test.startOffset),
167-
offsetBy: test.distance,
168-
limitedBy: limit)
166+
_ = c.location(start, offsetBy: test.distance, limitedBy: limit)
169167
}
170168
}
171169
% end

0 commit comments

Comments
 (0)