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

ทั้งหมด

Translation status: ภาษาไทย reader-locale proof. Term names and code fences follow the th-TH 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