From e078ef0c4672b0e02bebfec8ee3a1221d87ec5ca Mon Sep 17 00:00:00 2001 From: wangyaqi Date: Tue, 27 Feb 2024 17:58:47 +0800 Subject: [PATCH] =?UTF-8?q?test:=20=E5=A2=9E=E5=8A=A0=E5=AF=B9=E8=B1=A1?= =?UTF-8?q?=E5=AD=97=E9=9D=A2=E9=87=8F=E8=BD=ACtype=E5=AE=9E=E4=BE=8B?= =?UTF-8?q?=E6=B5=8B=E8=AF=95=E4=BE=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- uni_modules/uts-tests/utssdk/Type.uts | 20 ++++++++++++++++++++ uni_modules/uts-tests/utssdk/index.uts | 11 +++++++---- 2 files changed, 27 insertions(+), 4 deletions(-) create mode 100644 uni_modules/uts-tests/utssdk/Type.uts diff --git a/uni_modules/uts-tests/utssdk/Type.uts b/uni_modules/uts-tests/utssdk/Type.uts new file mode 100644 index 0000000..1f521ea --- /dev/null +++ b/uni_modules/uts-tests/utssdk/Type.uts @@ -0,0 +1,20 @@ +import { describe, test, expect, Result } from './tests.uts' + +export function testType() : Result { + return describe("Type", () => { + test("Object literal to type instance", () => { + type Person = { + age: number + } + const a: Person = { + age: 1 + } + const b = { + age: 2 + } as Person + + expect(a instanceof Person).toEqual(true); + expect(b instanceof Person).toEqual(true); + }) + }) +} \ No newline at end of file diff --git a/uni_modules/uts-tests/utssdk/index.uts b/uni_modules/uts-tests/utssdk/index.uts index e5faf62..715fa54 100644 --- a/uni_modules/uts-tests/utssdk/index.uts +++ b/uni_modules/uts-tests/utssdk/index.uts @@ -10,8 +10,9 @@ import { testSet } from './Set.uts' import { testOperators } from './Operators.uts' import { testMath } from './Math.uts' import { testRegExp } from './RegExp.uts' -import { testForLoop } from './ForLoop.uts' +import { testForLoop } from './ForLoop.uts' import { testGlobal } from './Global.uts' +import { testType } from './Type.uts' export { Result } from './tests.uts' // Promise、Proxy、Reflect、Weakmap、WeakSet 不支持 @@ -28,8 +29,9 @@ export function runTests() : UTSJSONObject { const MathRes = testMath(); const RegExpRes = testRegExp(); const KeyWordRes = testKeyWord(); - const ForLoopRes = testForLoop(); + const ForLoopRes = testForLoop(); const GlobalRes = testGlobal(); + const TypeRes = testType(); return { Array: ArrayRes, @@ -44,7 +46,8 @@ export function runTests() : UTSJSONObject { Math: MathRes, RegExp: RegExpRes, KeyWord: KeyWordRes, - ForLoop: ForLoopRes, - Global: GlobalRes, + ForLoop: ForLoopRes, + Global: GlobalRes, + Type: TypeRes } } \ No newline at end of file -- GitLab