import { Matchers,NumberMatchers } from './Matchers.uts' export const describes = new Map() // #ifndef APP-IOS export class Result implements IJsonStringify { total = 0 passed: string[] = [] failed: string[] = [] toJSON():any|null{ let jsonRet = { 'total': this.total, 'passed': JSON.stringify(this.passed), 'failed': JSON.stringify(this.failed), } return jsonRet } } // #endif // #ifdef APP-IOS export class Result { total = 0 passed: string[] = [] failed: string[] = [] } // #endif 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); }