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
16class A {
17  bar(): string {
18    return "Class A";
19  }
20}
21
22class B extends A {}
23
24class C extends B {
25  bar(): string {
26    return "Class C";
27  }
28}
29
30function foo(c: Int|String|A|null|undefined): void {
31  if (c instanceof String)  {
32    assert(c.length == 11);
33  } else if (c instanceof C) {
34    assert(c.bar() == "Class C");
35  } else if (c instanceof Int) {
36    assert(c * c == 49);
37  } else if (c === undefined) {
38     assert(c == undefined);
39  } else {
40     assert(c == null);
41  }
42}
43
44function main(): void {
45  foo("Test string");
46  foo(new Int(7));
47  foo(new C());
48  foo(null);
49  foo(undefined);
50}
51