forked from adoyle-h/lobash
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathif.bats
117 lines (98 loc) · 1.46 KB
/
if.bats
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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
#!/usr/bin/env bats
setup_fixture
test_prepare if
load_module if
@test "l.if foo foo.then foo.else when failed" {
foo() {
echo false;
}
foo.then() {
echo 1
}
foo.else() {
echo 2
}
run l.if foo foo.then foo.else
assert_success
assert_output 2
}
@test "l.if foo foo.then when failed" {
foo() {
echo false;
}
foo.then() {
echo 1
}
run l.if foo foo.then
assert_success
assert_output ''
}
@test "l.if foo foo.then when success" {
foo() {
echo true;
}
foo.then() {
echo 1
}
run l.if foo foo.then
assert_success
assert_output 1
}
@test "l.if 0 foo.then foo.else" {
foo.then() {
echo 1
}
foo.else() {
echo 2
}
run l.if 0 foo.then foo.else
assert_success
assert_output 1
}
@test "l.if 1 foo.then foo.else" {
foo.then() {
echo 1
}
foo.else() {
echo 2
}
run l.if 0 foo.then foo.else
assert_success
assert_output 1
}
@test "l.if true foo.then foo.else" {
foo.then() {
echo 1
}
foo.else() {
echo 2
}
run l.if true foo.then foo.else
assert_success
assert_output 1
}
@test "l.if false foo.then foo.else" {
foo.then() {
echo 1
}
foo.else() {
echo 2
}
run l.if false foo.then foo.else
assert_success
assert_output 2
}
@test "l.if foo foo.then foo.else when foo return 2" {
foo() {
return 2
}
foo.then() {
echo 1
}
foo.else() {
echo 2
}
run l.if foo foo.then foo.else
assert_failure 2
assert_output ''
}