forked from adoyle-h/lobash
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathhas.bats
113 lines (91 loc) · 1.9 KB
/
has.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
#!/usr/bin/env bats
setup_fixture
test_prepare has
load_module has
@test "l.has command cat, while cat is existed" {
run l.has command cat
assert_success
assert_output ''
}
@test "l.has command xxx, which not defined" {
run l.has command xxx
assert_failure
assert_output ''
}
@test "l.has function bbb, which not defined" {
run l.has function bbb
assert_failure
assert_output ''
}
@test "l.has function bbb, which has been defined" {
bbb() { echo 1; }
run l.has function bbb
assert_success
assert_output ''
}
@test "l.has builtin true" {
run l.has builtin true
assert_success
assert_output ''
}
@test "l.has builtin xxx, which not defined" {
run l.has builtin xxx
assert_failure
assert_output ''
}
@test "l.has keyword function" {
run l.has keyword function
assert_success
assert_output ''
}
@test "l.has keyword xxx, which not defined" {
run l.has keyword xxx
assert_failure
assert_output ''
}
@test "l.has alias xxx, which not defined" {
run l.has alias xxx
assert_failure
assert_output ''
}
@test "l.has alias gti, which has been defined" {
shopt -s expand_aliases
alias gti='git'
run l.has alias gti
assert_success
assert_output ''
shopt -u expand_aliases
}
@test "l.has the xxx, which not defined" {
run l.has the xxx
assert_failure
assert_output ''
}
@test "l.has the ls, which is command" {
run l.has the ls
assert_success
assert_output ''
}
@test "l.has the agti, which is alias" {
shopt -s expand_aliases
alias agti='git'
run l.has the agti
assert_success
assert_output ''
shopt -u expand_aliases
}
@test "l.has the function, which is keyword" {
run l.has the function
assert_success
assert_output ''
}
@test "l.has the type, which is builtin" {
run l.has the type
assert_success
assert_output ''
}
@test "l.has what type" {
run l.has what type
assert_failure 3
assert_output 'Invalid Condition: what'
}