• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /**
2  * Copyright (c) 2024-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 
16 #include "ast_verifier_test.h"
17 #include "checker/ETSchecker.h"
18 
19 using ark::es2panda::compiler::ast_verifier::ModifierAccessValid;
20 
TEST_F(ASTVerifierTest,ProtectedAccessTestCorrect)21 TEST_F(ASTVerifierTest, ProtectedAccessTestCorrect)
22 {
23     char const *text = R"(
24         class A {
25             public a: int = 1;
26         }
27         class B extends A {
28             public b: int = this.a;
29         }
30     )";
31     CONTEXT(ES2PANDA_STATE_CHECKED, text, "dummy.ets")
32     {
33         GetAst()
34             ->AsETSModule()
35             ->Statements()[1]
36             ->AsClassDeclaration()
37             ->Definition()
38             ->AsClassDefinition()
39             ->Body()[0]
40             ->AsClassProperty()
41             ->AddModifier(ark::es2panda::ir::ModifierFlags::PROTECTED);
42 
43         EXPECT_TRUE(Verify<ModifierAccessValid>());
44     }
45 }
46