全部
Translation status: 简体中文 reader-locale proof. Term names and code fences follow the zh-Hans pack; supporting prose may still be English.
Marks a test hook as applying to every case.
Syntax: 全部
Category#
testing
Related#
Examples#
radix/corpus/omnia/omnia.fab (canonical · keyword)#
Marks a test hook as applying to every case.
# =============================================================================
# 全部 — Marks a test hook as applying to every case.
# =============================================================================
#
# What this teaches:
# • Exhaustive matching — `匹配 全部` requires every variant of a `判别` to have a `情况` branch.
# • Safety guarantee — The compiler rejects incomplete matches, eliminating forgotten variant bugs.
#
# Common mistakes:
# • Using 默认 with 匹配 全部 — 全部 forbids catchall arms; list every variant explicitly.
#
# See also: 备置, 收尾
# =============================================================================
# 全部 — exhaustive 匹配 (must cover every variant)
#
# 匹配 全部 <判别> { 情况 <Variant> { … } … }
#
# GRAMMAR:
# matchStmt :← '匹配' '全部' expr '{' casuClause* '}'
#
# EXPECTED OUTPUT:
# none — stdout not pinned for this exemplum.
union Condicio {
Activa,
Quietus
}
fn narra(Condicio condicio) → string {
# every variant must have a 情况
match all condicio {
case Activa {
return "activa"
}
case Quietus {
return "quietus"
}
}
}
main {
const Condicio condicio ← variant Activa
print narra(condicio)
}Expected output:
activa