From e3e69105d8b017568d63d50f15cbf549bd80004b Mon Sep 17 00:00:00 2001 From: duqingquan Date: Mon, 7 Aug 2023 16:00:19 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AE=8C=E5=96=84=20index/lastIndexOf=20?= =?UTF-8?q?=E7=A4=BA=E4=BE=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- uni_modules/uts-tests/utssdk/Array.uts | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/uni_modules/uts-tests/utssdk/Array.uts b/uni_modules/uts-tests/utssdk/Array.uts index ab513a9..ce7f680 100644 --- a/uni_modules/uts-tests/utssdk/Array.uts +++ b/uni_modules/uts-tests/utssdk/Array.uts @@ -168,6 +168,14 @@ export function testArray(): Result { expect(array2.includes('c', 100)).toEqual(false); }) test("indexOf", () => { + + let raw = {} + let arr = new Array() + arr.push({}); + arr.push({}); + arr.push(raw); + expect(arr.indexOf(raw)).toEqual(2); + const beasts: string[] = ['ant', 'bison', 'camel', 'duck', 'bison']; expect(beasts.indexOf('bison')).toEqual(1); expect(beasts.indexOf('bison', 2)).toEqual(4); @@ -191,6 +199,15 @@ export function testArray(): Result { expect(elements.join('-')).toEqual("Fire-Air-Water"); }) test("lastIndexOf", () => { + + let raw = {} + let arr = new Array() + arr.push({}); + arr.push({}); + arr.push(raw); + expect(arr.lastIndexOf(raw)).toEqual(2); + + const animals: string[] = ['Dodo', 'Tiger', 'Penguin', 'Dodo']; expect(animals.lastIndexOf('Dodo')).toEqual(3); expect(animals.lastIndexOf('Tiger')).toEqual(1); -- GitLab