-
Notifications
You must be signed in to change notification settings - Fork 69
Expand file tree
/
Copy pathfunction-in-@example.test.sh
More file actions
60 lines (45 loc) · 1.02 KB
/
function-in-@example.test.sh
File metadata and controls
60 lines (45 loc) · 1.02 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
#!/usr/bin/env bash
tests:put input <<EOF
# @description Same, as \`tests:eval\`, but writes stdout into given variable and
# return stderr as expected.
#
# @example
# _x() {
# echo "y [\$@]"
# }
# tests:value response _x a b c
# tests:assert-equals "\$response" "y [a b c]"
#
# @arg \$1 string Variable name.
# @arg \$@ string String to evaluate.
# @see tests:eval
tests:value() {
local __variable__="\$1"
local __value__=""
shift
tests:ensure "\${@}"
__value__="\$(cat "\$(tests:get-stdout-file)")"
eval \$__variable__=\"\${__value__}\"
}
EOF
tests:put expected <<EOF
## Index
* [tests:value](#testsvalue)
### tests:value
Same, as \`tests:eval\`, but writes stdout into given variable and
return stderr as expected.
#### Example
\`\`\`bash
_x() {
echo "y [\$@]"
}
tests:value response _x a b c
tests:assert-equals "\$response" "y [a b c]"
\`\`\`
#### Arguments
* **\$1** (string): Variable name.
* **...** (string): String to evaluate.
#### See also
* [tests:eval](#testseval)
EOF
assert