diff --git a/uni_modules/uts-tests/utssdk/Type.uts b/uni_modules/uts-tests/utssdk/Type.uts new file mode 100644 index 0000000000000000000000000000000000000000..1f521ea6cc3e436d3ed73edfc4d981f6d78a2558 --- /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 e5faf6287c85a0ce57f48683552993087a8971b0..715fa548f376188ded38482b38208d42bd929ccd 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