import { Matchers,NumberMatchers } from './Matchers.uts' export const describes = new Map() export class Result implements io.dcloud.uts.json.IJsonStringify { total = 0 passed: string[] = [] failed: string[] = [] override toJSON():any|null{ let jsonRet = { 'total': this.total, 'passed': JSON.stringify(this.passed), 'failed': JSON.stringify(this.failed), } return jsonRet } } let result: Result = new Result() export function describe(name: string, fn: () => void): Result { result = new Result() describes.set(name, result) fn() return result } export function test(name: string, fn: () => void) { try { fn() // console.log('push....',name) result.passed.push(name) // console.log('push....',result.passed.length) } catch (e) { result.failed.push(`${name}:\n${e.message}`) } result.total++ } export function expect(value: T): Matchers { return new Matchers(value); } export function expectNumber(value: number): NumberMatchers { return new NumberMatchers(value); }