KScript docs
EN

Testing

Learning from the language tests

KScript's own repository tests the language with test scripts that are also good examples. Run kscript test samples/scripts/tests/language to run all of them, or pass one file. They also appear in VS Code's Test Explorer, and CI compares the tests the language server finds with the interpreter's results. Browse all language test scripts

What to try Runnable examples
Follow argument binding, recursive calls, and variable scope Named and piped calls · Recursion and scope
Step through an expression or a nested loop Operator precedence · Ranges and loop metadata
Give data a type and validate it at the boundary Custom literals · Records parsed from text · Joined types
Transform collections and text List transformations · Map updates · Regular expressions · Multiline strings
Use native values and add methods to a type Dates and durations · Money and rounding · Extension methods
Follow an error through nested handlers Guarded throws · Catch propagation

The repository tracks coverage gaps, combination targets and shared CLI, language-server and editor checks in the language test plan.

Run kscript test samples/scripts/tests/language/checkout-workflow.test.kscript to follow a mixed-currency invoice from line validation through discounts, settlement and refunds. The tests assert amounts in both currencies, recover the original error from a missing quote and check the penny retained after a partial refund. Checkout script

Run kscript test samples/scripts/tests/language/dispatch-workflow.test.kscript to follow incoming JSON through typed records, team-name normalization, priority sorting and queue selection. The same policy handles an unknown team by selecting a fallback or propagating the lookup error. Dispatch script

The refined string suite checks bare static keys, quoted interpolation, trimming and pattern failures. The license issuer suite exercises three validation guards and checks what the caller sees on success and failure.

Edit this page on GitHub