渲染zh-Hans

异步备置

Translation status: 简体中文 reader-locale proof. Term names and code fences follow the zh-Hans pack; supporting prose may still be English.

Registers an async before-each test hook.

Syntax: 异步备置 <block>

Category#

testing

Examples#

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

Registers an async before-each test hook.

# =============================================================================
# 异步备置 — Registers an async before-each test hook.
# =============================================================================
#
# What this teaches:
#   • Async test setup — `异步备置` registers an async block that runs before
#     each test case, used when setup involves I/O or future-based operations
#   • Async counterpart of `备置`; paired with `异步收尾` for async
#     setup/teardown
#
# Common mistakes:
#   • Confusing `异步备置` (async setup) with `异步收尾` (async teardown) — they run at opposite ends of each test.
#
# See also: 备置, 异步收尾
# =============================================================================

# 异步备置 — async before-each hook
#
# GRAMMAR:
#   hookDecl :← '异步备置' block
#
# EXPECTED OUTPUT:
#   No 入口 — declaration or test-runner surface only.
#
# BACKEND:
#   declaration-only test hook (whitelist: 异步备置/praeparabit.fab).
#

describe "async hooks" {
    async_setup {
        print "before each async"
    }
    test "sample" {
        assert true
    }
}