1/* 2 * Copyright (c) 2023-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 16enum E1 { 17 e1_item1, 18 e1_item2 = 7, 19 e1_item3, 20 e1_item4 = 1 21} 22 23 24function main() { 25 26 try { 27 assertEQ(E1.e1_item1.toString(), "0") 28 assertEQ(E1.e1_item1.valueOf(), 0) 29 assertEQ(E1.e1_item2.toString(), "7") 30 assertEQ(E1.e1_item2.valueOf(), 7) 31 assertEQ(E1.e1_item3.toString(), "8") 32 assertEQ(E1.e1_item3.valueOf(), 8) 33 34 let test1 : E1 = E1.getValueOf("e1_item1"); 35 let test2 : E1 = E1.getValueOf("e1_item2"); 36 let test3 : E1 = E1.getValueOf("e1_item3"); 37 38 assertEQ(test1.valueOf(), 0) 39 assertEQ(test1.getName(), "e1_item1") 40 assertEQ(test2.valueOf(), 7) 41 assertEQ(test2.getName(), "e1_item2") 42 assertEQ(test3.valueOf(), 8) 43 assertEQ(test3.getName(), "e1_item3") 44 } 45 catch (e) { 46 //Exception happened 47 } 48 49 50} 51