Skip to content

Commit

Permalink
Rewrite part swiftlang#5 of file with StdlibUnittest
Browse files Browse the repository at this point in the history
  • Loading branch information
frootloops committed Dec 24, 2015
1 parent 967a5ef commit ceb1ba7
Showing 1 changed file with 22 additions and 32 deletions.
54 changes: 22 additions & 32 deletions test/1_stdlib/Print.swift
Original file line number Diff line number Diff line change
Expand Up @@ -675,39 +675,29 @@ PrintTests.test("ClassVeryPrintable") {
expectPrinted("<description: 1>", c4)
}

func test_ArrayPrinting() {
let arrayOfInts: [Int] = []
printedIs(arrayOfInts, "[]")

printedIs([ 1 ], "[1]")
printedIs([ 1, 2 ], "[1, 2]")
printedIs([ 1, 2, 3 ], "[1, 2, 3]")

printedIs([ "foo", "bar", "bas" ], "[\"foo\", \"bar\", \"bas\"]")
debugPrintedIs([ "foo", "bar", "bas" ], "[\"foo\", \"bar\", \"bas\"]")

printedIs([ StructPrintable(1), StructPrintable(2),
StructPrintable(3) ],
"[►1◀︎, ►2◀︎, ►3◀︎]")

printedIs([ LargeStructPrintable(10, 20, 30, 40),
LargeStructPrintable(50, 60, 70, 80) ],
"[<10 20 30 40>, <50 60 70 80>]")

printedIs([ StructDebugPrintable(1) ], "[►1◀︎]")

printedIs([ ClassPrintable(1), ClassPrintable(2),
ClassPrintable(3) ],
"[►1◀︎, ►2◀︎, ►3◀︎]")

printedIs([ ClassPrintable(1), ClassPrintable(2),
ClassPrintable(3) ] as Array<AnyObject>,
"[►1◀︎, ►2◀︎, ►3◀︎]")

print("test_ArrayPrinting done")
PrintTests.test("Array") {
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>)
}
test_ArrayPrinting()
// CHECK: test_ArrayPrinting done

func test_DictionaryPrinting() {
var dictSI: Dictionary<String, Int> = [:]
Expand Down

0 comments on commit ceb1ba7

Please sign in to comment.