-
Notifications
You must be signed in to change notification settings - Fork 0
Starting Out
Every test has the same structure:
test_name("command") {
...
}The test name is a string that describes the test. The command is the command that you want to test. The command can be any command that you can run in the terminal.
For example, if you are building a project in C, and you want to test the output to stdout on a certain input, you can write a test like this:
test_name("./project_binary_name") {
input("your input"); // Gets sent to the program as stdin
output("expected output"); // The expected output of the program
}The test can also be a command that you want to run in the terminal. For example, if you want to test the output of a command like ls, you can write a test like this:
const LS_OUTPUT: string =
"file1.txt
file2.txt
file3.txt
file4.txt";
test_ls("ls") {
output(LS_OUTPUT); // The expected output of the ls command
}The test_script language has a few types that you can use in your tests, all of which you can find in Primitive Types.
Casting is done via the as keyword.
const x: string = 123 as string;You can define variables and constants in the test_script language.
const X: string = "Hello World"; // A constant
let y: string = "Hello World"; // A variableConstants should be in UPPER_SNAKE_CASE, while variables should be in snake_case.
You can define functions in the test_script language.
fn function_name(arg1: string, arg2: string): string {
// Function body
}Note: There is at the moment no return statement, instead the last expression in the function body is returned.
Since almost all expressions and statements in test_script returns a value, this is not a huge problem, but is something I am aware of and planning to implement in the near future.
The test_script language has a few control flow statements that you can use in your tests.
if condition {
// If statement body
} else if condition {
// Else if statement body
} else {
// Else statement body
}for variable: T in iterable {
// For loop body
}