1/* 2 * Copyright (c) 2025 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 16let testByte: Byte = new Byte(42 as byte); 17let testShort: Short = new Short(42 as short); 18let testInt: Int = new Int(42 as int); 19let testLong: Long = new Long(42 as long); 20let testFloat: Float = new Float(42 as float); 21let testDouble: Double = new Double(42 as double); 22let testChar: Char = new Char(42 as char); 23let testLongValue: Long = 9223372036854775807; 24 25function byte_test(): boolean { 26 let Byte_: Byte = new Byte(42 as byte); // ? 27 28 let byte_short = Byte_ as Short; // ? 29 let byte_int = Byte_ as Int; // ? 30 let byte_long = Byte_ as Long; // ok 31 let byte_float = Byte_ as Float; // ok 32 let byte_double = Byte_ as Double; // ok 33 let byte_char = Byte_ as Char; // ok 34 35 // true test Type speciefic operations 36 { 37 if (byte_double != testDouble || byte_double.toExponential() != testDouble.toExponential()) { 38 return false; 39 } 40 if (byte_char != testChar || byte_char.isBinDigit() != testChar.isBinDigit()) { 41 return false; 42 } 43 if (byte_float != testFloat || byte_float.isNaN() != testFloat.isNaN()) { 44 return false; 45 } 46 if (byte_long != testLong || (byte_long = testLongValue) != (testLongValue)) { 47 return false; // in fact CTE 48 } 49 50 // no int test 51 // no short test 52 // no byte test 53 } 54 return true; 55} 56function short_test(): boolean { 57 let Short_: Short = new Short(42 as short); 58 59 60 let short_byte = Short_ as Byte; 61 let short_short = Short_ as Short; 62 let short_char = Short_ as Char; 63 let short_int = Short_ as Int; 64 let short_long = Short_ as Long; 65 let short_float = Short_ as Float; 66 let short_double = Short_ as Double; 67 68 69 // true test Type speciefic operations 70 { 71 if (short_double.toExponential() != testDouble.toExponential()) { 72 return false; 73 } 74 if (short_char != testChar || short_char.isBinDigit() != testChar.isBinDigit()) { 75 return false; 76 } 77 if (short_float != testFloat || short_float.isNaN() != testFloat.isNaN()) { 78 return false; 79 } 80 if (short_long != testLong || (short_long = testLongValue) != (testLongValue)) { 81 return false; // in fact CTE 82 } 83 // no int test 84 // no short test 85 // no byte test 86 } 87 return true; 88} 89 90function char_test(): boolean { 91 let Char_: Char = new Char(42 as char); 92 93 let char_byte = Char_ as Byte; 94 let char_short = Char_ as Short; 95 let char_char = Char_ as Char; 96 let char_int = Char_ as Int; 97 let char_long = Char_ as Long; 98 let char_float = Char_ as Float; 99 let char_double = Char_ as Double; 100 101 // true test Type speciefic operations 102 { 103 if (char_double.toExponential() != testDouble.toExponential()) { 104 return false; 105 } 106 if (char_char != testChar || char_char.isBinDigit() != testChar.isBinDigit()) { 107 return false; 108 } 109 if (char_float != testFloat || char_float.isNaN() != testFloat.isNaN()) { 110 return false; 111 } 112 if (char_long != testLong || (char_long = testLongValue) != (testLongValue)) { 113 return false; // in fact CTE 114 } 115 // no int test 116 // no short test 117 // no byte test 118 } 119 return true; 120} 121 122function int_test(): boolean { 123 let Int_: Int = new Int(42 as int); 124 125 126 let int_byte = Int_ as Byte; 127 let int_short = Int_ as Short; 128 let int_char = Int_ as Char; 129 let int_int = Int_ as Int; 130 let int_long = Int_ as Long; 131 let int_float = Int_ as Float; 132 let int_double = Int_ as Double; 133 134 // true test Type speciefic operations 135 { 136 if (int_double.toExponential() != testDouble.toExponential()) { 137 return false; 138 } 139 if (int_char != testChar || int_char.isBinDigit() != testChar.isBinDigit()) { 140 return false; 141 } 142 if (int_float != testFloat || int_float.isNaN() != testFloat.isNaN()) { 143 return false; 144 } 145 if (int_long != testLong || (int_long = testLongValue) != (testLongValue)) { 146 return false; // in fact CTE 147 } 148 // no int test 149 // no short test 150 // no byte test 151 } 152 return true; 153} 154 155function long_test(): boolean { 156 let Long_: Long = new Long(42 as long); 157 158 let long_byte = Long_ as Byte; 159 let long_short = Long_ as Short; 160 let long_char = Long_ as Char; 161 let long_int = Long_ as Int; 162 let long_long = Long_ as Long; 163 let long_float = Long_ as Float; 164 let long_double = Long_ as Double; 165 166 // true test Type speciefic operations 167 { 168 if (long_double.toExponential() != testDouble.toExponential()) { 169 return false; 170 } 171 if (long_char != testChar || long_char.isBinDigit() != testChar.isBinDigit()) { 172 return false; 173 } 174 if (long_float != testFloat || long_float.isNaN() != testFloat.isNaN()) { 175 return false; 176 } 177 if (long_long != testLong || (long_long = testLongValue) != (testLongValue)) { 178 return false; // in fact CTE 179 } 180 // no int test 181 // no short test 182 // no byte test 183 } 184 return true; 185} 186 187function float_test(): boolean { 188 let Float_: Float = new Float(42 as float); 189 190 let float_byte = Float_ as Byte; 191 let float_short = Float_ as Short; 192 let float_char = Float_ as Char; 193 let float_int = Float_ as Int; 194 let float_long = Float_ as Long; 195 let float_float = Float_ as Float; 196 let float_double = Float_ as Double; 197 // true test Type speciefic operations 198 { 199 if (float_double.toExponential() != testDouble.toExponential()) { 200 return false; 201 } 202 if (float_char != testChar || float_char.isBinDigit() != testChar.isBinDigit()) { 203 return false; 204 } 205 if (float_float != testFloat || float_float.isNaN() != testFloat.isNaN()) { // better to find another way of checking 206 return false; 207 } 208 if (float_long != testLong || (float_long = testLongValue) != (testLongValue)) { 209 return false; // in fact CTE 210 } 211 // no int test 212 // no short test 213 // no byte test 214 } 215 return true; 216} 217 218function double_test(): boolean { 219 let Double_: Double = new Double(42 as double); 220 221 let double_byte = Double_ as Byte; 222 let double_short = Double_ as Short; 223 let double_char = Double_ as Char; 224 let double_int = Double_ as Int; 225 let double_long = Double_ as Long; 226 let double_float = Double_ as Float; 227 let double_double = Double_ as Double; 228 // true test Type speciefic operations 229 { 230 if (double_double.toExponential() != testDouble.toExponential()) { 231 return false; 232 } 233 if (double_char != testChar || double_char.isBinDigit() != testChar.isBinDigit()) { 234 return false; 235 } 236 if (double_float != testFloat || double_float.isNaN() != testFloat.isNaN()) { // better to find another way of checking 237 return false; 238 } 239 if (double_long != testLong || (double_long = testLongValue) != (testLongValue)) { 240 return false; // in fact CTE 241 } 242 // no int test 243 // no short test 244 // no byte test 245 } 246 return true; 247} 248 249function boolean_test(): boolean { 250 let boolean_: boolean = true; 251 let Boolean_: Boolean = new Boolean(true); 252 253 let boolean_boolean = Boolean_ as Boolean; 254 return true; 255} 256 257function main(): int { 258 if (byte_test() && short_test() && char_test() && int_test() 259 && long_test() && float_test() && double_test() && boolean_test()) { 260 return 0; 261 } 262 return 1; 263} 264