1/* 2 * Copyright (c) 2024 Huawei Device Co., Ltd. 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15 16function byte_test(): void { 17 let byte_: byte = 42; 18 let Byte_: Byte = new Byte(42 as byte); 19 20 { 21 // Casting to primitive types 22 let byte_byte = byte_ as byte; 23 let byte_short = byte_ as short; 24 let byte_char = byte_ as char; 25 let byte_int = byte_ as int; 26 let byte_long = byte_ as long; 27 let byte_float = byte_ as float; 28 let byte_double = byte_ as double; 29 30 let Byte_byte = Byte_ as byte; 31 let Byte_short = Byte_ as short; 32 let Byte_int = Byte_ as int; 33 let Byte_long = Byte_ as long; 34 let Byte_float = Byte_ as float; 35 let Byte_double = Byte_ as double; 36 } 37 38 { 39 // Casting to reference type 40 let byte_Byte = byte_ as Byte; 41 let Byte_Byte = Byte_ as Byte; 42 let Byte_Object = Byte_ as Object; 43 } 44} 45 46function short_test(): void { 47 let short_: short = 42; 48 let Short_: Short = new Short(42 as short); 49 50 { 51 // Casting to primitive types 52 let short_byte = short_ as byte; 53 let short_short = short_ as short; 54 let short_char = short_ as char; 55 let short_int = short_ as int; 56 let short_long = short_ as long; 57 let short_float = short_ as float; 58 let short_double = short_ as double; 59 60 let Short_short = Short_ as short; 61 let Short_int = Short_ as int; 62 let Short_long = Short_ as long; 63 let Short_float = Short_ as float; 64 let Short_double = Short_ as double; 65 } 66 67 { 68 // Casting to reference type 69 let short_Short = short_ as Short; 70 let Short_Short = Short_ as Short; 71 let Short_Object = Short_ as Object; 72 } 73} 74 75function char_test(): void { 76 let char_: char = 42; 77 let Char_: Char = new Char(42 as char); 78 79 { 80 // Casting to primitive types 81 let char_byte = char_ as byte; 82 let char_short = char_ as short; 83 let char_char = char_ as char; 84 let char_int = char_ as int; 85 let char_long = char_ as long; 86 let char_float = char_ as float; 87 let char_double = char_ as double; 88 89 let Char_char = Char_ as char; 90 let Char_int = Char_ as int; 91 let Char_long = Char_ as long; 92 let Char_float = Char_ as float; 93 let Char_double = Char_ as double; 94 } 95 96 { 97 // Casting to reference type 98 let char_Char = char_ as Char; 99 let Char_Char = Char_ as Char; 100 let Char_Object = Char_ as Object; 101 } 102} 103 104function int_test(): void { 105 let int_: int = 42; 106 let Int_: Int = new Int(42 as int); 107 108 { 109 // Casting to primitive types 110 let int_byte = int_ as byte; 111 let int_short = int_ as short; 112 let int_char = int_ as char; 113 let int_int = int_ as int; 114 let int_long = int_ as long; 115 let int_float = int_ as float; 116 let int_double = int_ as double; 117 118 let Int_int = Int_ as int; 119 let Int_long = Int_ as long; 120 let Int_float = Int_ as float; 121 let Int_double = Int_ as double; 122 } 123 124 { 125 // Casting to reference type 126 let int_Int = int_ as Int; 127 let Int_Int = Int_ as Int; 128 let Int_Object = Int_ as Object; 129 } 130} 131 132function long_test(): void { 133 let long_: long = 42; 134 let Long_: Long = new Long(42 as long); 135 136 { 137 // Casting to primitive types 138 let long_byte = long_ as byte; 139 let long_short = long_ as short; 140 let long_char = long_ as char; 141 let long_int = long_ as int; 142 let long_long = long_ as long; 143 let long_float = long_ as float; 144 let long_double = long_ as double; 145 146 let Long_long = Long_ as long; 147 let Long_float = Long_ as float; 148 let Long_double = Long_ as double; 149 } 150 151 { 152 // Casting to reference type 153 let long_Long = long_ as Long; 154 let Long_Long = Long_ as Long; 155 let Long_Object = Long_ as Object; 156 } 157} 158 159function float_test(): void { 160 let float_: float = 42; 161 let Float_: Float = new Float(42 as float); 162 163 { 164 // Casting to primitive types 165 let float_byte = float_ as byte; 166 let float_short = float_ as short; 167 let float_char = float_ as char; 168 let float_int = float_ as int; 169 let float_long = float_ as long; 170 let float_float = float_ as float; 171 let float_double = float_ as double; 172 173 let Float_float = Float_ as float; 174 let Float_double = Float_ as double; 175 } 176 177 { 178 // Casting to reference type 179 let float_Float = float_ as Float; 180 let Float_Float = Float_ as Float; 181 let Float_Object = Float_ as Object; 182 } 183} 184 185function double_test(): void { 186 let double_: double = 42; 187 let Double_: Double = new Double(42 as double); 188 189 { 190 // Casting to primitive types 191 let double_byte = double_ as byte; 192 let double_short = double_ as short; 193 let double_char = double_ as char; 194 let double_int = double_ as int; 195 let double_long = double_ as long; 196 let double_float = double_ as float; 197 let double_double = double_ as double; 198 199 let Double_double = Double_ as double; 200 } 201 202 { 203 // Casting to reference type 204 let double_Double = double_ as Double; 205 let Double_Double = Double_ as Double; 206 let Double_Object = Double_ as Object; 207 } 208} 209 210function boolean_test(): void { 211 let boolean_: boolean = true; 212 let Boolean_: Boolean = new Boolean(true); 213 214 { 215 // Casting to primitive types 216 let boolean_boolean = boolean_ as boolean; 217 let Boolean_boolean = Boolean_ as boolean; 218 } 219 220 { 221 // Casting to reference type 222 let boolean_Boolean = boolean_ as Boolean; 223 let Boolean_Boolean = Boolean_ as Boolean; 224 let Boolean_Object = Boolean_ as Object; 225 } 226} 227