aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorMu Qiao <qiaomuf@gentoo.org>2011-07-21 17:53:09 +0800
committerMu Qiao <qiaomuf@gentoo.org>2011-08-02 15:46:29 +0800
commit043e0195a2c690e7aa450f7d66c90051bc5040b0 (patch)
treeb5f1b1465a85712ff031921df05853abc64f4a9e /test
parentParser: support -a and -i option for local (diff)
downloadlibbash-043e0195a2c690e7aa450f7d66c90051bc5040b0.tar.gz
libbash-043e0195a2c690e7aa450f7d66c90051bc5040b0.tar.bz2
libbash-043e0195a2c690e7aa450f7d66c90051bc5040b0.zip
Core: raise exception when using local outside function
Diffstat (limited to 'test')
-rw-r--r--test/walker_test.cpp17
1 files changed, 17 insertions, 0 deletions
diff --git a/test/walker_test.cpp b/test/walker_test.cpp
index 4f87c26..e5b0583 100644
--- a/test/walker_test.cpp
+++ b/test/walker_test.cpp
@@ -100,3 +100,20 @@ TEST(brace_expansion, not_in_raw_string)
bash_ast ast(input);
EXPECT_THROW(ast.interpret_with(walker), libbash::unsupported_exception);
}
+
+TEST(local_builtin, outside_function)
+{
+ interpreter walker;
+
+ std::string script = "local a";
+ std::istringstream input(script);
+ bash_ast ast(input);
+ try
+ {
+ ast.interpret_with(walker);
+ }
+ catch(libbash::runtime_exception& e)
+ {
+ EXPECT_STREQ(e.what(), "Define local variables outside function scope");
+ }
+}