Skip to content

Commit 4357cc5

Browse files
committed
1 parent 44d694d commit 4357cc5

File tree

4 files changed

+144
-123
lines changed

4 files changed

+144
-123
lines changed

__tests__/Stack.ts

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ describe('Stack', () => {
6464
it('get helpers make for easier to read code', () => {
6565
var s = Stack.of('a', 'b', 'c');
6666
expect(s.first()).toBe('a');
67+
expect(s.last()).toBe('c');
6768
expect(s.peek()).toBe('a');
6869
});
6970

@@ -83,7 +84,14 @@ describe('Stack', () => {
8384
[1,'b'],
8485
[2,'c'],
8586
]);
86-
87+
88+
// map will cause reverse iterate
89+
expect(s.map(val => val + val).toArray()).toEqual([
90+
'aa',
91+
'bb',
92+
'cc',
93+
]);
94+
8795
var iteratorResults = [];
8896
var iterator = s.entries();
8997
var step;
@@ -95,6 +103,17 @@ describe('Stack', () => {
95103
[1,'b'],
96104
[2,'c'],
97105
]);
106+
107+
iteratorResults = [];
108+
iterator = s.toSeq().reverse().entries();
109+
while (!(step = iterator.next()).done) {
110+
iteratorResults.push(step.value);
111+
}
112+
expect(iteratorResults).toEqual([
113+
[0,'c'],
114+
[1,'b'],
115+
[2,'a'],
116+
]);
98117
});
99118

100119
it('push inserts at lowest index', () => {

0 commit comments

Comments
 (0)