การเรนเดอร์th-TH

adfirma

Translation status: ภาษาไทย reader-locale proof. Code fences render through the th-TH pipeline; prose is canonical Latin.

Asserts that a condition is true at runtime.

Aliases: assert

Syntax: adfirma <expression> [, <message>]

Category#

testing

Examples#

radix/corpus/adfirma/adfirma.fab (canonical · keyword)#

Asserts that a condition is true at runtime.

# =============================================================================
# adfirma — Asserts that a condition is true at runtime.
# =============================================================================
#
# What this teaches:
#   • Runtime assertions — `adfirma <condition>` validates invariants during
#     program execution
#   • Custom messages — `adfirma <condition>, "message"` adds descriptive
#     diagnostic text on failure
#   • Testing category — adfirma is the primary assertion keyword for test
#     and verification code
#
# Common mistakes:
#   • using `adfirma` outside `proba` or `probandum` (WARN006); use `mori` for invariant violations in production code or move assertions into test blocks
#
# See also: proba, fac, cape
# =============================================================================

# adfirma — runtime assertions
#
# adfirma <condition>
# adfirma <condition>, "nuntius"
#
# GRAMMAR:
#   adfirmaStmt :← 'adfirma' expr (',' stringLit)?
#
# EXPECTED OUTPUT:
#   empty — adfirma only (adfirma.expected)

main {
    const _ x  10

    # Simple assertion without message
    assert x > 0

    # Assertion with custom message
    assert x  10 else "x decem esse debet"

    # Multiple assertions
    const _ nomen  "Marcus"
    assert nomen  "Marcus"
    assert nomen  "" else "nomen vacuum non sit"

    # Boolean assertions
    const _ viget  true
    assert viget
    assert viget  true else "vigere debet"
}

test "assertions validate invariants" {
    const _ x  10
    assert x > 0
    assert x  10 else "x decem esse debet"

    const _ nomen  "Marcus"
    assert nomen  "Marcus"
    assert nomen  "" else "nomen vacuum non sit"

    const _ viget  true
    assert viget
    assert viget  true else "vigere debet"
}