当前位置: 首页>>代码示例>>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;未经允许,请勿转载。