Renderingen-US

all

Translation status: English reader-locale proof. Term names and code fences follow the en pack; supporting prose may still be English.

Marks a test hook as applying to every case.

Syntax: all

Category#

testing

Examples#

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

Marks a test hook as applying to every case.

# =============================================================================
# all — Marks a test hook as applying to every case.
# =============================================================================
#
# What this teaches:
#   • Exhaustive matching — `match all` requires every variant of a `union` to have a `case` branch.
#   • Safety guarantee — The compiler rejects incomplete matches, eliminating forgotten variant bugs.
#
# Common mistakes:
#   • Using default with match all — all forbids catchall arms; list every variant explicitly.
#
# See also: setup, teardown
# =============================================================================

# all — exhaustive match (must cover every variant)
#
# match all <union> { case <Variant> { … } … }
#
# GRAMMAR:
#   matchStmt :← 'match' 'all' 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 case
    match all condicio {
        case Activa {
            return "activa"
        }
        case Quietus {
            return "quietus"
        }
    }
}

main {
    const Condicio condicio ← variant Activa
    print narra(condicio)
}

Expected output:

activa