summaryrefslogtreecommitdiff
path: root/trip.rc
diff options
context:
space:
mode:
authorToby Goodwin <toby@paccrat.org>2018-03-05 06:51:31 +0000
committerToby Goodwin <toby@paccrat.org>2018-03-05 06:51:31 +0000
commitb3b9943da25aa0f86e2542c6846142aeeaa0cfe5 (patch)
treec7ff0edf52a46b34de69df7a36e8f4b3391e871e /trip.rc
parent7d179ce096c89963deae835327596de435e66cdf (diff)
implement walk half of if not, plus tests
Diffstat (limited to 'trip.rc')
-rw-r--r--trip.rc11
1 files changed, 9 insertions, 2 deletions
diff --git a/trip.rc b/trip.rc
index ddb259c..666418b 100644
--- a/trip.rc
+++ b/trip.rc
@@ -17,8 +17,11 @@ fn expect {
fn submatch {
if (!~ $#* 3)
fail incorrect invocation of submatch
- prompt=$nl if (!~ `` $nl {$rc -ic $1>[2=1]} $2)
+ got = `` $nl { prompt=$nl $rc -ic $1>[2=1] }
+ if (!~ $got $2) {
+ echo got $got expected $2
fail $3
+ }
}
fn sigexit sigint sigquit sigsegv
fn sigexit {
@@ -675,7 +678,7 @@ if (!~ $^L 'a c e f') {
}
# test support for unquoted =
-submatch 'echo foo = bar' 'foo = bar' 'unquoted equals 2'
+submatch 'echo foo = bar' 'foo = bar' 'unquoted equals 1'
submatch 'echo foo=bar' 'foo=bar' 'unquoted equals 2'
submatch 'echo foo=' 'foo=' 'unquoted equals 3'
submatch 'echo =bar; whatis -v echo' 'echo=bar' 'unquoted equals 4'
@@ -700,3 +703,7 @@ $rc -ec 'X=`{false}'
if (~ $status 0) {
fail '"rc -e" exits with zero status when backquote command returns non-zero'
}
+
+# exercise "if not"
+submatch 'if (false) echo foo; if not echo bar' 'bar' 'if not 1'
+submatch 'if (false) echo foo; echo qux; if not echo bar' 'rc: `if not'' must follow `if''' 'if not 2'