Add unit test for divide by zero protection

This commit is contained in:
Jason Turner
2015-01-09 20:17:20 -07:00
parent 25b15a3449
commit 576816e3b1
2 changed files with 9 additions and 2 deletions

View File

@@ -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>());

View 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())
}