summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAssaf Gordon <assafgordon@gmail.com>2014-12-06 04:49:37 (GMT)
committerAssaf Gordon <assafgordon@gmail.com>2014-12-06 04:49:37 (GMT)
commitd470e6e18d64f0b7d232f2483c18fdbcecb18fd7 (patch)
tree483fa50385d657a2258baf15bc225ae844a32a32
parent855db0ca0f17670e9301c0789b05624b943ace67 (diff)
downloadagnostic-d470e6e18d64f0b7d232f2483c18fdbcecb18fd7.zip
agnostic-d470e6e18d64f0b7d232f2483c18fdbcecb18fd7.tar.gz
agnostic-d470e6e18d64f0b7d232f2483c18fdbcecb18fd7.tar.bz2
tests: add 'for' syntax tests
-rw-r--r--src/tests/shell_syntax_tests.js18
1 files changed, 17 insertions, 1 deletions
diff --git a/src/tests/shell_syntax_tests.js b/src/tests/shell_syntax_tests.js
index f96f46e..8338b29 100644
--- a/src/tests/shell_syntax_tests.js
+++ b/src/tests/shell_syntax_tests.js
@@ -53,7 +53,8 @@ var rules = {
/* NOTE: these rules must be used directly, no other rule points to them */
'Compound_Command_Subshell' : 'Command',
- 'Compound_Command_Currentshell' : 'Command'
+ 'Compound_Command_Currentshell' : 'Command',
+ 'For_clause' : 'Command'
};
var tests = [
@@ -321,6 +322,21 @@ var tests = [
["cmpcs12", "{ uname && true || false & }", true, "Compound_Command_Currentshell"],
["cmpcs13", "{}", false, "Compound_Command_Currentshell"],
+/* Test For clause */
+["for1", "for a in a b c d ; do true ; done", true, "For_clause"],
+/* missing 'in' */
+["for2", "for a a b c d ; do true ; done", false, "For_clause"],
+/* missing semi-colon before do */
+["for3", "for a in a b c d do true ; done", false, "For_clause"],
+/* missing 'do' */
+["for4", "for a in a b c d ; true ; done", false, "For_clause"],
+/* missing semi-colon before done */
+["for5", "for a in a b c d ; do true done", false, "For_clause"],
+/* missing command between do and done */
+["for6", "for a in a b c d ; do ; done", false, "For_clause"],
+/* non-simple values in word-list */
+["for7", "for a in $(ls); do echo a=$a ; done", true, "For_clause"],
+
/* Test Pipeline rule */
["pipe1", "seq 1 2 10 | wc -l", true, "Pipeline"],
["pipe2", "seq 1 2 10 2>foo.txt | wc -l 2>>foo2.txt ", true, "Pipeline"],