本文整理汇总了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")
}
})
示例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)
}
})