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 16namespace QualifiedNamespace { 17 export namespace LevelOne { 18 export namespace LevelTwo { 19 export function qualifiedFunction() { 20 return "Qualified Function"; 21 } 22 23 export let qualifiedValue = 100; 24 25 // Utility function to reset the state of LevelTwo 26 export function resetState() { 27 qualifiedValue = 100; // Reset qualifiedValue to its initial state 28 } 29 } 30 } 31 32 // Utility function to reset the state of LevelOne and LevelTwo 33 export function resetQualifiedState() { 34 LevelOne.LevelTwo.resetState(); 35 } 36} 37 38function main() { 39 // Reset QualifiedNamespace state before running tests 40 QualifiedNamespace.resetQualifiedState(); 41 42 // Test access to deeply qualified namespace members 43 assertEQ(QualifiedNamespace.LevelOne.LevelTwo.qualifiedFunction(), "Qualified Function", "Qualified function access failed") 44 assertEQ(QualifiedNamespace.LevelOne.LevelTwo.qualifiedValue, 100, "Qualified value access failed") 45 46 // Test modification of qualified value 47 QualifiedNamespace.LevelOne.LevelTwo.qualifiedValue = QualifiedNamespace.LevelOne.LevelTwo.qualifiedValue + 50; 48 assertEQ(QualifiedNamespace.LevelOne.LevelTwo.qualifiedValue, 150, "Qualified value update failed") 49}