• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1/*
2 * Copyright (c) 2023 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
16const assert = require('assert');
17
18export namespace secHello {
19  export namespace secWorld {
20    export function sayWorld() {
21      const instance = new World();
22      return instance.sayWorld();
23    }
24
25    class World{
26      private readonly worldStr;
27
28      constructor() {
29        this.worldStr = "world";
30      }
31
32      public sayWorld(){
33        return this.worldStr;
34      }
35    }
36  }
37
38  assert.strictEqual(secWorld.sayWorld(), "world");
39
40  export class Hello {
41    private readonly helloStr;
42
43    constructor() {
44      this.helloStr = 'hello';
45    }
46
47    public sayHello(){
48      return this.helloStr;
49    }
50  }
51
52  function sayHello() {
53
54  }
55
56  export const cat = new class{
57    private readonly mAge: number;
58
59    constructor() {
60      this.mAge = 2;
61    }
62
63    getAge(){
64      return this.mAge;
65    }
66  }
67}
68
69const hello = new secHello.Hello();
70
71assert.strictEqual(hello.sayHello(), "hello");
72
73assert.strictEqual(secHello.cat.getAge(), 2);
74