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 16const etsVm = globalThis.gtest.etsVm; 17const areFuncsEqual1 = etsVm.getFunction('Lets_shared_reference/ETSGLOBAL;', 'areFuncsEqual1'); 18const areFuncsEqual2 = etsVm.getFunction('Lets_shared_reference/ETSGLOBAL;', 'areFuncsEqual2'); 19const areArraysEqual1 = etsVm.getFunction('Lets_shared_reference/ETSGLOBAL;','areArraysEqual1'); 20const areArraysEqual2 = etsVm.getFunction('Lets_shared_reference/ETSGLOBAL;','areArraysEqual2'); 21const areArraysEqual3 = etsVm.getFunction('Lets_shared_reference/ETSGLOBAL;','areArraysEqual3'); 22const areDatasEqual = etsVm.getFunction('Lets_shared_reference/ETSGLOBAL;','areDatasEqual'); 23const areMapsEqual = etsVm.getFunction('Lets_shared_reference/ETSGLOBAL;','areMapsEqual'); 24const areSetsEqual = etsVm.getFunction('Lets_shared_reference/ETSGLOBAL;','areSetsEqual'); 25const areRangeErrorEqual = etsVm.getFunction('Lets_shared_reference/ETSGLOBAL;','areRangeErrorEqual'); 26const areSyntaxErrorEqual = etsVm.getFunction('Lets_shared_reference/ETSGLOBAL;','areSyntaxErrorEqual'); 27const areURIErrorEqual = etsVm.getFunction('Lets_shared_reference/ETSGLOBAL;','areURIErrorEqual'); 28 29export let jsArray = ['foo', 1, true]; 30export let o = {a:1}; 31let bar = (): void => { 32 print('hello'); 33} 34 35ASSERT_TRUE(!areFuncsEqual1(bar)); 36ASSERT_TRUE(areFuncsEqual1(bar)); 37ASSERT_TRUE(!areFuncsEqual2(bar)); 38ASSERT_TRUE(areFuncsEqual2(bar)); 39 40ASSERT_TRUE(!areArraysEqual1(jsArray)); 41ASSERT_TRUE(areArraysEqual1(jsArray)); 42ASSERT_TRUE(areArraysEqual2(jsArray, jsArray)); 43ASSERT_TRUE(areArraysEqual3(jsArray)); 44 45const strTime = '2025-03-01T01:02:03.000Z'; 46let dateStr: Date = new Date(strTime); 47// The same function is called twice to verify that the parameters passed multiple times are consistent. 48// The first call has no cache, while the second call has a cache. Therefore, 49// the first call is expected to return false, and the second call is expected to return successfully. 50ASSERT_TRUE(!areDatasEqual(dateStr)); 51ASSERT_TRUE(areDatasEqual(dateStr)); 52 53const map = new Map([['key1', 1]]); 54ASSERT_TRUE(!areMapsEqual(map)); 55ASSERT_TRUE(areMapsEqual(map)); 56 57const set = new Set([1, 2, 3]); 58ASSERT_TRUE(!areSetsEqual(set)); 59ASSERT_TRUE(areSetsEqual(set)); 60 61const rangeError = new RangeError('Range error example'); 62ASSERT_TRUE(!areRangeErrorEqual(rangeError)); 63ASSERT_TRUE(areRangeErrorEqual(rangeError)); 64 65const syntaxError = new SyntaxError('Syntax error example'); 66ASSERT_TRUE(!areSyntaxErrorEqual(syntaxError)); 67ASSERT_TRUE(areSyntaxErrorEqual(syntaxError)); 68 69const uriError = new URIError('URI error example'); 70ASSERT_TRUE(!areURIErrorEqual(uriError)); 71ASSERT_TRUE(areURIErrorEqual(uriError));