1 /** 2 * Copyright (c) 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 <gtest/gtest.h> 17 #include "lowering_test.h" 18 #include "compiler/lowering/ets/topLevelStmts/topLevelStmts.h" 19 20 namespace ark::es2panda { 21 TEST_F(LoweringTest,TestInterfaceObjectLiteral)22TEST_F(LoweringTest, TestInterfaceObjectLiteral) 23 { 24 char const *text = R"( 25 interface I1 { 26 a: number 27 } 28 29 interface I2 { 30 a: string 31 } 32 33 function foo1(a: I1) { } 34 function foo2(a: I2) { } 35 36 function main() { 37 foo1({ a: 1 }) 38 foo2({ a: "2" }) 39 })"; 40 41 CONTEXT(ES2PANDA_STATE_LOWERED, text) 42 { 43 const auto *const ast = GetAst(); 44 [[maybe_unused]] auto *classDef1 = ast->FindChild([](ir::AstNode *child) { 45 return child->IsClassDefinition() && 46 (child->AsClassDefinition()->InternalName().Mutf8() == "dummy.dummy$I1$ObjectLiteral"); 47 }); 48 ASSERT_TRUE(classDef1 != nullptr); 49 [[maybe_unused]] auto *classDef2 = ast->FindChild([](ir::AstNode *child) { 50 return child->IsClassDefinition() && 51 (child->AsClassDefinition()->InternalName().Mutf8() == "dummy.dummy$I2$ObjectLiteral"); 52 }); 53 ASSERT_TRUE(classDef1 != nullptr); 54 } 55 } 56 57 } // namespace ark::es2panda 58