1/*
2 * Copyright (c) 2023-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
16enum E1 {
17  e1_item1,
18  e1_item2 = 7,
19  e1_item3,
20  e1_item4 = 1
21}
22
23//let cons = new Console;
24
25function main() {
26
27  assert(E1.e1_item1.toString() == "0");
28  assert(E1.e1_item1.valueOf() == 0);
29  assert(E1.e1_item2.toString() == "7");
30  assert(E1.e1_item2.valueOf() == 7);
31  assert(E1.e1_item3.toString() == "8");
32  assert(E1.e1_item3.valueOf() == 8);
33
34 // cons.print("First element of 'E1': '" + E1.e1_item1.toString() + "' = " + E1.e1_item1.ordinal()  + 
35 //   ", second: '" + E1.e1_item2.toString() + "' = " + E1.e1_item2.ordinal() + " and third: '" + 
36 //   E1.e1_item3.toString() + "' = " + E1.e1_item3.ordinal() + ".\n")
37
38  try {
39
40    let test1 : E1 = E1.getValueOf("e1_item1");
41    let test2 : E1 = E1.getValueOf("e1_item2");
42    let test3 : E1 = E1.getValueOf("e1_item3");
43
44    assert(test1.valueOf() == 0);
45    assert(test1.getName() == "e1_item1");
46    assert(test2.valueOf() == 7);
47    assert(test2.getName() == "e1_item2");
48    assert(test3.valueOf() == 8);
49    assert(test3.getName() == "e1_item3");
50
51    //cons.print("First element of 'E1': '" + test1.toString() + "' = " + test1.ordinal() +
52    //  ", second: '" + test2.toString() + "' = " + test2.ordinal() + " and third: '"  + test3.toString() + "' = " + test3.ordinal()  + ".\n")
53  }
54  catch (e) {
55    //cons.print("Exception happened")
56  }
57}
58