-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtypeof.test
More file actions
36 lines (31 loc) · 898 Bytes
/
typeof.test
File metadata and controls
36 lines (31 loc) · 898 Bytes
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
#!/bin/bash
run_test() {
. typeof
# setup
local -a bob=( [0]="bob" [2]="bob:2.1-1" [5]="\"Bobby\"" [6]= [8]="at Jo's" )
local -A bobi=( ["name"]="bob" ["id"]="bob:2.1-1" ["nick"]="\"Bobby\"" ["job"]="at Jo's" ["email"]= )
local -ix year="${MMXVI-2016}"
local -ln reff='biNGo'
local bingo='Bing-Bash'
local emptyVar=
# prep
vars=( bob bobi year bingo reff )
vars+=( ${!BING*} )
vars+=( ${!BASH*} )
vars+=( DISPLAY OSTYPE RANDOM EUID PPID UID SHELLOPTS )
vars+=( declare ls for typeof type grep vars emptyVar)
# test
tput clear; tput setaf 5; echo '========== TEST: typeof =========='; tput sgr0
echo
for i in "${!vars[@]}"; do
echo "$i. ${vars[$i]}"
typeof "${vars[$i]}"
if [[ $? == 0 ]]
then echo -n '['; tput bold; tput setaf 2; echo -n 'OK'
else echo -n '['; tput bold; tput setaf 1; echo -n 'FAIL'
fi
tput sgr0; echo -n ']'; echo; echo
done
echo
}
run_test