@@ -409,81 +409,67 @@ PrintTests.test("floating point printing") {
409
409
#endif
410
410
}
411
411
412
- func test_BoolPrinting( ) {
413
- printedIs ( Bool ( true ) , " true " )
414
- printedIs ( Bool ( false ) , " false " )
415
-
416
- printedIs ( true , " true " )
417
- printedIs ( false , " false " )
418
-
419
- print ( " test_BoolPrinting done " )
420
- }
421
- test_BoolPrinting ( )
422
- // CHECK: test_BoolPrinting done
423
-
424
- func test_CTypesPrinting( ) {
425
- printedIs ( CChar ( 42 ) , " 42 " )
426
- printedIs ( CUnsignedChar ( 42 ) , " 42 " )
427
- printedIs ( CUnsignedShort ( 42 ) , " 42 " )
428
- printedIs ( CUnsignedInt ( 42 ) , " 42 " )
429
- printedIs ( CUnsignedLong ( 42 ) , " 42 " )
430
- printedIs ( CUnsignedLongLong ( 42 ) , " 42 " )
431
- printedIs ( CSignedChar ( 42 ) , " 42 " )
432
- printedIs ( CShort ( 42 ) , " 42 " )
433
- printedIs ( CInt ( 42 ) , " 42 " )
434
- printedIs ( CLong ( 42 ) , " 42 " )
435
- printedIs ( CLongLong ( 42 ) , " 42 " )
436
- printedIs ( CFloat ( 1.0 ) , " 1.0 " )
437
- printedIs ( CFloat ( - 1.0 ) , " -1.0 " )
438
- printedIs ( CDouble ( 1.0 ) , " 1.0 " )
439
- printedIs ( CDouble ( - 1.0 ) , " -1.0 " )
440
-
441
- printedIs ( CWideChar ( 42 ) , " * " )
442
- printedIs ( CChar16 ( 42 ) , " 42 " )
443
- printedIs ( CChar32 ( 42 ) , " * " )
444
- printedIs ( CBool ( true ) , " true " )
445
- printedIs ( CBool ( false ) , " false " )
446
-
447
- print ( " test_CTypesPrinting done " )
448
- }
449
- test_CTypesPrinting ( )
450
- // CHECK: test_CTypesPrinting done
451
-
452
-
453
- func test_PointerPrinting( ) {
454
- let nullUP = UnsafeMutablePointer < Float > ( )
455
- let fourByteUP = UnsafeMutablePointer < Float > ( bitPattern: 0xabcd1234 as UInt )
456
-
457
- #if !(arch(i386) || arch(arm))
458
- let eightByteAddr : UInt = 0xabcddcba12344321
459
- let eightByteUP = UnsafeMutablePointer < Float > ( bitPattern: eightByteAddr)
460
- #endif
461
-
462
- #if arch(i386) || arch(arm)
463
- let expectedNull = " 0x00000000 "
464
- printedIs ( fourByteUP, " 0xabcd1234 " )
465
- #else
466
- let expectedNull = " 0x0000000000000000 "
467
- printedIs ( fourByteUP, " 0x00000000abcd1234 " )
468
- printedIs ( eightByteUP, " 0xabcddcba12344321 " )
469
- #endif
470
-
471
- printedIs ( nullUP, expectedNull)
472
-
473
- printedIs ( UnsafeBufferPointer ( start: nullUP, count: 0 ) ,
474
- " UnsafeBufferPointer(start: \( expectedNull) , length: 0) " )
475
- printedIs ( UnsafeMutableBufferPointer ( start: nullUP, count: 0 ) ,
476
- " UnsafeMutableBufferPointer(start: \( expectedNull) , length: 0) " )
477
-
478
- printedIs ( COpaquePointer ( ) , expectedNull)
479
- printedIs ( CVaListPointer ( _fromUnsafeMutablePointer: nullUP) , expectedNull)
480
- printedIs ( AutoreleasingUnsafeMutablePointer < Int > ( ) , expectedNull)
412
+ PrintTests . test ( " bool printing " ) {
413
+ expectPrinted ( " true " , Bool ( true ) )
414
+ expectPrinted ( " false " , Bool ( false ) )
415
+
416
+ expectPrinted ( " true " , true )
417
+ expectPrinted ( " false " , false )
418
+ }
481
419
482
- print ( " test_PointerPrinting done " )
420
+ PrintTests . test ( " ctypes printing " ) {
421
+ expectPrinted ( " 42 " , CChar ( 42 ) )
422
+ expectPrinted ( " 42 " , CUnsignedChar ( 42 ) )
423
+ expectPrinted ( " 42 " , CUnsignedShort ( 42 ) )
424
+ expectPrinted ( " 42 " , CUnsignedInt ( 42 ) )
425
+ expectPrinted ( " 42 " , CUnsignedLong ( 42 ) )
426
+ expectPrinted ( " 42 " , CUnsignedLongLong ( 42 ) )
427
+ expectPrinted ( " 42 " , CSignedChar ( 42 ) )
428
+ expectPrinted ( " 42 " , CShort ( 42 ) )
429
+ expectPrinted ( " 42 " , CInt ( 42 ) )
430
+ expectPrinted ( " 42 " , CLong ( 42 ) )
431
+ expectPrinted ( " 42 " , CLongLong ( 42 ) )
432
+ expectPrinted ( " 1.0 " , CFloat ( 1.0 ) )
433
+ expectPrinted ( " -1.0 " , CFloat ( - 1.0 ) )
434
+ expectPrinted ( " 1.0 " , CDouble ( 1.0 ) )
435
+ expectPrinted ( " -1.0 " , CDouble ( - 1.0 ) )
436
+
437
+ expectPrinted ( " * " , CWideChar ( 42 ) )
438
+ expectPrinted ( " 42 " , CChar16 ( 42 ) )
439
+ expectPrinted ( " * " , CChar32 ( 42 ) )
440
+ expectPrinted ( " true " , CBool ( true ) )
441
+ expectPrinted ( " false " , CBool ( false ) )
483
442
}
484
- test_PointerPrinting ( )
485
- // CHECK: test_PointerPrinting done
486
443
444
+ PrintTests . test ( " pointer printing " ) {
445
+ let nullUP = UnsafeMutablePointer < Float > ( )
446
+ let fourByteUP = UnsafeMutablePointer < Float > ( bitPattern: 0xabcd1234 as UInt )
447
+
448
+ #if !(arch(i386) || arch(arm))
449
+ let eightByteAddr : UInt = 0xabcddcba12344321
450
+ let eightByteUP = UnsafeMutablePointer < Float > ( bitPattern: eightByteAddr)
451
+ #endif
452
+
453
+ #if arch(i386) || arch(arm)
454
+ let expectedNull = " 0x00000000 "
455
+ expectPrinted ( " 0xabcd1234 " , fourByteUP)
456
+ #else
457
+ let expectedNull = " 0x0000000000000000 "
458
+ expectPrinted ( " 0x00000000abcd1234 " , fourByteUP)
459
+ expectPrinted ( " 0xabcddcba12344321 " , eightByteUP)
460
+ #endif
461
+
462
+ expectPrinted ( expectedNull, nullUP)
463
+
464
+ expectPrinted ( " UnsafeBufferPointer(start: \( expectedNull) , length: 0) " ,
465
+ UnsafeBufferPointer ( start: nullUP, count: 0 ) )
466
+ expectPrinted ( " UnsafeMutableBufferPointer(start: \( expectedNull) , length: 0) " ,
467
+ UnsafeMutableBufferPointer ( start: nullUP, count: 0 ) )
468
+
469
+ expectPrinted ( expectedNull, COpaquePointer ( ) )
470
+ expectPrinted ( expectedNull, CVaListPointer ( _fromUnsafeMutablePointer: nullUP) )
471
+ expectPrinted ( expectedNull, AutoreleasingUnsafeMutablePointer < Int > ( ) )
472
+ }
487
473
488
474
protocol ProtocolUnrelatedToPrinting { }
489
475
@@ -596,104 +582,71 @@ class ClassVeryPrintable : CustomStringConvertible, CustomDebugStringConvertible
596
582
}
597
583
}
598
584
599
- func test_ObjectPrinting( ) {
600
- do {
601
- let s = StructPrintable ( 1 )
602
- printedIs ( s, " ►1◀︎ " )
603
- }
604
- do {
605
- let s : ProtocolUnrelatedToPrinting = StructPrintable ( 1 )
606
- printedIs ( s, " ►1◀︎ " )
607
- }
608
- do {
609
- let s : CustomStringConvertible = StructPrintable ( 1 )
610
- printedIs ( s, " ►1◀︎ " )
611
- }
612
- do {
613
- let s : Any = StructPrintable ( 1 )
614
- printedIs ( s, " ►1◀︎ " )
615
- }
616
-
617
- do {
618
- let s = LargeStructPrintable ( 10 , 20 , 30 , 40 )
619
- printedIs ( s, " <10 20 30 40> " )
620
- }
621
- do {
622
- let s : ProtocolUnrelatedToPrinting = LargeStructPrintable ( 10 , 20 , 30 , 40 )
623
- printedIs ( s, " <10 20 30 40> " )
624
- }
625
- do {
626
- let s : CustomStringConvertible = LargeStructPrintable ( 10 , 20 , 30 , 40 )
627
- printedIs ( s, " <10 20 30 40> " )
628
- }
629
- do {
630
- let s : Any = LargeStructPrintable ( 10 , 20 , 30 , 40 )
631
- printedIs ( s, " <10 20 30 40> " )
632
- }
585
+ PrintTests . test ( " StructPrintable " ) {
586
+ let s0 = StructPrintable ( 1 )
587
+ let s1 : ProtocolUnrelatedToPrinting = StructPrintable ( 1 )
588
+ let s2 : CustomStringConvertible = StructPrintable ( 1 )
589
+ let s3 : Any = StructPrintable ( 1 )
590
+
591
+ expectPrinted ( " ►1◀︎ " , s0)
592
+ expectPrinted ( " ►1◀︎ " , s1)
593
+ expectPrinted ( " ►1◀︎ " , s2)
594
+ expectPrinted ( " ►1◀︎ " , s3)
595
+ }
633
596
634
- do {
635
- let s = StructVeryPrintable ( 1 )
636
- printedIs ( s, " <description: 1> " )
637
- }
638
- do {
639
- let s : ProtocolUnrelatedToPrinting = StructVeryPrintable ( 1 )
640
- printedIs ( s, " <description: 1> " )
641
- }
642
- do {
643
- let s : CustomStringConvertible = StructVeryPrintable ( 1 )
644
- printedIs ( s, " <description: 1> " )
645
- }
646
- do {
647
- let s : CustomDebugStringConvertible = StructVeryPrintable ( 1 )
648
- printedIs ( s, " <description: 1> " )
649
- }
650
- do {
651
- let s : Any = StructVeryPrintable ( 1 )
652
- printedIs ( s, " <description: 1> " )
653
- }
597
+ PrintTests . test ( " LargeStructPrintable " ) {
598
+ let s0 = LargeStructPrintable ( 10 , 20 , 30 , 40 )
599
+ let s1 : ProtocolUnrelatedToPrinting = LargeStructPrintable ( 10 , 20 , 30 , 40 )
600
+ let s2 : CustomStringConvertible = LargeStructPrintable ( 10 , 20 , 30 , 40 )
601
+ let s3 : Any = LargeStructPrintable ( 10 , 20 , 30 , 40 )
654
602
655
- do {
656
- let c = ClassPrintable ( 1 )
657
- printedIs ( c, " ►1◀︎ " )
658
- }
659
- do {
660
- let c : ProtocolUnrelatedToPrinting = ClassPrintable ( 1 )
661
- printedIs ( c, " ►1◀︎ " )
662
- }
663
- do {
664
- let c : CustomStringConvertible = ClassPrintable ( 1 )
665
- printedIs ( c, " ►1◀︎ " )
666
- }
667
- do {
668
- let c : Any = ClassPrintable ( 1 )
669
- printedIs ( c, " ►1◀︎ " )
670
- }
603
+ expectPrinted ( " <10 20 30 40> " , s0)
604
+ expectPrinted ( " <10 20 30 40> " , s1)
605
+ expectPrinted ( " <10 20 30 40> " , s2)
606
+ expectPrinted ( " <10 20 30 40> " , s0)
607
+ expectPrinted ( " <10 20 30 40> " , s3)
671
608
672
- do {
673
- let c = ClassVeryPrintable ( 1 )
674
- printedIs ( c, " <description: 1> " )
675
- }
676
- do {
677
- let c : ProtocolUnrelatedToPrinting = ClassVeryPrintable ( 1 )
678
- printedIs ( c, " <description: 1> " )
679
- }
680
- do {
681
- let c : CustomStringConvertible = ClassVeryPrintable ( 1 )
682
- printedIs ( c, " <description: 1> " )
683
- }
684
- do {
685
- let c : CustomDebugStringConvertible = ClassVeryPrintable ( 1 )
686
- printedIs ( c, " <description: 1> " )
687
- }
688
- do {
689
- let c : Any = ClassVeryPrintable ( 1 )
690
- printedIs ( c, " <description: 1> " )
691
- }
609
+ }
692
610
693
- print ( " test_ObjectPrinting done " )
611
+ PrintTests . test ( " StructVeryPrintable " ) {
612
+ let s0 = StructVeryPrintable ( 1 )
613
+ let s1 : ProtocolUnrelatedToPrinting = StructVeryPrintable ( 1 )
614
+ let s2 : CustomStringConvertible = StructVeryPrintable ( 1 )
615
+ let s3 : CustomDebugStringConvertible = StructVeryPrintable ( 1 )
616
+ let s4 : Any = StructVeryPrintable ( 1 )
617
+
618
+ expectPrinted ( " <description: 1> " , s0)
619
+ expectPrinted ( " <description: 1> " , s1)
620
+ expectPrinted ( " <description: 1> " , s2)
621
+ expectPrinted ( " <description: 1> " , s3)
622
+ expectPrinted ( " <description: 1> " , s4)
623
+ }
624
+
625
+ PrintTests . test ( " ClassPrintable " ) {
626
+ let c0 = ClassPrintable ( 1 )
627
+ let c1 : ProtocolUnrelatedToPrinting = ClassPrintable ( 1 )
628
+ let c2 : CustomStringConvertible = ClassPrintable ( 1 )
629
+ let c3 : Any = ClassPrintable ( 1 )
630
+
631
+ expectPrinted ( " ►1◀︎ " , c0)
632
+ expectPrinted ( " ►1◀︎ " , c1)
633
+ expectPrinted ( " ►1◀︎ " , c2)
634
+ expectPrinted ( " ►1◀︎ " , c3)
635
+ }
636
+
637
+ PrintTests . test ( " ClassVeryPrintable " ) {
638
+ let c0 = ClassVeryPrintable ( 1 )
639
+ let c1 : ProtocolUnrelatedToPrinting = ClassVeryPrintable ( 1 )
640
+ let c2 : CustomStringConvertible = ClassVeryPrintable ( 1 )
641
+ let c3 : CustomDebugStringConvertible = ClassVeryPrintable ( 1 )
642
+ let c4 : Any = ClassVeryPrintable ( 1 )
643
+
644
+ expectPrinted ( " <description: 1> " , c0)
645
+ expectPrinted ( " <description: 1> " , c1)
646
+ expectPrinted ( " <description: 1> " , c2)
647
+ expectPrinted ( " <description: 1> " , c3)
648
+ expectPrinted ( " <description: 1> " , c4)
694
649
}
695
- test_ObjectPrinting ( )
696
- // CHECK: test_ObjectPrinting done
697
650
698
651
func test_ThickMetatypePrintingImpl< T> (
699
652
thickMetatype: T . Type ,
0 commit comments