import { describe, test, expect, Result } from './tests.uts' class User{ name:string = ""; age:number = 0 } export function testKeyWord(): Result { return describe("KeyWord", () => { test('new', () => { let new1 = new User() // expect(JSON.stringify(new1)).toEqual('{"age":0,"name":""}') console.log(JSON.stringify(new1)) new1.age = 10 new1.name = "job" console.log(JSON.stringify(new1)) // expect(JSON.stringify(new1)).toEqual('{"age":10,"name":"job"}') }) test('typeof', () => { let new1 = new User() expect(typeof(new1)).toEqual('object') expect(typeof(123456.789)).toEqual('number') expect(typeof(789778979798797987979)).toEqual('number') expect(typeof(0.0)).toEqual('number') expect(typeof("hello world")).toEqual('string') expect(typeof([1,2,3])).toEqual('object') expect(typeof(new Array())).toEqual('object') expect(typeof(new Set())).toEqual('object') // expect(typeof(new Map())).toEqual('object') expect(typeof(new Date())).toEqual('object') expect(typeof("hello world")).toEqual('string') // 原生对象 // #ifndef APP-IOS expect(typeof(UTSAndroid.getUniActivity())).toEqual('object') // #endif }) test('instanceof', () => { let user1:any = new User() let instanceRet1 = user1 instanceof User expect(instanceRet1).toEqual(true) let instanceRet2 = user1 instanceof String expect(instanceRet2).toEqual(false) let num1:any = 3.1415926 let instanceRet3 = num1 instanceof String expect(instanceRet3).toEqual(false) let instanceRet4 = num1 instanceof Number expect(instanceRet4).toEqual(true) }) }) }