Skip to content

Rewrite ArrayCore tests #1758

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 21, 2016
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
49 changes: 16 additions & 33 deletions test/1_stdlib/ArrayCore.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,10 @@
// See http://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
//
//===----------------------------------------------------------------------===//
// RUN: %target-run-stdlib-swift | FileCheck %s
// RUN: %target-run-simple-swift
// REQUIRES: executable_test

import StdlibUnittest
import Swift

//===--- class Tracked ----------------------------------------------------===//
Expand Down Expand Up @@ -81,40 +82,22 @@ struct MrMcRange : Collection {
var base: Base
}

func printSequence<T : Sequence>(x: T) {
print("<", terminator: "")
var prefix = ""
for a in x {
print(prefix, terminator: "")
print(a, terminator: "")
prefix = " "
}
print(">")
}



// CHECK: testing...
print("testing...")
let ArrayCoreTests = TestSuite("ArrayCore")

func test() {
//===--- Sequences can be converted -------------------------------------===//

let n0 = ((Tracked(10)..<Tracked(27)).makeIterator())._copyToNativeArrayBuffer()
// CHECK-NEXT: <10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26>
printSequence(n0)

//===--- Collections get measured ---------------------------------------===//
ArrayCoreTests.test("Sequences can be converted") {
let n = ((Tracked(10)..<Tracked(27)).makeIterator())._copyToNativeArrayBuffer()
let out = n.map { "\($0)" }.joined(separator: " ")
expectPrinted("10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26", out)
}

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

// CHECK-NEXT: trackedCount = 0
print("trackedCount = \(trackedCount)")
ArrayCoreTests.test("Check trackedCount") {
expectEqual(0, trackedCount)
}

// CHECK-NEXT: done.
print("done.")
runAllTests()