Commit e9bfd1656b8f306b408d35e26634d553f99bba39

Golmote 2015-08-26T08:17:57

Merge pull request #686 from Golmote/tests-bash Add tests for Bash

diff --git a/tests/languages/bash/comment_feature.test b/tests/languages/bash/comment_feature.test
new file mode 100644
index 0000000..5824909
--- /dev/null
+++ b/tests/languages/bash/comment_feature.test
@@ -0,0 +1,13 @@
+#foo
+# bar
+
+----------------------------------------------------
+
+[
+	["comment", "#foo"],
+	["comment", "# bar"]
+]
+
+----------------------------------------------------
+
+Checks for comments.
\ No newline at end of file
diff --git a/tests/languages/bash/function_feature.test b/tests/languages/bash/function_feature.test
new file mode 100644
index 0000000..cb0def2
--- /dev/null
+++ b/tests/languages/bash/function_feature.test
@@ -0,0 +1,101 @@
+alias apropos apt-get aptitude aspell
+awk basename bash bc bg
+builtin bzip2 cal cat cd
+cfdisk chgrp chmod chown chroot
+chkconfig cksum clear cmp comm
+command cp cron crontab csplit
+cut date dc dd ddrescue
+df diff diff3 dig dir dircolors
+dirname dirs dmesg du
+egrep eject enable env ethtool
+eval exec expand expect
+export expr fdformat fdisk
+fg fgrep file find fmt
+fold format free fsck ftp
+fuser gawk getopts git grep
+groupadd groupdel groupmod groups
+gzip hash head help hg history
+hostname htop iconv id ifconfig
+ifdown ifup import install jobs
+join kill killall less link ln
+locate logname logout look lpc lpr
+lprint lprintd lprintq lprm ls
+lsof make man mkdir mkfifo
+mkisofs mknod more most mount
+mtools mtr mv mmv nano netstat
+nice nl nohup notify-send nslookup
+open op passwd paste pathchk ping
+pkill popd pr printcap printenv
+printf ps pushd pv pwd quota
+quotacheck quotactl ram rar rcp
+read readarray readonly reboot
+rename renice remsync rev rm
+rmdir rsync screen scp sdiff sed
+seq service sftp shift
+shopt shutdown sleep slocate
+sort source split ssh stat strace
+su sudo sum suspend sync tail tar
+tee test time timeout times
+touch top traceroute trap tr
+tsort tty type ulimit umask
+umount unalias uname unexpand uniq
+units unrar unshar uptime
+useradd userdel usermod users uuencode
+uudecode v vdir vi vmstat wait watch
+wc wget whereis which who whoami write
+xargs xdg-open yes zip
+
+----------------------------------------------------
+
+[
+	["function", "alias"], ["function", "apropos"], ["function", "apt-get"], ["function", "aptitude"], ["function", "aspell"],
+	["function", "awk"], ["function", "basename"], ["function", "bash"], ["function", "bc"], ["function", "bg"],
+	["function", "builtin"], ["function", "bzip2"], ["function", "cal"], ["function", "cat"], ["function", "cd"],
+	["function", "cfdisk"], ["function", "chgrp"], ["function", "chmod"], ["function", "chown"], ["function", "chroot"],
+	["function", "chkconfig"], ["function", "cksum"], ["function", "clear"], ["function", "cmp"], ["function", "comm"],
+	["function", "command"], ["function", "cp"], ["function", "cron"], ["function", "crontab"], ["function", "csplit"],
+	["function", "cut"], ["function", "date"], ["function", "dc"], ["function", "dd"], ["function", "ddrescue"],
+	["function", "df"], ["function", "diff"], ["function", "diff3"], ["function", "dig"], ["function", "dir"], ["function", "dircolors"],
+	["function", "dirname"], ["function", "dirs"], ["function", "dmesg"], ["function", "du"],
+	["function", "egrep"], ["function", "eject"], ["function", "enable"], ["function", "env"], ["function", "ethtool"],
+	["function", "eval"], ["function", "exec"], ["function", "expand"], ["function", "expect"],
+	["function", "export"], ["function", "expr"], ["function", "fdformat"], ["function", "fdisk"],
+	["function", "fg"], ["function", "fgrep"], ["function", "file"], ["function", "find"], ["function", "fmt"],
+	["function", "fold"], ["function", "format"], ["function", "free"], ["function", "fsck"], ["function", "ftp"],
+	["function", "fuser"], ["function", "gawk"], ["function", "getopts"], ["function", "git"], ["function", "grep"],
+	["function", "groupadd"], ["function", "groupdel"], ["function", "groupmod"], ["function", "groups"],
+	["function", "gzip"], ["function", "hash"], ["function", "head"], ["function", "help"], ["function", "hg"], ["function", "history"],
+	["function", "hostname"], ["function", "htop"], ["function", "iconv"], ["function", "id"], ["function", "ifconfig"],
+	["function", "ifdown"], ["function", "ifup"], ["function", "import"], ["function", "install"], ["function", "jobs"],
+	["function", "join"], ["function", "kill"], ["function", "killall"], ["function", "less"], ["function", "link"], ["function", "ln"],
+	["function", "locate"], ["function", "logname"], ["function", "logout"], ["function", "look"], ["function", "lpc"], ["function", "lpr"],
+	["function", "lprint"], ["function", "lprintd"], ["function", "lprintq"], ["function", "lprm"], ["function", "ls"],
+	["function", "lsof"], ["function", "make"], ["function", "man"], ["function", "mkdir"], ["function", "mkfifo"],
+	["function", "mkisofs"], ["function", "mknod"], ["function", "more"], ["function", "most"], ["function", "mount"],
+	["function", "mtools"], ["function", "mtr"], ["function", "mv"], ["function", "mmv"], ["function", "nano"], ["function", "netstat"],
+	["function", "nice"], ["function", "nl"], ["function", "nohup"], ["function", "notify-send"], ["function", "nslookup"],
+	["function", "open"], ["function", "op"], ["function", "passwd"], ["function", "paste"], ["function", "pathchk"], ["function", "ping"],
+	["function", "pkill"], ["function", "popd"], ["function", "pr"], ["function", "printcap"], ["function", "printenv"],
+	["function", "printf"], ["function", "ps"], ["function", "pushd"], ["function", "pv"], ["function", "pwd"], ["function", "quota"],
+	["function", "quotacheck"], ["function", "quotactl"], ["function", "ram"], ["function", "rar"], ["function", "rcp"],
+	["function", "read"], ["function", "readarray"], ["function", "readonly"], ["function", "reboot"],
+	["function", "rename"], ["function", "renice"], ["function", "remsync"], ["function", "rev"], ["function", "rm"],
+	["function", "rmdir"], ["function", "rsync"], ["function", "screen"], ["function", "scp"], ["function", "sdiff"], ["function", "sed"],
+	["function", "seq"], ["function", "service"], ["function", "sftp"], ["function", "shift"],
+	["function", "shopt"], ["function", "shutdown"], ["function", "sleep"], ["function", "slocate"],
+	["function", "sort"], ["function", "source"], ["function", "split"], ["function", "ssh"], ["function", "stat"], ["function", "strace"],
+	["function", "su"], ["function", "sudo"], ["function", "sum"], ["function", "suspend"], ["function", "sync"], ["function", "tail"], ["function", "tar"],
+	["function", "tee"], ["function", "test"], ["function", "time"], ["function", "timeout"], ["function", "times"],
+	["function", "touch"], ["function", "top"], ["function", "traceroute"], ["function", "trap"], ["function", "tr"],
+	["function", "tsort"], ["function", "tty"], ["function", "type"], ["function", "ulimit"], ["function", "umask"],
+	["function", "umount"], ["function", "unalias"], ["function", "uname"], ["function", "unexpand"], ["function", "uniq"],
+	["function", "units"], ["function", "unrar"], ["function", "unshar"], ["function", "uptime"],
+	["function", "useradd"], ["function", "userdel"], ["function", "usermod"], ["function", "users"], ["function", "uuencode"],
+	["function", "uudecode"], ["function", "v"], ["function", "vdir"], ["function", "vi"], ["function", "vmstat"], ["function", "wait"], ["function", "watch"],
+	["function", "wc"], ["function", "wget"], ["function", "whereis"], ["function", "which"], ["function", "who"], ["function", "whoami"], ["function", "write"],
+	["function", "xargs"], ["function", "xdg-open"], ["function", "yes"], ["function", "zip"]
+]
+
+----------------------------------------------------
+
+Checks for all functions.
\ No newline at end of file
diff --git a/tests/languages/bash/important_feature.test b/tests/languages/bash/important_feature.test
new file mode 100644
index 0000000..0e03588
--- /dev/null
+++ b/tests/languages/bash/important_feature.test
@@ -0,0 +1,11 @@
+#!/bin/bash
+
+----------------------------------------------------
+
+[
+	["important", "#!/bin/bash"]
+]
+
+----------------------------------------------------
+
+Checks for shebang.
\ No newline at end of file
diff --git a/tests/languages/bash/keyword_feature.test b/tests/languages/bash/keyword_feature.test
new file mode 100644
index 0000000..ce35561
--- /dev/null
+++ b/tests/languages/bash/keyword_feature.test
@@ -0,0 +1,19 @@
+if then else elif fi
+for break continue while
+in case function select
+do done until echo exit
+return set declare
+
+----------------------------------------------------
+
+[
+	["keyword", "if"], ["keyword", "then"], ["keyword", "else"], ["keyword", "elif"], ["keyword", "fi"],
+	["keyword", "for"], ["keyword", "break"], ["keyword", "continue"], ["keyword", "while"],
+	["keyword", "in"], ["keyword", "case"], ["keyword", "function"], ["keyword", "select"],
+	["keyword", "do"], ["keyword", "done"], ["keyword", "until"], ["keyword", "echo"], ["keyword", "exit"],
+	["keyword", "return"], ["keyword", "set"], ["keyword", "declare"]
+]
+
+----------------------------------------------------
+
+Checks for all keywords.
\ No newline at end of file
diff --git a/tests/languages/bash/string_feature.test b/tests/languages/bash/string_feature.test
new file mode 100644
index 0000000..2426bc7
--- /dev/null
+++ b/tests/languages/bash/string_feature.test
@@ -0,0 +1,32 @@
+""
+''
+"foo"
+'foo'
+"foo
+bar"
+'foo
+bar'
+"$@"
+"${foo}"
+
+----------------------------------------------------
+
+[
+	["string", ["\"\""]],
+	["string", ["''"]],
+	["string", ["\"foo\""]],
+	["string", ["'foo'"]],
+	["string", ["\"foo\r\nbar\""]],
+	["string", ["'foo\r\nbar'"]],
+	["string", [
+		"\"", ["property", "$@"], "\""
+	]],
+	["string", [
+		"\"", ["property", "${foo}"], "\""
+	]]
+]
+
+----------------------------------------------------
+
+Checks for single-quoted and double-quoted strings.
+Also checks for variables in strings.
\ No newline at end of file
diff --git a/tests/languages/bash/variable_feature.test b/tests/languages/bash/variable_feature.test
new file mode 100644
index 0000000..58cca25
--- /dev/null
+++ b/tests/languages/bash/variable_feature.test
@@ -0,0 +1,15 @@
+$foo
+$@
+${foo bar}
+
+----------------------------------------------------
+
+[
+	["property", "$foo"],
+	["property", "$@"],
+	["property", "${foo bar}"]
+]
+
+----------------------------------------------------
+
+Checks for variables.
\ No newline at end of file