| 1 |
## our_shell: ysh
|
| 2 |
## oils_failures_allowed: 5
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
source --builtin testing.ysh
|
| 7 |
|
| 8 |
echo 'parens'
|
| 9 |
test-expr (42 + 1)
|
| 10 |
echo
|
| 11 |
|
| 12 |
echo 'brackets'
|
| 13 |
test-expr [42 + 1]
|
| 14 |
echo
|
| 15 |
|
| 16 |
echo 'expr in parens'
|
| 17 |
test-expr (^[42 + 1])
|
| 18 |
echo
|
| 19 |
|
| 20 |
## STDOUT:
|
| 21 |
## END
|
| 22 |
|
| 23 |
|
| 24 |
|
| 25 |
source --builtin testing.ysh
|
| 26 |
|
| 27 |
echo 'parens'
|
| 28 |
test-named (n=42 + 1)
|
| 29 |
echo
|
| 30 |
|
| 31 |
echo 'brackets'
|
| 32 |
test-named [n=42 + 1]
|
| 33 |
echo
|
| 34 |
|
| 35 |
echo 'expr in parens'
|
| 36 |
test-named (n=^[42 + 1])
|
| 37 |
echo
|
| 38 |
|
| 39 |
echo 'no value'
|
| 40 |
test-named
|
| 41 |
echo
|
| 42 |
|
| 43 |
## STDOUT:
|
| 44 |
## END
|
| 45 |
|
| 46 |
|
| 47 |
|
| 48 |
source --builtin testing.ysh # get rid of this line later?
|
| 49 |
|
| 50 |
var x = 42
|
| 51 |
|
| 52 |
# how do you get the code string here?
|
| 53 |
|
| 54 |
assert [42 === x]
|
| 55 |
|
| 56 |
assert [42 < x]
|
| 57 |
|
| 58 |
#assert [42 < x; fail_message='message']
|
| 59 |
|
| 60 |
#assert (^[(42 < x)], fail_message='passed message')
|
| 61 |
|
| 62 |
# BUG
|
| 63 |
assert [42 < x, fail_message='passed message']
|
| 64 |
|
| 65 |
## STDOUT:
|
| 66 |
## END
|
| 67 |
|
| 68 |
|
| 69 |
|
| 70 |
cat >mytest.ysh <<EOF
|
| 71 |
echo hi
|
| 72 |
EOF
|
| 73 |
|
| 74 |
# which ysh
|
| 75 |
|
| 76 |
# the test framework sets $SH to bin/ysh
|
| 77 |
# but ysh is already installed on this machine
|
| 78 |
|
| 79 |
$SH --tool test mytest.ysh
|
| 80 |
|
| 81 |
## STDOUT:
|
| 82 |
## END
|
| 83 |
|
| 84 |
# Hm can we do this entirely in user code, not as a builtin?
|
| 85 |
|
| 86 |
|
| 87 |
|
| 88 |
source --builtin testing.ysh
|
| 89 |
|
| 90 |
proc p {
|
| 91 |
echo STDOUT
|
| 92 |
echo STDERR >& 2
|
| 93 |
return 42
|
| 94 |
}
|
| 95 |
|
| 96 |
describe p {
|
| 97 |
# each case changes to a clean directory?
|
| 98 |
#
|
| 99 |
# and each one is numbered?
|
| 100 |
|
| 101 |
it 'prints to stdout and stderr' {
|
| 102 |
try {
|
| 103 |
p > out 2>& err
|
| 104 |
}
|
| 105 |
assert (_status === 42)
|
| 106 |
|
| 107 |
cat out
|
| 108 |
cat err
|
| 109 |
|
| 110 |
# Oh man the here docs are still useful here because of 'diff' interface
|
| 111 |
# Multiline strings don't quite do it
|
| 112 |
|
| 113 |
diff out - <<< '''
|
| 114 |
STDOUT
|
| 115 |
'''
|
| 116 |
|
| 117 |
diff err - <<< '''
|
| 118 |
STDERR
|
| 119 |
'''
|
| 120 |
}
|
| 121 |
}
|
| 122 |
|
| 123 |
## STDOUT:
|
| 124 |
TODO
|
| 125 |
## END
|