summaryrefslogtreecommitdiff
path: root/Shell
diff options
context:
space:
mode:
authorAnotherTest <ali.mpfard@gmail.com>2020-09-14 19:37:01 +0430
committerAndreas Kling <kling@serenityos.org>2020-09-15 20:36:59 +0200
commit4f223793c0da55e2931e94236bc04faa1f70928f (patch)
tree2c3d2a2ed751f341df9dc276e0c572d4a0c21527 /Shell
parent4c6f7846b49d6fbbe877148be2173e970cb685ea (diff)
downloadserenity-4f223793c0da55e2931e94236bc04faa1f70928f.zip
Shell: Add some tests for 'match'
Diffstat (limited to 'Shell')
-rw-r--r--Shell/Tests/match.sh53
1 files changed, 53 insertions, 0 deletions
diff --git a/Shell/Tests/match.sh b/Shell/Tests/match.sh
new file mode 100644
index 0000000000..0b2640e9cc
--- /dev/null
+++ b/Shell/Tests/match.sh
@@ -0,0 +1,53 @@
+#!/bin/Shell
+
+result=no
+match hello {
+ he* { result=yes }
+ * { result=fail }
+};
+
+test "$result" = yes || echo invalid result $result for normal string match, single option && exit 1
+
+result=no
+match hello {
+ he* | f* { result=yes }
+ * { result=fail }
+};
+
+test "$result" = yes || echo invalid result $result for normal string match, multiple options && exit 1
+
+result=no
+match (well hello friends) {
+ (* *) { result=fail }
+ (* * *) { result=yes }
+ * { result=fail }
+};
+
+test "$result" = yes || echo invalid result $result for list match && exit 1
+
+result=no
+match yes as v {
+ () { result=fail }
+ (*) { result=yes }
+ * { result=$v }
+};
+
+test "$result" = yes || echo invalid result $result for match with name && exit 1
+
+result=no
+# $(...) is a list, $(echo) should be an empty list, not an empty string
+match $(echo) {
+ * { result=fail }
+ () { result=yes }
+};
+
+test "$result" = yes || echo invalid result $result for list subst match && exit 1
+
+result=no
+# "$(...)" is a string, "$(echo)" should be an empty string, not an empty list
+match "$(echo)" {
+ * { result=yes }
+ () { result=fail }
+};
+
+test "$result" = yes || echo invalid result $result for string subst match && exit 1