Reflect

Unit Testing

⚠️ TODO ❌ Not Implemented

Example

unittest {
	expect(2 * 2 == 4);
}

Documented Unit Tests

Unit tests that have an associated doc comment will be treated as an example section of the doc comment of the preceding declaration. The contents of the unit test will be included as a code block.

If the doc comment contains text, the first paragraph will be treated as the title of the example section, instead of the default "Example". Any additional paragraphs will be treated as the contents of this section.

Example

/** Computes the square of a number

	Parameters:
		- x: Number to square

	Returns:
		Returns the square of the specified number.
*/
function square(x) => x ^^ 2;

/// Basic Example
unittest {
	expect(2 * 2 == 4);
}

/** Advanced Example

	This example shows a more complete example of how this function can be
	used. 
*/
unittest {
	var num = 2;
	for (i; 0 .. 4)
		num = square(num);
	assert(num == 65536);
}