Add unit test for divide by zero protection
This commit is contained in:
@@ -486,10 +486,10 @@ namespace chaiscript
|
||||
m->add(chaiscript::fun(&has_parse_tree), "has_parse_tree");
|
||||
m->add(chaiscript::fun(&get_parse_tree), "get_parse_tree");
|
||||
|
||||
m->add(chaiscript::user_type<chaiscript::exception::eval_error>("eval_error"));
|
||||
m->add(chaiscript::user_type<chaiscript::exception::eval_error>(), "eval_error");
|
||||
m->add(chaiscript::base_class<std::runtime_error, chaiscript::exception::eval_error>());
|
||||
|
||||
m->add(chaiscript::user_type<chaiscript::exception::arithmetic_error>("arithmetic_error"));
|
||||
m->add(chaiscript::user_type<chaiscript::exception::arithmetic_error>(), "arithmetic_error");
|
||||
m->add(chaiscript::base_class<std::runtime_error, chaiscript::exception::arithmetic_error>());
|
||||
|
||||
|
||||
|
7
unittests/divide_by_zero_protection.chai
Normal file
7
unittests/divide_by_zero_protection.chai
Normal file
@@ -0,0 +1,7 @@
|
||||
try {
|
||||
3/0
|
||||
assert_true(false); // should never get here
|
||||
} catch (e) {
|
||||
assert_equal("Arithmetic error: divide by zero", e.what())
|
||||
}
|
||||
|
Reference in New Issue
Block a user