blob: 0b7c3eaa4029a35ec3790c16ccbdd1ada3e4463a (
plain)
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
|
#!/bin/shell
source $(dirname "$0")/test-commons.inc
setopt --verbose
if test 1 -eq 1 {
# Are comments ok?
# Basic 'if' structure, empty block.
if true {
} else {
fail "if true runs false branch"
}
if false {
fail "if false runs true branch"
} else {
}
# Can we put `else` on a new line?
if false {
echo "if false runs true branch"
exit 2
}
else {
}
# Basic 'if' structure, without 'else'
if false {
fail "'if false' runs the branch"
}
# Extended 'cond' form.
if false {
fail "'if false' with 'else if' runs first branch"
} else if true {
} else {
fail "'if false' with 'else if' runs last branch"
}
# FIXME: Some form of 'not' would be nice
# &&/|| in condition
if true || false {
} else {
fail "'if true || false' runs false branch"
}
if true && false {
fail "'if true && false' runs true branch"
}
} else {
fail "'if test 1 -eq 1' runs false branch"
}
echo PASS
|