Commit 660908f7 authored by Phil Booth's avatar Phil Booth

fix(code): throw from shift and unshift

parent c17715a2
......@@ -80,13 +80,14 @@ function getIndex (key, size) {
return key % size
}
Hoopy.prototype.push = () => {
const nop = () => {
throw new Error('Not implemented')
}
Hoopy.prototype.pop = () => {
throw new Error('Not implemented')
}
Hoopy.prototype.push = nop
Hoopy.prototype.pop = nop
Hoopy.prototype.shift = nop
Hoopy.prototype.unshift = nop
module.exports = Hoopy
......@@ -12,6 +12,10 @@ test('interface is correct', () => {
assert.throws(() => new Hoopy(0))
assert.doesNotThrow(() => new Hoopy(1))
assert.throws(() => new Hoopy(-1))
assert.throws(() => new Hoopy(1).push())
assert.throws(() => new Hoopy(1).pop())
assert.throws(() => new Hoopy(1).shift())
assert.throws(() => new Hoopy(1).unshift())
})
suite('instantiate, size=1:', () => {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment