...

Source file src/runtime/testdata/testprog/panicprint.go

Documentation: runtime/testdata/testprog

     1  // Copyright 2020 The Go Authors. All rights reserved.
     2  // Use of this source code is governed by a BSD-style
     3  // license that can be found in the LICENSE file.
     4  
     5  package main
     6  
     7  type MyBool bool
     8  type MyComplex128 complex128
     9  type MyComplex64 complex64
    10  type MyFloat32 float32
    11  type MyFloat64 float64
    12  type MyInt int
    13  type MyInt8 int8
    14  type MyInt16 int16
    15  type MyInt32 int32
    16  type MyInt64 int64
    17  type MyString string
    18  type MyUint uint
    19  type MyUint8 uint8
    20  type MyUint16 uint16
    21  type MyUint32 uint32
    22  type MyUint64 uint64
    23  type MyUintptr uintptr
    24  
    25  func panicCustomComplex64() {
    26  	panic(MyComplex64(0.11 + 3i))
    27  }
    28  
    29  func panicCustomComplex128() {
    30  	panic(MyComplex128(32.1 + 10i))
    31  }
    32  
    33  func panicCustomString() {
    34  	panic(MyString("Panic\nline two"))
    35  }
    36  
    37  func panicCustomBool() {
    38  	panic(MyBool(true))
    39  }
    40  
    41  func panicCustomInt() {
    42  	panic(MyInt(93))
    43  }
    44  
    45  func panicCustomInt8() {
    46  	panic(MyInt8(93))
    47  }
    48  
    49  func panicCustomInt16() {
    50  	panic(MyInt16(93))
    51  }
    52  
    53  func panicCustomInt32() {
    54  	panic(MyInt32(93))
    55  }
    56  
    57  func panicCustomInt64() {
    58  	panic(MyInt64(93))
    59  }
    60  
    61  func panicCustomUint() {
    62  	panic(MyUint(93))
    63  }
    64  
    65  func panicCustomUint8() {
    66  	panic(MyUint8(93))
    67  }
    68  
    69  func panicCustomUint16() {
    70  	panic(MyUint16(93))
    71  }
    72  
    73  func panicCustomUint32() {
    74  	panic(MyUint32(93))
    75  }
    76  
    77  func panicCustomUint64() {
    78  	panic(MyUint64(93))
    79  }
    80  
    81  func panicCustomUintptr() {
    82  	panic(MyUintptr(93))
    83  }
    84  
    85  func panicCustomFloat64() {
    86  	panic(MyFloat64(-93.70))
    87  }
    88  
    89  func panicCustomFloat32() {
    90  	panic(MyFloat32(-93.70))
    91  }
    92  
    93  func init() {
    94  	register("panicCustomComplex64", panicCustomComplex64)
    95  	register("panicCustomComplex128", panicCustomComplex128)
    96  	register("panicCustomBool", panicCustomBool)
    97  	register("panicCustomFloat32", panicCustomFloat32)
    98  	register("panicCustomFloat64", panicCustomFloat64)
    99  	register("panicCustomInt", panicCustomInt)
   100  	register("panicCustomInt8", panicCustomInt8)
   101  	register("panicCustomInt16", panicCustomInt16)
   102  	register("panicCustomInt32", panicCustomInt32)
   103  	register("panicCustomInt64", panicCustomInt64)
   104  	register("panicCustomString", panicCustomString)
   105  	register("panicCustomUint", panicCustomUint)
   106  	register("panicCustomUint8", panicCustomUint8)
   107  	register("panicCustomUint16", panicCustomUint16)
   108  	register("panicCustomUint32", panicCustomUint32)
   109  	register("panicCustomUint64", panicCustomUint64)
   110  	register("panicCustomUintptr", panicCustomUintptr)
   111  }
   112  

View as plain text