From 5454166103257b3f19b829dbc2c824ad67acf344 Mon Sep 17 00:00:00 2001 From: Mu Qiao Date: Thu, 2 Jun 2011 19:27:04 +0800 Subject: Core: make error handling POSIX compliant For a non-interactive shell, an error condition encountered by a special built-in or other type of utility shall cause the shell to write a diagnostic message to standard error and exit. --- test/api_test.cpp | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) (limited to 'test') diff --git a/test/api_test.cpp b/test/api_test.cpp index 7744ebf..38972fe 100644 --- a/test/api_test.cpp +++ b/test/api_test.cpp @@ -40,10 +40,8 @@ TEST(libbashapi, illegal_script) { std::unordered_map> variables; std::vector functions; - int result = libbash::interpret(get_src_dir() + "/scripts/illegal_script.sh", - variables, - functions); - EXPECT_NE(0, result); + EXPECT_THROW(libbash::interpret(get_src_dir() + "/scripts/illegal_script.sh", variables, functions), + interpreter_exception); } TEST(libbashapi, legal_script) @@ -78,9 +76,10 @@ TEST(libbashapi, preload) variables, functions); EXPECT_NE(0, result); - result = libbash::interpret(get_src_dir() + std::string("/scripts/source_true.sh"), - get_src_dir() + std::string("/scripts/illegal_script.sh"), - variables, - functions); - EXPECT_NE(0, result); + + EXPECT_THROW(libbash::interpret(get_src_dir() + std::string("/scripts/source_true.sh"), + get_src_dir() + std::string("/scripts/illegal_script.sh"), + variables, + functions), + interpreter_exception); } -- cgit v1.2.3-65-gdbad