File tree Expand file tree Collapse file tree 5 files changed +24
-36
lines changed Expand file tree Collapse file tree 5 files changed +24
-36
lines changed Original file line number Diff line number Diff line change @@ -36,10 +36,9 @@ bash_object.parse_filter() {
36
36
done
37
37
IFS=" $old_ifs "
38
38
elif [ " $flag_parser_type " = ' advanced' ]; then
39
- # TODO: scope
40
- declare char=
41
- declare mode=' MODE_DEFAULT'
42
- declare -i PARSER_COLUMN_NUMBER=0
39
+ local char=
40
+ local mode=' MODE_DEFAULT'
41
+ local -i PARSER_COLUMN_NUMBER=0
43
42
44
43
# Append dot so parsing does not fail at end
45
44
# This makes parsing a lot easier, since it always expects a dot after a ']'
Original file line number Diff line number Diff line change @@ -16,12 +16,11 @@ bash_object.ensure.variable_does_exist() {
16
16
17
17
if ! declare -p " $variable_name " & > /dev/null; then
18
18
bash_object.util.die ' ERROR_INTERNAL' " Variable '$variable_name ' does not exist, but it should"
19
- return
19
+ return
20
20
fi
21
21
}
22
22
23
- # TODO
24
- # @description Test if the variable already exists. Note that the variable _must_ be sanitized before using this function
23
+ # @description Ensure the variable does not exist
25
24
bash_object.ensure.variable_does_not_exist () {
26
25
local variable_name=" $1 "
27
26
@@ -30,20 +29,8 @@ bash_object.ensure.variable_does_not_exist() {
30
29
return
31
30
fi
32
31
33
- if (( BASH_VERSINFO[0 ] >= 5 )) || (( BASH_VERSINFO[0 ] == 4 && BASH_VERSINFO[1 ] >= 2 )) ; then
34
- if [[ -v " $variable_name " ]]; then
35
- bash_object.util.die ' ERROR_INTERNAL' " Variable '$variable_name ' exists, but it shouldn't"
36
- return
37
- fi
38
- else
39
- if ! eval "
40
- if ! [ -z \$ {$variable_name +x} ]; then
41
- bash_object.util.die 'ERROR_INTERNAL' \" Variable '$variable_name ' exists, but it shouldn't\"
42
- return
43
- fi
44
- " ; then
45
- bash_object.util.die ' ERROR_INTERNAL' ' Eval unset test'
46
- return
47
- fi
32
+ if bash_object.ensure.variable_does_exist " $1 " ; then
33
+ bash_object.util.die ' ERROR_INTERNAL' " Variable '$variable_name ' exists, but it shouldn't"
34
+ return
48
35
fi
49
36
}
Original file line number Diff line number Diff line change @@ -21,11 +21,6 @@ bash_object.util.die() {
21
21
local error_key=" $1 "
22
22
local error_context=" ${2:- <empty>} "
23
23
24
- # TODO: test
25
- # if [[ ! -v 'ERRORS_BASH_OBJECT["$error_key"]' ]]; then
26
- # return 77
27
- # fi
28
-
29
24
local error_output=
30
25
case " $error_key " in
31
26
ERROR_FILTER_INVALID)
@@ -60,7 +55,7 @@ bash_object.util.generate_vobject_name() {
60
55
random_string=" ${RANDOM} _${RANDOM} _${RANDOM} _${RANDOM} _${RANDOM} "
61
56
fi
62
57
63
- REPLY= " __bash_object_${root_object_name} _${root_object_query} _${random_string} "
58
+ printf -v REPLY ' %q ' " __bash_object_${root_object_name} _${root_object_query} _${random_string} "
64
59
}
65
60
66
61
# @description A stringified version of the filter
Original file line number Diff line number Diff line change 7
7
load ' ./util/init.sh'
8
8
9
9
# get
10
+ @test " Error on invalid \$ 1" {
11
+ run bobject get-blah
12
+
13
+ assert_failure
14
+ assert_line -p " ERROR_ARGUMENTS_INVALID"
15
+ assert_line -p " Subcommand 'get-blah' not recognized"
16
+ }
17
+
10
18
@test " Error with \$ # of 2" {
11
19
run bobject get-string --as-value ' OBJECT'
12
20
Original file line number Diff line number Diff line change @@ -77,14 +77,13 @@ load './util/init.sh'
77
77
assert_line -p " , but received '5'"
78
78
}
79
79
80
- # TODO?
81
- # @test "Error on empty \$1" {
82
- # run bobject
83
-
84
- # assert_failure
85
- # assert_line -p "ERROR_ARGUMENTS_INVALID"
86
- # assert_line -p "'1' is empty"
87
- # }
80
+ @test " Error on invalid \$ 1" {
81
+ run bobject set-blah
82
+
83
+ assert_failure
84
+ assert_line -p " ERROR_ARGUMENTS_INVALID"
85
+ assert_line -p " Subcommand 'set-blah' not recognized"
86
+ }
88
87
89
88
@test " Error on empty \$ 2" {
90
89
run bobject set-string --by-ref " " ' .obj' obj
You can’t perform that action at this time.
0 commit comments