Repository navigation
Tests
CupidScript tests are plain .cs scripts under tests/ plus a native C test binary.
make testThe runner executes each tests/*.cs file in lexical order and prints PASS/FAIL. It also runs the C API test binary bin/c_api_tests.
- Create a new file in
tests/(e.g.tests/my_feature.cs). - Use
assert(condition, "message")for checks. - Optionally print a success marker at the end.
Example:
// tests/my_feature.cs
let x = 1 + 2;
assert(x == 3, "basic math");
print("my_feature ok");If a test should fail, add this header at the top:
// EXPECT_FAILExample:
// tests/negative_example.cs
// EXPECT_FAIL
assert(false, "should fail");Files starting with _ are ignored by the test runner. Use these for shared fixtures or helper modules.
tests/c_api_tests.c is compiled into bin/c_api_tests and run by make test. It exercises the embedding API directly (lists, maps, error handling, etc.).
make -j2 test OBJDIR=obj-asan BINDIR=bin-asan CFLAGS='-std=c99 -D_POSIX_C_SOURCE=200809L -Wall -Wextra -g -O1 -fsanitize=address,undefined -fno-omit-frame-pointer' LDFLAGS='-fsanitize=address,undefined'make test runs the corpus and C API binary, an HTTP parser/transport binary, and Python loopback HTTP/TLS tests. Install Python 3 and the OpenSSL command-line tool for the TLS test certificate. No public network service is required. Both valid and malformed responses are tested, including binary bodies, peer-name verification, and a closed peer during a write.
To check both TLS modes in the same output directories:
make -j2 test CS_NO_TLS=1
make -j2 testThe build detects compiler/feature/flag changes and rebuilds affected objects. The runner checks sanitizer diagnostics and signals even for EXPECT_FAIL scripts. Coverage includes tuple host ownership, tuple comprehension bindings, container cycles, pending async tasks, nested interpolation, binary string patterns, and cleanup error/control-flow precedence.