Skip to content

Commit 967a5ef

Browse files
committed
Rewrite part swiftlang#4 of file with StdlibUnittest
1 parent dfe3ab5 commit 967a5ef

File tree

1 file changed

+27
-33
lines changed

1 file changed

+27
-33
lines changed

test/1_stdlib/Print.swift

Lines changed: 27 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -582,6 +582,17 @@ class ClassVeryPrintable : CustomStringConvertible, CustomDebugStringConvertible
582582
}
583583
}
584584

585+
func test_ThickMetatypePrintingImpl<T>(
586+
thickMetatype: T.Type,
587+
_ expectedPrint: String,
588+
_ expectedDebug: String
589+
) {
590+
expectPrinted(expectedPrint, thickMetatype)
591+
expectPrinted("[\(expectedDebug)]", [ thickMetatype ])
592+
expectDebugPrinted(expectedDebug, thickMetatype)
593+
expectDebugPrinted("[\(expectedDebug)]", [ thickMetatype ])
594+
}
595+
585596
PrintTests.test("StructPrintable") {
586597
let s0 = StructPrintable(1)
587598
let s1: ProtocolUnrelatedToPrinting = StructPrintable(1)
@@ -592,6 +603,14 @@ PrintTests.test("StructPrintable") {
592603
expectPrinted("►1◀︎", s1)
593604
expectPrinted("►1◀︎", s2)
594605
expectPrinted("►1◀︎", s3)
606+
607+
let structMetatype = StructPrintable.self
608+
expectPrinted("StructPrintable", structMetatype)
609+
expectDebugPrinted("a.StructPrintable", structMetatype)
610+
expectPrinted("[a.StructPrintable]", [ structMetatype ])
611+
expectDebugPrinted("[a.StructPrintable]", [ structMetatype ])
612+
test_ThickMetatypePrintingImpl(structMetatype, "StructPrintable",
613+
"a.StructPrintable")
595614
}
596615

597616
PrintTests.test("LargeStructPrintable") {
@@ -632,6 +651,14 @@ PrintTests.test("ClassPrintable") {
632651
expectPrinted("►1◀︎", c1)
633652
expectPrinted("►1◀︎", c2)
634653
expectPrinted("►1◀︎", c3)
654+
655+
let classMetatype = ClassPrintable.self
656+
expectPrinted("ClassPrintable", classMetatype)
657+
expectDebugPrinted("a.ClassPrintable", classMetatype)
658+
expectPrinted("[a.ClassPrintable]", [ classMetatype ])
659+
expectDebugPrinted("[a.ClassPrintable]", [ classMetatype ])
660+
test_ThickMetatypePrintingImpl(classMetatype, "ClassPrintable",
661+
"a.ClassPrintable")
635662
}
636663

637664
PrintTests.test("ClassVeryPrintable") {
@@ -648,39 +675,6 @@ PrintTests.test("ClassVeryPrintable") {
648675
expectPrinted("<description: 1>", c4)
649676
}
650677

651-
func test_ThickMetatypePrintingImpl<T>(
652-
thickMetatype: T.Type,
653-
_ expectedPrint: String,
654-
_ expectedDebug: String
655-
) {
656-
printedIs(thickMetatype, expectedPrint)
657-
printedIs([ thickMetatype ], "[" + expectedDebug + "]")
658-
debugPrintedIs(thickMetatype, expectedDebug)
659-
debugPrintedIs([ thickMetatype ], "[" + expectedDebug + "]")
660-
}
661-
662-
func test_gcMetatypePrinting() {
663-
let structMetatype = StructPrintable.self
664-
printedIs(structMetatype, "StructPrintable")
665-
debugPrintedIs(structMetatype, "a.StructPrintable")
666-
printedIs([ structMetatype ], "[a.StructPrintable]")
667-
debugPrintedIs([ structMetatype ], "[a.StructPrintable]")
668-
test_ThickMetatypePrintingImpl(structMetatype, "StructPrintable",
669-
"a.StructPrintable")
670-
671-
let classMetatype = ClassPrintable.self
672-
printedIs(classMetatype, "ClassPrintable")
673-
debugPrintedIs(classMetatype, "a.ClassPrintable")
674-
printedIs([ classMetatype ], "[a.ClassPrintable]")
675-
debugPrintedIs([ classMetatype ], "[a.ClassPrintable]")
676-
test_ThickMetatypePrintingImpl(classMetatype, "ClassPrintable",
677-
"a.ClassPrintable")
678-
679-
print("test_gcMetatypePrinting done")
680-
}
681-
test_gcMetatypePrinting()
682-
// CHECK: test_gcMetatypePrinting done
683-
684678
func test_ArrayPrinting() {
685679
let arrayOfInts: [Int] = []
686680
printedIs(arrayOfInts, "[]")

0 commit comments

Comments
 (0)