Skip to content

Commit 21871af

Browse files
committed
Merge pull request #1758 from frootloops/master
Rewrite ArrayCore tests
2 parents e2a825a + 50876e1 commit 21871af

File tree

1 file changed

+16
-33
lines changed

1 file changed

+16
-33
lines changed

test/1_stdlib/ArrayCore.swift

Lines changed: 16 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,10 @@
99
// See http://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
1010
//
1111
//===----------------------------------------------------------------------===//
12-
// RUN: %target-run-stdlib-swift | FileCheck %s
12+
// RUN: %target-run-simple-swift
1313
// REQUIRES: executable_test
1414

15+
import StdlibUnittest
1516
import Swift
1617

1718
//===--- class Tracked ----------------------------------------------------===//
@@ -81,40 +82,22 @@ struct MrMcRange : Collection {
8182
var base: Base
8283
}
8384

84-
func printSequence<T : Sequence>(x: T) {
85-
print("<", terminator: "")
86-
var prefix = ""
87-
for a in x {
88-
print(prefix, terminator: "")
89-
print(a, terminator: "")
90-
prefix = " "
91-
}
92-
print(">")
93-
}
94-
95-
96-
97-
// CHECK: testing...
98-
print("testing...")
85+
let ArrayCoreTests = TestSuite("ArrayCore")
9986

100-
func test() {
101-
//===--- Sequences can be converted -------------------------------------===//
102-
103-
let n0 = ((Tracked(10)..<Tracked(27)).makeIterator())._copyToNativeArrayBuffer()
104-
// CHECK-NEXT: <10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26>
105-
printSequence(n0)
106-
107-
//===--- Collections get measured ---------------------------------------===//
87+
ArrayCoreTests.test("Sequences can be converted") {
88+
let n = ((Tracked(10)..<Tracked(27)).makeIterator())._copyToNativeArrayBuffer()
89+
let out = n.map { "\($0)" }.joined(separator: " ")
90+
expectPrinted("10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26", out)
91+
}
10892

109-
// CHECK-NEXT: using collection API
110-
let n1 = MrMcRange(3..<23)._copyToNativeArrayBuffer()
111-
// CHECK: <3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22>
112-
printSequence(n1)
93+
ArrayCoreTests.test("Collections get measured") {
94+
let n = MrMcRange(3..<23)._copyToNativeArrayBuffer()
95+
let out = n.map { "\($0)" }.joined(separator: " ")
96+
expectPrinted("3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22", out)
11397
}
114-
test()
11598

116-
// CHECK-NEXT: trackedCount = 0
117-
print("trackedCount = \(trackedCount)")
99+
ArrayCoreTests.test("Check trackedCount") {
100+
expectEqual(0, trackedCount)
101+
}
118102

119-
// CHECK-NEXT: done.
120-
print("done.")
103+
runAllTests()

0 commit comments

Comments
 (0)