Files
swift-mirror/test/stdlib/PrintArray.swift
2016-09-01 16:51:43 -07:00

38 lines
1.3 KiB
Swift
Raw Blame History

This file contains invisible Unicode characters
This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
// RUN: rm -rf %t && mkdir %t
// RUN: %target-build-swift -c -force-single-frontend-invocation -parse-as-library -emit-module -emit-module-path %t/PrintTestTypes.swiftmodule -o %t/PrintTestTypes.o %S/Inputs/PrintTestTypes.swift
// RUN: %target-build-swift %s -Xlinker %t/PrintTestTypes.o -I %t -L %t -o %t/main
// RUN: %target-run %t/main
// REQUIRES: executable_test
import StdlibUnittest
import PrintTestTypes
let PrintTests = TestSuite("PrintArray")
PrintTests.test("Printable") {
expectPrinted("[]", [Int]())
expectPrinted("[1]", [ 1 ])
expectPrinted("[1, 2]", [ 1, 2 ])
expectPrinted("[1, 2, 3]", [ 1, 2, 3 ])
expectPrinted("[\"foo\", \"bar\", \"bas\"]", ["foo", "bar", "bas"])
expectDebugPrinted("[\"foo\", \"bar\", \"bas\"]", ["foo", "bar", "bas"])
expectPrinted("[►1◀, ►2◀, ►3◀]", [StructPrintable(1),
StructPrintable(2), StructPrintable(3)])
expectPrinted("[<10 20 30 40>, <50 60 70 80>]",
[LargeStructPrintable(10, 20, 30, 40), LargeStructPrintable(50, 60, 70, 80)])
expectPrinted("[►1◀]", [StructDebugPrintable(1)])
expectPrinted("[►1◀, ►2◀, ►3◀]", [ClassPrintable(1),
ClassPrintable(2), ClassPrintable(3)])
expectPrinted("[►1◀, ►2◀, ►3◀]", [ClassPrintable(1),
ClassPrintable(2), ClassPrintable(3)] as Array<AnyObject>)
}
runAllTests()