Finch/tests/tool/test_blocks.fch
Nexoniarz d428498efd finch.toml, threads and atomics, finch fmt, C++ files, struct #defines, a struct variable given for its ptr
- finch.toml: name, entry, paths, include, links, libdirs, cflags, ldflags, and [target.windows] etc.;
  finch run / build / test with no file use its entry
- import thread: spawn, join, mutex, cpus; atomic_add/sub/load/store/swap/cas built in
- finch fmt [--check]: indentation by { }, trailing spaces, empty lines; also as LSP formatting
- link "x.cpp" (or in finch.toml): built with the C++ compiler, which then links (FINCH_CXX)
- #define RAYWHITE (Color){ 245, 245, 245, 255 } imports as a Color
- push(body) where push takes ptr[Body]: the same as push(addr(body))
- --target android (NDK clang from ANDROID_NDK_HOME, -llog)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_016GzNP6r8dg6WDxUVZy8wjL
2026-10-29 11:17:10 +01:00

30 lines
606 B
Text

// finch test: each test "..." block runs on its own; a failed assert or a runtime error fails only that one
fn add(int a, int b) -> int {
return a + b
}
fn second([]int xs) -> int {
return xs[1]
}
test "add works" {
assert(add(2, 3) == 5)
assert(add(-1, 1) == 0, "zero")
}
test "a failing assert" {
x := add(1, 2)
assert(x == 4, "x is \(x), not 4")
}
test "a runtime error fails only this test" {
print(second([1]))
}
test "still runs after the others" {
assert("\(1.5, 2) and \(add(1, 1))" == "1.50 and 2")
}
fn main() {
print("main is not run by finch test")
}