渲染zh-Hant

全部

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

Marks a test hook as applying to every case.

Syntax: 全部

Category#

testing

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