ChaiScript/unittests/unit_test.inc
Jason Turner 79e8af4f6e Enhance eval error stack reporting
Use OOP to avoid code duplication for eval error tracking. This results
in much more robust stack error reporting and 400 LOC less.
2011-03-27 21:03:24 -06:00

54 lines
776 B
C++

def assert_equal(x, y)
{
if (x == y)
{
// Passes
} else {
// Fails
print("assert_equal failure: got " + to_string(y) + " expected " + to_string(x));
exit(-1);
}
}
def assert_false(f)
{
if (f)
{
print("assert_false failure");
exit(-1);
}
}
def assert_true(f)
{
if (!f)
{
print("assert_false failure");
exit(-1);
}
}
def assert_not_equal(x, y)
{
if (!(x == y))
{
// Passes
} else {
// Fails
print("assert_not_equal failure: got " + to_string(y) + " which was not expected.");
exit(-1);
}
}
def assert_throws(desc, x)
{
if (throws_exception(x))
{
// Passes
} else {
// Fails
print("assert_throws failure, function did not throw exception: " + to_string(desc));
exit(-1);
}
}