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
杜庆泉's avatar
杜庆泉 已提交
12
        throw new Error(format(expected, this.actual))
Y
yurj26 已提交
13 14
        // #endif
        // #ifdef APP-IOS
lizhongyi_'s avatar
lizhongyi_ 已提交
15
        // NSException(name = NSExceptionName.internalInconsistencyException, reason = format(expected, this.actual)).raise()
Y
yurj26 已提交
16 17 18 19 20 21 22
        // #endif
    }
}

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