Skip to content

Commit a898bfd

Browse files
committed
test(L-I): Stack
1 parent b119835 commit a898bfd

File tree

1 file changed

+32
-0
lines changed

1 file changed

+32
-0
lines changed

L-I/0003 Stack ( L-I )/Test.js

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
const { strict: assert } = require('assert')
2+
3+
const Stack = require('./Stack.js')
4+
5+
const stack = new Stack()
6+
7+
stack.push('foo')
8+
9+
assert.equal(stack.size, 1)
10+
11+
stack.push('bar')
12+
13+
assert.equal(stack.size, 2)
14+
15+
assert.equal(stack.peek(), 'bar')
16+
assert.equal(stack.size, 2)
17+
assert.equal(stack.pop(), 'bar')
18+
assert.equal(stack.size, 1)
19+
assert.equal(stack.peek(), 'foo')
20+
assert.equal(stack.size, 1)
21+
22+
stack.push('foobar')
23+
24+
assert.equal(stack.size, 2)
25+
assert.equal(stack.peek(), 'foobar')
26+
assert.equal(stack.size, 2)
27+
assert.equal(stack.pop(), 'foobar')
28+
assert.equal(stack.size, 1)
29+
assert.equal(stack.pop(), 'foo')
30+
assert.equal(stack.size, 0)
31+
32+
console.log('All tests success')

0 commit comments

Comments
 (0)