@@ -25,11 +25,18 @@ set +e
2525[ $? = 127 ] || test_fail_psst $LINENO
2626set -e
2727
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.
2930set +e
3031( stack_push_psst ' ' 1 2> /dev/null )
3132[ $? = 127 ] || test_fail_psst $LINENO
3233
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+
3340( stack_push_psst ' stack' ' ' 2> /dev/null ) || test_fail_psst $LINENO
3441set -e
3542
@@ -43,31 +50,84 @@ set +e
4350[ $? = 127 ] || test_fail_psst $LINENO
4451set -e
4552
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.
4755set +e
4856( stack_pop_psst ' ' 2> /dev/null )
4957[ $? = 127 ] || test_fail_psst $LINENO
5058
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+
5165( stack_pop_psst ' stack' ' ' 2> /dev/null )
5266[ $? = 127 ] || test_fail_psst $LINENO
5367set -e
5468
5569
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+
56116# Test push creates and pops destroys
57117(
58118 ! 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
61121
62122 stack_push_psst ' stack' 1 || test_fail_psst $LINENO
63123 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
66126
67127 stack_pop_psst ' stack' || test_fail_psst $LINENO
68128 ! 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
71131)
72132
73133
@@ -80,7 +140,7 @@ set -e
80140 stack_exists_psst ' stack' || test_fail_psst $LINENO
81141
82142 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
84144
85145 stack_pop_psst ' stack' || test_fail_psst $LINENO
86146 ! stack_exists_psst ' stack' || test_fail_psst $LINENO
@@ -136,11 +196,12 @@ test4Res=
136196! stack_pop_psst ' stack' test4Res || test_fail_psst $LINENO
137197[ -z " $test4Res " ] || test_fail_psst $LINENO
138198
139-
140199# Verify that the gloabl namespace has not been polluted
141200! ( set | grep ' ^_.*_psst' ) || test_fail_psst $LINENO
142201
143- # Test count
202+
203+
204+ # Test stack count
144205(
145206 [ " $( stack_count_psst ' stack' ) " -eq 0 ] || test_fail_psst $LINENO
146207 stack_push_psst ' stack' ' a' || test_fail_psst $LINENO
0 commit comments