forked from adoyle-h/lobash
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathhas_not.s.bats
121 lines (101 loc) · 2.23 KB
/
has_not.s.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
118
119
120
121
#!/usr/bin/env bats
setup_fixture
test_prepare has_not.s
load_module has_not.s
@test "l.has_not.s the gti, which is an alias" {
shopt -s expand_aliases
alias gti='git'
result=$(l.has_not.s the gti)
assert_equal "$result" false
shopt -u expand_aliases
}
@test "l.has_not.s command cat, while cat is existed" {
run l.has_not.s command cat
assert_success
assert_output false
}
@test "l.has_not.s command xxx, which not defined" {
run l.has_not.s command xxx
assert_success
assert_output true
}
@test "l.has_not.s function bbb, which not defined" {
run l.has_not.s function bbb
assert_success
assert_output true
}
@test "l.has_not.s function bbb, which has been defined" {
bbb() { echo 1; }
run l.has_not.s function bbb
assert_success
assert_output false
}
@test "l.has_not.s builtin true" {
run l.has_not.s builtin true
assert_success
assert_output false
}
@test "l.has_not.s builtin xxx, which not defined" {
run l.has_not.s builtin xxx
assert_success
assert_output true
}
@test "l.has_not.s keyword function" {
run l.has_not.s keyword function
assert_success
assert_output false
}
@test "l.has_not.s keyword xxx, which not defined" {
run l.has_not.s keyword xxx
assert_success
assert_output true
}
@test "l.has_not.s alias xxx, which not defined" {
run l.has_not.s alias xxx
assert_success
assert_output true
}
@test "l.has_not.s the xxx, which not defined" {
run l.has_not.s the xxx
assert_success
assert_output true
}
@test "l.has_not.s the ls, which is command" {
run l.has_not.s the ls
assert_success
assert_output false
}
@test "l.has_not.s the function, which is keyword" {
run l.has_not.s the function
assert_success
assert_output false
}
@test "l.has_not.s the type, which is builtin" {
run l.has_not.s the type
assert_success
assert_output false
}
@test "l.has_not.s what type" {
test() {
set -e
l.has_not.s what type
}
run test
assert_failure 3
assert_output 'Invalid Condition: what'
}
@test "result=\$(l.has_not.s what type)" {
foo() {
set -e;
local r
r=$(l.has_not.s what type)
if [[ $r == true ]]; then
echo 13
else
echo 14
fi
}
run foo
assert_failure 3
assert_line -n 0 'Invalid Condition: what'
}