2023-11-10 21:38:45 +00:00
|
|
|
// This is a basic example test.
|
|
|
|
|
2023-11-10 20:47:11 +00:00
|
|
|
#load "./example_math.jai";
|
2023-11-10 21:38:45 +00:00
|
|
|
// You can import files and libraries as normal.
|
|
|
|
//
|
|
|
|
// Note you do not have to import anything for the test
|
|
|
|
// suite specifically. That gets handled by the metaprogram.
|
2023-11-10 20:47:11 +00:00
|
|
|
|
|
|
|
main :: () {
|
2023-11-10 21:38:45 +00:00
|
|
|
Init_Test_Harness("basic");
|
|
|
|
// This call initializes the test harness.
|
|
|
|
// The string you pass in will be prefixed to all test names.
|
|
|
|
// (you can omit the prefix if you want.)
|
2023-11-10 20:47:11 +00:00
|
|
|
|
2023-11-10 21:38:45 +00:00
|
|
|
// This is how you create a single test.
|
|
|
|
// A test is a logically connected unit of functionality you
|
|
|
|
// want to verify the results of.
|
|
|
|
Test("example test", () {
|
2023-11-10 20:47:11 +00:00
|
|
|
expect(times2(1), 2);
|
|
|
|
expect(times2(2), 4);
|
|
|
|
});
|
|
|
|
|
2023-11-10 21:38:45 +00:00
|
|
|
// You can have more than one test in a suite.
|
|
|
|
Test("example test 2", () {
|
|
|
|
expect(times2(3), 6);
|
|
|
|
|
|
|
|
// uncomment this next expect call to see what it's like when
|
|
|
|
// a test fails
|
|
|
|
// expect(times2(4), 3);
|
|
|
|
});
|
|
|
|
|
2023-11-10 20:47:11 +00:00
|
|
|
Run_Test_Harness();
|
2023-11-10 21:38:45 +00:00
|
|
|
// when you're done declaring tests, call Run_Test_Harness
|
|
|
|
// to actually run all the tests and output the results
|
|
|
|
|
|
|
|
// This test will never run because it's being declared after
|
|
|
|
// Run_Test_Harness. We don't have a good way to check this and
|
|
|
|
// alert you automatically right now so be careful
|
|
|
|
Test("bad test", () {
|
|
|
|
expect(times2(4), 3);
|
|
|
|
});
|
2023-11-10 20:47:11 +00:00
|
|
|
}
|