當前位置: 首頁>>代碼示例>>TypeScript>>正文


TypeScript AssertContext.fail方法代碼示例

本文整理匯總了TypeScript中ava.AssertContext.fail方法的典型用法代碼示例。如果您正苦於以下問題:TypeScript AssertContext.fail方法的具體用法?TypeScript AssertContext.fail怎麽用?TypeScript AssertContext.fail使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在ava.AssertContext的用法示例。


在下文中一共展示了AssertContext.fail方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。

示例1: while

    logFiles.forEach((file) => {
        const data = fs.readFileSync(file, "utf8")
        const log = JSON.parse(data)

        // Has to set explicitly the type of richLogootSOps
        // so that TypeScript does its job and infers the return type of richLogootSOps.map(...)
        const richLogootSOps: unknown = log.richLogootSOps

        if (richLogootSOps instanceof Array && richLogootSOps.length > 0) {
            let isOk = true
            let i = 0

            const logootSOps: LogootSOperation[] = []

            while (isOk && i < richLogootSOps.length) {
                const plainLogootSOp: unknown = {
                    ...richLogootSOps[i].logootSOp,
                    author: richLogootSOps[i].id,
                }
                let logootSOp: LogootSOperation | null = LogootSDel.fromPlain(plainLogootSOp)
                if (logootSOp === null) {
                    logootSOp = LogootSAdd.fromPlain(plainLogootSOp)
                }
                if (logootSOp === null) {
                    isOk = false
                } else {
                    logootSOps.push(logootSOp)
                }
                i++
            }

            if (isOk) {
                logs.push(logootSOps)
            } else {
                t.fail("the log must contains only valid logoots operations")
            }
        } else {
            t.fail("the log must not be empty")
        }
    })
開發者ID:coast-team,項目名稱:mute-structs,代碼行數:40,代碼來源:logs.test.ts

示例2: test

test("fromPlain", (t: AssertContext) => {
    const plain = {
        random: 42,
        replicaNumber: 1,
        clock: 10,
        offset: -5,
    }

    const tuple: IdentifierTuple | null = IdentifierTuple.fromPlain(plain)

    if (tuple === null) {
        t.fail("The identifier tuple should have been correctly instantiated")
    } else {
        t.is(tuple.random, plain.random)
        t.is(tuple.replicaNumber, plain.replicaNumber)
        t.is(tuple.clock, plain.clock)
        t.is(tuple.offset, plain.offset)
    }
})
開發者ID:coast-team,項目名稱:mute-structs,代碼行數:19,代碼來源:identifiertuple.test.ts


注:本文中的ava.AssertContext.fail方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。