Development build 586e1bd4
Typst文档简体中文版v0.15.1 + dev 586e1bd4

assert自始可用Go to source

Ensures that a condition is fulfilled.

Fails with an error if the condition is not fulfilled. Does not produce any output in the document.

If you wish to test equality between two values, see assert.eq and assert.ne.

Example

#assert(1 < 2, message: "math broke")

参数
Question mark

assert() → none

condition
bool
必需参数
Question mark
位置参数
Question mark

The condition that must be true for the assertion to pass.

message

The error message when the assertion fails.

定义
Question mark

eq0.4.0起可用Go to source

Ensures that two values are equal.

Fails with an error if the first value is not equal to the second. Does not produce any output in the document.

#assert.eq(10, 10)
assert.eq(
any,any,message: str,
) → none

left
any
必需参数
Question mark
位置参数
Question mark

The first value to compare.

right
any
必需参数
Question mark
位置参数
Question mark

The second value to compare.

message

An optional message to display on error instead of the representations of the compared values.

ne0.4.0起可用Go to source

Ensures that two values are not equal.

Fails with an error if the first value is equal to the second. Does not produce any output in the document.

#assert.ne(3, 4)
assert.ne(
any,any,message: str,
) → none

left
any
必需参数
Question mark
位置参数
Question mark

The first value to compare.

right
any
必需参数
Question mark
位置参数
Question mark

The second value to compare.

message

An optional message to display on error instead of the representations of the compared values.