@@ -25,11 +25,18 @@ set +e
25
25
[ $? = 127 ] || test_fail_psst $LINENO
26
26
set -e
27
27
28
- # Stack name must not be empty, value can be empty
28
+ # Stack name must not be empty or start with a digit or have spaces.
29
+ # Value can be empty.
29
30
set +e
30
31
( stack_push_psst ' ' 1 2> /dev/null )
31
32
[ $? = 127 ] || test_fail_psst $LINENO
32
33
34
+ ( stack_push_psst ' 1stack' ' ' 2> /dev/null )
35
+ [ $? = 127 ] || test_fail_psst $LINENO
36
+
37
+ ( stack_puth_psst ' stack name' ' ' 2> /dev/null )
38
+ [ $? = 127 ] || test_fail_psst $LINENO
39
+
33
40
( stack_push_psst ' stack' ' ' 2> /dev/null ) || test_fail_psst $LINENO
34
41
set -e
35
42
@@ -43,31 +50,84 @@ set +e
43
50
[ $? = 127 ] || test_fail_psst $LINENO
44
51
set -e
45
52
46
- # Neither one may be empty
53
+ # Stack name must not be empty or start with a digit or have spaces.
54
+ # outVar name must not be empty.
47
55
set +e
48
56
( stack_pop_psst ' ' 2> /dev/null )
49
57
[ $? = 127 ] || test_fail_psst $LINENO
50
58
59
+ ( stack_pop_psst ' 1stack' ' ' 2> /dev/null )
60
+ [ $? = 127 ] || test_fail_psst $LINENO
61
+
62
+ ( stack_pop_psst ' stack name' 2> /dev/null )
63
+ [ $? = 127 ] || test_fail_psst $LINENO
64
+
51
65
( stack_pop_psst ' stack' ' ' 2> /dev/null )
52
66
[ $? = 127 ] || test_fail_psst $LINENO
53
67
set -e
54
68
55
69
70
+ # Exists must accept exactly one argument
71
+ set +e
72
+ ( stack_exists_psst 2> /dev/null )
73
+ [ $? = 127 ] || test_fail_psst $LINENO
74
+
75
+ ( stack_exists_psst ' stack' 1 2> /dev/null )
76
+ [ $? = 127 ] || test_fail_psst $LINENO
77
+ set -e
78
+
79
+ # Stack name must not be empty or start with a digit or have spaces
80
+ set +e
81
+ ( stack_exists_psst ' ' 2> /dev/null )
82
+ [ $? = 127 ] || test_fail_psst $LINENO
83
+
84
+ ( stack_exists_psst ' 1stack' 2> /dev/null )
85
+ [ $? = 127 ] || test_fail_psst $LINENO
86
+
87
+ ( stack_exists_psst ' stack name' ' ' 2> /dev/null )
88
+ [ $? = 127 ] || test_fail_psst $LINENO
89
+ set -e
90
+
91
+
92
+
93
+ # Count must accept exactly one argument
94
+ set +e
95
+ ( stack_count_psst 2> /dev/null )
96
+ [ $? = 127 ] || test_fail_psst $LINENO
97
+
98
+ ( stack_count_psst ' stack' 1 2> /dev/null )
99
+ [ $? = 127 ] || test_fail_psst $LINENO
100
+ set -e
101
+
102
+ # Stack name must not be empty or start with a digit or have spaces
103
+ set +e
104
+ ( stack_count_psst ' ' 2> /dev/null )
105
+ [ $? = 127 ] || test_fail_psst $LINENO
106
+
107
+ ( stack_count_psst ' 1stack' ' ' 2> /dev/null )
108
+ [ $? = 127 ] || test_fail_psst $LINENO
109
+
110
+ ( stack_count_psst ' stack name' ' ' 2> /dev/null )
111
+ [ $? = 127 ] || test_fail_psst $LINENO
112
+ set -e
113
+
114
+
115
+
56
116
# Test push creates and pops destroys
57
117
(
58
118
! stack_exists_psst ' stack' || test_fail_psst $LINENO
59
- # Verify that the gloabl namespace has not been polluted
60
- ! ( set | grep ' ^_.*_psst' ) || test_fail_psst $LINENO
119
+ # Verify that the gloabl namespace has not been polluted
120
+ ! ( set | grep ' ^_.*_psst' ) || test_fail_psst $LINENO
61
121
62
122
stack_push_psst ' stack' 1 || test_fail_psst $LINENO
63
123
stack_exists_psst ' stack' || test_fail_psst $LINENO
64
- # Verify that the gloabl namespace has not been polluted
65
- ! ( set | grep " ^_.*_psst" ) || test_fail_psst $LINENO
124
+ # Verify that the gloabl namespace has not been polluted
125
+ ! ( set | grep " ^_.*_psst" ) || test_fail_psst $LINENO
66
126
67
127
stack_pop_psst ' stack' || test_fail_psst $LINENO
68
128
! stack_exists_psst ' stack' || test_fail_psst $LINENO
69
- # Verify that the gloabl namespace has not been polluted
70
- ! ( set | grep ' ^_.*_psst' ) || test_fail_psst $LINENO
129
+ # Verify that the gloabl namespace has not been polluted
130
+ ! ( set | grep ' ^_.*_psst' ) || test_fail_psst $LINENO
71
131
)
72
132
73
133
@@ -80,7 +140,7 @@ set -e
80
140
stack_exists_psst ' stack' || test_fail_psst $LINENO
81
141
82
142
stack_pop_psst ' stack' || test_fail_psst $LINENO
83
- stack_exists_psst ' stack' test_fail_psst $LINENO
143
+ stack_exists_psst ' stack' || test_fail_psst $LINENO
84
144
85
145
stack_pop_psst ' stack' || test_fail_psst $LINENO
86
146
! stack_exists_psst ' stack' || test_fail_psst $LINENO
@@ -136,11 +196,12 @@ test4Res=
136
196
! stack_pop_psst ' stack' test4Res || test_fail_psst $LINENO
137
197
[ -z " $test4Res " ] || test_fail_psst $LINENO
138
198
139
-
140
199
# Verify that the gloabl namespace has not been polluted
141
200
! ( set | grep ' ^_.*_psst' ) || test_fail_psst $LINENO
142
201
143
- # Test count
202
+
203
+
204
+ # Test stack count
144
205
(
145
206
[ " $( stack_count_psst ' stack' ) " -eq 0 ] || test_fail_psst $LINENO
146
207
stack_push_psst ' stack' ' a' || test_fail_psst $LINENO
0 commit comments