Renderingen-US

Experimental through version 1. Version 0 was alpha. This is the first language release: the interface is relatively stable, not frozen. Nothing is promised stable until version 2.

Testing

Tests are ordinary Faber source. There is no separate test language and no external runner to configure.

A single test#

test declares one test. assert asserts.

reader locale
faber convert --to en — English reader surface
test "additio" {
    assert 1 + 1 ≡ 2
}
faber convert --to la — canonical Faber
proba "additio" {
    adfirma 1 + 1 ≡ 2
}
faber convert --to th-TH — Thai
ทดสอบ "additio" {
    ยืนยัน 1 + 1 ≡ 2
}
faber convert --to zh-Hans — Simplified Chinese
测试 "additio" {
    断言 1 + 1 ≡ 2
}
faber convert --to zh-Hant — Traditional Chinese
測試 "additio" {
    斷言 1 + 1 ≡ 2
}
faber convert --to vi — Vietnamese
kiểm_thử "additio" {
    khẳng_định 1 + 1 ≡ 2
}
faber convert --to ar — Arabic
اختبر "additio" {
    أكد 1 + 1 ≡ 2
}
faber convert --to hi — Hindi
परीक्षण "additio" {
    पुष्टि 1 + 1 ≡ 2
}

Grouping tests#

describe groups related tests under one name.

reader locale
faber convert --to en — English reader surface
describe "arithmetica" {
    test "additio" {
        assert 1 + 1 ≡ 2
    }

    test "multiplicatio" {
        assert 2 * 3 ≡ 6
    }
}
faber convert --to la — canonical Faber
probandum "arithmetica" {
    proba "additio" {
        adfirma 1 + 1 ≡ 2
    }

    proba "multiplicatio" {
        adfirma 2 * 3 ≡ 6
    }
}
faber convert --to th-TH — Thai
ทดสอบชุด "arithmetica" {
    ทดสอบ "additio" {
        ยืนยัน 1 + 1 ≡ 2
    }

    ทดสอบ "multiplicatio" {
        ยืนยัน 2 * 3 ≡ 6
    }
}
faber convert --to zh-Hans — Simplified Chinese
验题 "arithmetica" {
    测试 "additio" {
        断言 1 + 1 ≡ 2
    }

    测试 "multiplicatio" {
        断言 2 * 3 ≡ 6
    }
}
faber convert --to zh-Hant — Traditional Chinese
測試規格 "arithmetica" {
    測試 "additio" {
        斷言 1 + 1 ≡ 2
    }

    測試 "multiplicatio" {
        斷言 2 * 3 ≡ 6
    }
}
faber convert --to vi — Vietnamese
đối_tượng_kiểm_thử "arithmetica" {
    kiểm_thử "additio" {
        khẳng_định 1 + 1 ≡ 2
    }

    kiểm_thử "multiplicatio" {
        khẳng_định 2 * 3 ≡ 6
    }
}
faber convert --to ar — Arabic
مختبر "arithmetica" {
    اختبر "additio" {
        أكد 1 + 1 ≡ 2
    }

    اختبر "multiplicatio" {
        أكد 2 * 3 ≡ 6
    }
}
faber convert --to hi — Hindi
परीक्षणसमूह "arithmetica" {
    परीक्षण "additio" {
        पुष्टि 1 + 1 ≡ 2
    }

    परीक्षण "multiplicatio" {
        पुष्टि 2 * 3 ≡ 6
    }
}

Tagging#

tag labels a test so it can be selected or filtered when running.

reader locale
faber convert --to en — English reader surface
describe "textus" {
    test "concatenatio" tag "fast" {
        assert "a" + "b" ≡ "ab"
    }
}
faber convert --to la — canonical Faber
probandum "textus" {
    proba "concatenatio" tag "fast" {
        adfirma "a" + "b" ≡ "ab"
    }
}
faber convert --to th-TH — Thai
ทดสอบชุด "textus" {
    ทดสอบ "concatenatio" แท็ก "fast" {
        ยืนยัน "a" + "b" ≡ "ab"
    }
}
faber convert --to zh-Hans — Simplified Chinese
验题 "textus" {
    测试 "concatenatio" 标签 "fast" {
        断言 "a" + "b" ≡ "ab"
    }
}
faber convert --to zh-Hant — Traditional Chinese
測試規格 "textus" {
    測試 "concatenatio" 標籤 "fast" {
        斷言 "a" + "b" ≡ "ab"
    }
}
faber convert --to vi — Vietnamese
đối_tượng_kiểm_thử "textus" {
    kiểm_thử "concatenatio" nhãn "fast" {
        khẳng_định "a" + "b" ≡ "ab"
    }
}
faber convert --to ar — Arabic
مختبر "textus" {
    اختبر "concatenatio" وسم "fast" {
        أكد "a" + "b" ≡ "ab"
    }
}
faber convert --to hi — Hindi
परीक्षणसमूह "textus" {
    परीक्षण "concatenatio" टैग "fast" {
        पुष्टि "a" + "b" ≡ "ab"
    }
}

Modifiers#

Modifiers follow the test name.

reader locale
faber convert --to en — English reader surface
describe "modifiers" {
    test "stable" tag "fast" {
        assert true
    }

    test "every run" repeat 3 {
        assert true
    }

    test "not written yet" todo "waiting on the parser" {
        assert true
    }
}
faber convert --to la — canonical Faber
probandum "modifiers" {
    proba "stable" tag "fast" {
        adfirma verum
    }

    proba "every run" repete 3 {
        adfirma verum
    }

    proba "not written yet" futurum "waiting on the parser" {
        adfirma verum
    }
}
faber convert --to th-TH — Thai
ทดสอบชุด "modifiers" {
    ทดสอบ "stable" แท็ก "fast" {
        ยืนยัน จริง
    }

    ทดสอบ "every run" ทำซ้ำ 3 {
        ยืนยัน จริง
    }

    ทดสอบ "not written yet" ค้าง "waiting on the parser" {
        ยืนยัน จริง
    }
}
faber convert --to zh-Hans — Simplified Chinese
验题 "modifiers" {
    测试 "stable" 标签 "fast" {
        断言 真
    }

    测试 "every run" 重复 3 {
        断言 真
    }

    测试 "not written yet" 预期 "waiting on the parser" {
        断言 真
    }
}
faber convert --to zh-Hant — Traditional Chinese
測試規格 "modifiers" {
    測試 "stable" 標籤 "fast" {
        斷言 真
    }

    測試 "every run" 重複 3 {
        斷言 真
    }

    測試 "not written yet" 預期 "waiting on the parser" {
        斷言 真
    }
}
faber convert --to vi — Vietnamese
đối_tượng_kiểm_thử "modifiers" {
    kiểm_thử "stable" nhãn "fast" {
        khẳng_định đúng
    }

    kiểm_thử "every run" lặp_lại 3 {
        khẳng_định đúng
    }

    kiểm_thử "not written yet" việc_cần_làm "waiting on the parser" {
        khẳng_định đúng
    }
}
faber convert --to ar — Arabic
مختبر "modifiers" {
    اختبر "stable" وسم "fast" {
        أكد صواب
    }

    اختبر "every run" معاد 3 {
        أكد صواب
    }

    اختبر "not written yet" مستقبلي "waiting on the parser" {
        أكد صواب
    }
}
faber convert --to hi — Hindi
परीक्षणसमूह "modifiers" {
    परीक्षण "stable" टैग "fast" {
        पुष्टि सत्य
    }

    परीक्षण "every run" पुनरावृत्ति 3 {
        पुष्टि सत्य
    }

    परीक्षण "not written yet" लंबित "waiting on the parser" {
        पुष्टि सत्य
    }
}
ModifierMeaning
tag "<name>"Label for selection and filtering
repeat <n>Run the test n times; it passes only if every run passes
flaky <n>Rejected by faber test: flaky retries are not run, so the case fails without running its body
todo "<reason>"Expected-pending; documents why it does not run yet
skipSkip

repeat is a test modifier, not a loop, and it does not retry until a run passes. For loops see Loops.

Asserting#

assert takes any boolean expression.

reader locale
faber convert --to en — English reader surface
describe "assertiones" {
    test "comparisons" {
        assert 1 + 1 ≡ 2
        assert 3 ≻ 2
        assert "abc".length() ≡ 3
    }
}
faber convert --to la — canonical Faber
probandum "assertiones" {
    proba "comparisons" {
        adfirma 1 + 1 ≡ 2
        adfirma 3 ≻ 2
        adfirma "abc".longitudo() ≡ 3
    }
}
faber convert --to th-TH — Thai
ทดสอบชุด "assertiones" {
    ทดสอบ "comparisons" {
        ยืนยัน 1 + 1 ≡ 2
        ยืนยัน 3 ≻ 2
        ยืนยัน "abc".ความยาว() ≡ 3
    }
}
faber convert --to zh-Hans — Simplified Chinese
验题 "assertiones" {
    测试 "comparisons" {
        断言 1 + 1 ≡ 2
        断言 3 ≻ 2
        断言 "abc".长度() ≡ 3
    }
}
faber convert --to zh-Hant — Traditional Chinese
測試規格 "assertiones" {
    測試 "comparisons" {
        斷言 1 + 1 ≡ 2
        斷言 3 ≻ 2
        斷言 "abc".長度() ≡ 3
    }
}
faber convert --to vi — Vietnamese
đối_tượng_kiểm_thử "assertiones" {
    kiểm_thử "comparisons" {
        khẳng_định 1 + 1 ≡ 2
        khẳng_định 3 ≻ 2
        khẳng_định "abc".độ_dài() ≡ 3
    }
}
faber convert --to ar — Arabic
مختبر "assertiones" {
    اختبر "comparisons" {
        أكد 1 + 1 ≡ 2
        أكد 3 ≻ 2
        أكد "abc".طول() ≡ 3
    }
}
faber convert --to hi — Hindi
परीक्षणसमूह "assertiones" {
    परीक्षण "comparisons" {
        पुष्टि 1 + 1 ≡ 2
        पुष्टि 3 ≻ 2
        पुष्टि "abc".लंबाई() ≡ 3
    }
}

Tests in the program's own file#

Since 1.19 a source file can carry its tests, and the output a run should print, in sections after its program. Each section starts with a whole-line marker: +++ toml for the header, +++ faber for the program, `+++ faber test for the tests, and +++ text stdout (or stdin, stderr; also json`, jsonl, base64) for streams. A section runs to the next marker.

+++ toml
locale = "en"

+++ faber
@ public
fn double(int x) → int {
    return x * 2
}

main {
    print double(21)
}

+++ faber test
test "doubles" {
    assert double(21) ≡ 42
}

+++ text stdout
42

The test section sees the program's @ public items, as a sibling file would. check, run and build compile only the program section; faber test runs the test section, and faber corpus compares the program's output with the stream sections. A file with only a +++ faber test section is a test-only file that faber test runs and faber run refuses.

Where tests live, and running them#

Tests let beside the code they exercise, inside the package. Run them with:

faber test <package>

Related: Commands · Errors and testing