Matchers.uts 645 字节
Newer Older
Y
yurj26 已提交
1 2 3 4 5 6 7 8 9 10 11

export class Matchers<T> {
    private actual: T
    constructor(actual: T) {
        this.actual = actual
    }
    toEqual(expected: T) {
        if (JSON.stringify(expected) == JSON.stringify(this.actual)) {
            return
        }
        // #ifndef APP-IOS
lizhongyi_'s avatar
lizhongyi_ 已提交
12
        // throw new Error(format(expected, this.actual))
Y
yurj26 已提交
13 14 15 16 17 18 19 20 21 22
        // #endif
        // #ifdef APP-IOS
        NSException(name = NSExceptionName.internalInconsistencyException, reason = format(expected, this.actual)).raise()
        // #endif
    }
}

function format(expected: any | null, actual: any | null): string {
    return `expected:<${expected}> but was:<${actual}>`
}