-
-
Notifications
You must be signed in to change notification settings - Fork 29
/
is_function.bats
70 lines (58 loc) · 1.1 KB
/
is_function.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
#!/usr/bin/env bats
# shellcheck disable=2034
setup_fixture
@test "l.is_function a function" {
function abc() { echo 123; }
run l.is_function abc
assert_success
assert_output ''
}
@test "l.is_function an alias" {
function abc() { echo 123; }
alias k=abc
run l.is_function k
assert_failure
assert_output ''
}
@test "l.is_function undefined var" {
run l.is_function undefined
assert_failure
assert_output ''
}
@test "l.is_function string" {
local s='abc'
run l.is_function s
assert_failure
assert_output ''
}
@test "l.is_function empty string" {
local s=''
run l.is_function s
assert_failure
assert_output ''
run l.is_function ""
assert_failure
assert_output ''
}
@test "l.is_function array" {
declare -a a=()
run l.is_function a
assert_failure
assert_output ''
declare -A A=()
run l.is_function A
assert_failure
assert_output ''
}
@test "l.is_function number" {
run l.is_function 123
assert_failure
assert_output ''
run l.is_function 0
assert_failure
assert_output ''
local n=123
run l.is_function n
assert_failure
assert_output ''
}