aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorMu Qiao <qiaomuf@gentoo.org>2011-05-22 17:39:39 +0800
committerMu Qiao <qiaomuf@gentoo.org>2011-05-23 23:04:45 +0800
commit68c4695fdc7c2b3f73484bf03d24742034eed103 (patch)
tree183350a2955f08fc47c369c3a1fc3527de83bdb4 /test
parentWalker: support ${*:x:y} expansion (diff)
downloadlibbash-68c4695fdc7c2b3f73484bf03d24742034eed103.tar.gz
libbash-68c4695fdc7c2b3f73484bf03d24742034eed103.tar.bz2
libbash-68c4695fdc7c2b3f73484bf03d24742034eed103.zip
API: allow sourcing a script before interpreting
Diffstat (limited to 'test')
-rw-r--r--test/api_test.cpp18
1 files changed, 18 insertions, 0 deletions
diff --git a/test/api_test.cpp b/test/api_test.cpp
index 8746a0a..e74313e 100644
--- a/test/api_test.cpp
+++ b/test/api_test.cpp
@@ -33,6 +33,8 @@ TEST(libbashapi, bad_path)
std::vector<std::string> functions;
EXPECT_THROW(libbash::interpret("not exist", variables, functions),
interpreter_exception);
+ EXPECT_THROW(libbash::interpret("/scripts/source_true.sh", "not exist", variables, functions),
+ interpreter_exception);
}
TEST(libbashapi, illegal_script)
@@ -59,3 +61,19 @@ TEST(libbashapi, legal_script)
functions);
EXPECT_NE(0, result);
}
+
+TEST(libbashapi, preload)
+{
+ std::unordered_map<std::string, std::vector<std::string>> variables;
+ std::vector<std::string> functions;
+ int result = libbash::interpret(get_src_dir() + std::string("/scripts/source_true.sh"),
+ get_src_dir() + std::string("/scripts/source_true.sh"),
+ variables,
+ functions);
+ EXPECT_EQ(0, result);
+ result = libbash::interpret(get_src_dir() + std::string("/scripts/source_true.sh"),
+ get_src_dir() + std::string("/scripts/source_false.sh"),
+ variables,
+ functions);
+ EXPECT_NE(0, result);
+}