Skip to content

Commit ff8fbb0

Browse files
committed
Fix minor issues & add more tests
1 parent 2cece9b commit ff8fbb0

File tree

1 file changed

+23
-2
lines changed

1 file changed

+23
-2
lines changed

src/Containers-Stack-Tests/CTStackTest.class.st

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,22 @@ CTStackTest >> testCopyHasSameContents [
9797
self assert: copy top equals: stack top
9898
]
9999

100+
{ #category : 'tests' }
101+
CTStackTest >> testCopyIsIndependent [
102+
103+
| copy |
104+
stack push: 'a'; push: 'b'.
105+
copy := stack copy.
106+
107+
"Now, modify the original stack"
108+
stack pop.
109+
stack push: 'c'.
110+
111+
self assert: copy size equals: 2.
112+
self assert: copy top equals: 'b'.
113+
self deny: copy top equals: stack top.
114+
]
115+
100116
{ #category : 'tests' }
101117
CTStackTest >> testDefaultStackCreation [
102118

@@ -273,7 +289,7 @@ CTStackTest >> testPushSingleElement [
273289
self assert: stack top equals: 'first'
274290
]
275291

276-
{ #category : 'removing' }
292+
{ #category : 'tests' }
277293
CTStackTest >> testRemoveAll [
278294

279295
stack
@@ -283,7 +299,12 @@ CTStackTest >> testRemoveAll [
283299
stack removeAll.
284300

285301
self assert: stack isEmpty.
286-
self assert: stack size equals: 0
302+
self assert: stack size equals: 0.
303+
304+
stack push: 'd'.
305+
self deny: stack isEmpty.
306+
self assert: stack size equals: 1.
307+
self assert: stack top equals: 'd'.
287308
]
288309

289310
{ #category : 'tests' }

0 commit comments

Comments
 (0)