From: Jérôme Benoit Date: Sat, 25 May 2024 15:36:39 +0000 (+0200) Subject: test: comment out fixed priority queue tests X-Git-Tag: v4.0.13~17 X-Git-Url: https://git.piment-noir.org/?a=commitdiff_plain;h=f3230413d6a37d39f07457707a549f8e6c225610;p=poolifier.git test: comment out fixed priority queue tests Signed-off-by: Jérôme Benoit --- diff --git a/tests/fixed-priority-queue.test.mjs b/tests/fixed-priority-queue.test.mjs index 4821d387..b70bc17f 100644 --- a/tests/fixed-priority-queue.test.mjs +++ b/tests/fixed-priority-queue.test.mjs @@ -1,161 +1,161 @@ -import { expect } from 'expect' +// import { expect } from 'expect' -import { - defaultQueueSize, - FixedPriorityQueue -} from '../lib/fixed-priority-queue.cjs' +// import { +// defaultQueueSize, +// FixedPriorityQueue +// } from '../lib/fixed-priority-queue.cjs' -describe.skip('Fixed Priority queue test suite', () => { - it('Verify constructor() behavior', () => { - expect(() => new FixedPriorityQueue('')).toThrow( - new TypeError('Invalid fixed priority queue size: is not an integer') - ) - expect(() => new FixedPriorityQueue(-1)).toThrow( - new RangeError('Invalid fixed priority queue size: -1 < 0') - ) - let fixedPriorityQueue = new FixedPriorityQueue() - expect(fixedPriorityQueue.start).toBe(0) - expect(fixedPriorityQueue.size).toBe(0) - expect(fixedPriorityQueue.maxSize).toBe(0) - expect(fixedPriorityQueue.nodeArray).toBeInstanceOf(Array) - expect(fixedPriorityQueue.nodeArray.length).toBe(defaultQueueSize) - fixedPriorityQueue = new FixedPriorityQueue(2) - expect(fixedPriorityQueue.start).toBe(0) - expect(fixedPriorityQueue.size).toBe(0) - expect(fixedPriorityQueue.maxSize).toBe(0) - expect(fixedPriorityQueue.nodeArray).toBeInstanceOf(Array) - expect(fixedPriorityQueue.nodeArray.length).toBe(2) - }) +// describe('Fixed Priority queue test suite', () => { +// it('Verify constructor() behavior', () => { +// expect(() => new FixedPriorityQueue('')).toThrow( +// new TypeError('Invalid fixed priority queue size: is not an integer') +// ) +// expect(() => new FixedPriorityQueue(-1)).toThrow( +// new RangeError('Invalid fixed priority queue size: -1 < 0') +// ) +// let fixedPriorityQueue = new FixedPriorityQueue() +// expect(fixedPriorityQueue.start).toBe(0) +// expect(fixedPriorityQueue.size).toBe(0) +// expect(fixedPriorityQueue.maxSize).toBe(0) +// expect(fixedPriorityQueue.nodeArray).toBeInstanceOf(Array) +// expect(fixedPriorityQueue.nodeArray.length).toBe(defaultQueueSize) +// fixedPriorityQueue = new FixedPriorityQueue(2) +// expect(fixedPriorityQueue.start).toBe(0) +// expect(fixedPriorityQueue.size).toBe(0) +// expect(fixedPriorityQueue.maxSize).toBe(0) +// expect(fixedPriorityQueue.nodeArray).toBeInstanceOf(Array) +// expect(fixedPriorityQueue.nodeArray.length).toBe(2) +// }) - it('Verify enqueue() behavior', () => { - const fixedPriorityQueue = new FixedPriorityQueue() - let rtSize = fixedPriorityQueue.enqueue(1) - expect(fixedPriorityQueue.start).toBe(0) - expect(fixedPriorityQueue.size).toBe(1) - expect(fixedPriorityQueue.maxSize).toBe(1) - expect(rtSize).toBe(fixedPriorityQueue.size) - expect(fixedPriorityQueue.nodeArray).toMatchObject([ - { data: 1, priority: 0 } - ]) - rtSize = fixedPriorityQueue.enqueue(2) - expect(fixedPriorityQueue.start).toBe(0) - expect(fixedPriorityQueue.size).toBe(2) - expect(fixedPriorityQueue.maxSize).toBe(2) - expect(rtSize).toBe(fixedPriorityQueue.size) - expect(fixedPriorityQueue.nodeArray).toMatchObject([ - { data: 1, priority: 0 }, - { data: 2, priority: 0 } - ]) - rtSize = fixedPriorityQueue.enqueue(3) - expect(fixedPriorityQueue.start).toBe(0) - expect(fixedPriorityQueue.size).toBe(3) - expect(fixedPriorityQueue.maxSize).toBe(3) - expect(rtSize).toBe(fixedPriorityQueue.size) - expect(fixedPriorityQueue.nodeArray).toMatchObject([ - { data: 1, priority: 0 }, - { data: 2, priority: 0 }, - { data: 3, priority: 0 } - ]) - rtSize = fixedPriorityQueue.enqueue(3, -1) - expect(fixedPriorityQueue.start).toBe(0) - expect(fixedPriorityQueue.size).toBe(4) - expect(fixedPriorityQueue.maxSize).toBe(4) - expect(rtSize).toBe(fixedPriorityQueue.size) - expect(fixedPriorityQueue.nodeArray).toMatchObject([ - { data: 3, priority: -1 }, - { data: 1, priority: 0 }, - { data: 2, priority: 0 }, - { data: 3, priority: 0 } - ]) - rtSize = fixedPriorityQueue.enqueue(1, 1) - expect(fixedPriorityQueue.start).toBe(0) - expect(fixedPriorityQueue.size).toBe(5) - expect(fixedPriorityQueue.maxSize).toBe(5) - expect(rtSize).toBe(fixedPriorityQueue.size) - expect(fixedPriorityQueue.nodeArray).toMatchObject([ - { data: 3, priority: -1 }, - { data: 1, priority: 0 }, - { data: 2, priority: 0 }, - { data: 3, priority: 0 }, - { data: 1, priority: 1 } - ]) - }) +// it('Verify enqueue() behavior', () => { +// const fixedPriorityQueue = new FixedPriorityQueue() +// let rtSize = fixedPriorityQueue.enqueue(1) +// expect(fixedPriorityQueue.start).toBe(0) +// expect(fixedPriorityQueue.size).toBe(1) +// expect(fixedPriorityQueue.maxSize).toBe(1) +// expect(rtSize).toBe(fixedPriorityQueue.size) +// expect(fixedPriorityQueue.nodeArray).toMatchObject([ +// { data: 1, priority: 0 } +// ]) +// rtSize = fixedPriorityQueue.enqueue(2) +// expect(fixedPriorityQueue.start).toBe(0) +// expect(fixedPriorityQueue.size).toBe(2) +// expect(fixedPriorityQueue.maxSize).toBe(2) +// expect(rtSize).toBe(fixedPriorityQueue.size) +// expect(fixedPriorityQueue.nodeArray).toMatchObject([ +// { data: 1, priority: 0 }, +// { data: 2, priority: 0 } +// ]) +// rtSize = fixedPriorityQueue.enqueue(3) +// expect(fixedPriorityQueue.start).toBe(0) +// expect(fixedPriorityQueue.size).toBe(3) +// expect(fixedPriorityQueue.maxSize).toBe(3) +// expect(rtSize).toBe(fixedPriorityQueue.size) +// expect(fixedPriorityQueue.nodeArray).toMatchObject([ +// { data: 1, priority: 0 }, +// { data: 2, priority: 0 }, +// { data: 3, priority: 0 } +// ]) +// rtSize = fixedPriorityQueue.enqueue(3, -1) +// expect(fixedPriorityQueue.start).toBe(0) +// expect(fixedPriorityQueue.size).toBe(4) +// expect(fixedPriorityQueue.maxSize).toBe(4) +// expect(rtSize).toBe(fixedPriorityQueue.size) +// expect(fixedPriorityQueue.nodeArray).toMatchObject([ +// { data: 3, priority: -1 }, +// { data: 1, priority: 0 }, +// { data: 2, priority: 0 }, +// { data: 3, priority: 0 } +// ]) +// rtSize = fixedPriorityQueue.enqueue(1, 1) +// expect(fixedPriorityQueue.start).toBe(0) +// expect(fixedPriorityQueue.size).toBe(5) +// expect(fixedPriorityQueue.maxSize).toBe(5) +// expect(rtSize).toBe(fixedPriorityQueue.size) +// expect(fixedPriorityQueue.nodeArray).toMatchObject([ +// { data: 3, priority: -1 }, +// { data: 1, priority: 0 }, +// { data: 2, priority: 0 }, +// { data: 3, priority: 0 }, +// { data: 1, priority: 1 } +// ]) +// }) - it('Verify dequeue() behavior', () => { - const fixedPriorityQueue = new FixedPriorityQueue() - fixedPriorityQueue.enqueue(1) - fixedPriorityQueue.enqueue(2, -1) - fixedPriorityQueue.enqueue(3) - expect(fixedPriorityQueue.start).toBe(0) - expect(fixedPriorityQueue.size).toBe(3) - expect(fixedPriorityQueue.maxSize).toBe(3) - let rtItem = fixedPriorityQueue.dequeue() - expect(fixedPriorityQueue.start).toBe(1) - expect(fixedPriorityQueue.size).toBe(2) - expect(fixedPriorityQueue.maxSize).toBe(3) - expect(rtItem).toBe(2) - expect(fixedPriorityQueue.nodeArray).toMatchObject([ - { data: 2, priority: -1 }, - { data: 1, priority: 0 }, - { data: 3, priority: 0 } - ]) - rtItem = fixedPriorityQueue.dequeue() - expect(fixedPriorityQueue.start).toBe(2) - expect(fixedPriorityQueue.size).toBe(1) - expect(fixedPriorityQueue.maxSize).toBe(3) - expect(rtItem).toBe(1) - expect(fixedPriorityQueue.nodeArray).toMatchObject([ - { data: 2, priority: -1 }, - { data: 1, priority: 0 }, - { data: 3, priority: 0 } - ]) - rtItem = fixedPriorityQueue.dequeue() - expect(fixedPriorityQueue.start).toBe(3) - expect(fixedPriorityQueue.size).toBe(0) - expect(fixedPriorityQueue.maxSize).toBe(3) - expect(rtItem).toBe(3) - expect(fixedPriorityQueue.nodeArray).toMatchObject([ - { data: 2, priority: -1 }, - { data: 1, priority: 0 }, - { data: 3, priority: 0 } - ]) - expect(fixedPriorityQueue.dequeue()).toBe(undefined) - }) +// it('Verify dequeue() behavior', () => { +// const fixedPriorityQueue = new FixedPriorityQueue() +// fixedPriorityQueue.enqueue(1) +// fixedPriorityQueue.enqueue(2, -1) +// fixedPriorityQueue.enqueue(3) +// expect(fixedPriorityQueue.start).toBe(0) +// expect(fixedPriorityQueue.size).toBe(3) +// expect(fixedPriorityQueue.maxSize).toBe(3) +// let rtItem = fixedPriorityQueue.dequeue() +// expect(fixedPriorityQueue.start).toBe(1) +// expect(fixedPriorityQueue.size).toBe(2) +// expect(fixedPriorityQueue.maxSize).toBe(3) +// expect(rtItem).toBe(2) +// expect(fixedPriorityQueue.nodeArray).toMatchObject([ +// { data: 2, priority: -1 }, +// { data: 1, priority: 0 }, +// { data: 3, priority: 0 } +// ]) +// rtItem = fixedPriorityQueue.dequeue() +// expect(fixedPriorityQueue.start).toBe(2) +// expect(fixedPriorityQueue.size).toBe(1) +// expect(fixedPriorityQueue.maxSize).toBe(3) +// expect(rtItem).toBe(1) +// expect(fixedPriorityQueue.nodeArray).toMatchObject([ +// { data: 2, priority: -1 }, +// { data: 1, priority: 0 }, +// { data: 3, priority: 0 } +// ]) +// rtItem = fixedPriorityQueue.dequeue() +// expect(fixedPriorityQueue.start).toBe(3) +// expect(fixedPriorityQueue.size).toBe(0) +// expect(fixedPriorityQueue.maxSize).toBe(3) +// expect(rtItem).toBe(3) +// expect(fixedPriorityQueue.nodeArray).toMatchObject([ +// { data: 2, priority: -1 }, +// { data: 1, priority: 0 }, +// { data: 3, priority: 0 } +// ]) +// expect(fixedPriorityQueue.dequeue()).toBe(undefined) +// }) - it('Verify iterator behavior', () => { - const fixedPriorityQueue = new FixedPriorityQueue() - fixedPriorityQueue.enqueue(1) - fixedPriorityQueue.enqueue(2) - fixedPriorityQueue.enqueue(3) - let i = fixedPriorityQueue.start + 1 - for (const value of fixedPriorityQueue) { - expect(value).toBe(i) - ++i - } - fixedPriorityQueue.dequeue() - i = fixedPriorityQueue.start + 1 - for (const value of fixedPriorityQueue) { - expect(value).toBe(i) - ++i - } - }) +// it('Verify iterator behavior', () => { +// const fixedPriorityQueue = new FixedPriorityQueue() +// fixedPriorityQueue.enqueue(1) +// fixedPriorityQueue.enqueue(2) +// fixedPriorityQueue.enqueue(3) +// let i = fixedPriorityQueue.start + 1 +// for (const value of fixedPriorityQueue) { +// expect(value).toBe(i) +// ++i +// } +// fixedPriorityQueue.dequeue() +// i = fixedPriorityQueue.start + 1 +// for (const value of fixedPriorityQueue) { +// expect(value).toBe(i) +// ++i +// } +// }) - it('Verify clear() behavior', () => { - const fixedPriorityQueue = new FixedPriorityQueue() - fixedPriorityQueue.start = 1 - fixedPriorityQueue.size = 2 - fixedPriorityQueue.maxSize = 2 - fixedPriorityQueue.nodeArray = [ - { data: 2, priority: 0 }, - { data: 3, priority: 0 } - ] - fixedPriorityQueue.clear() - expect(fixedPriorityQueue.start).toBe(0) - expect(fixedPriorityQueue.size).toBe(0) - expect(fixedPriorityQueue.maxSize).toBe(0) - expect(fixedPriorityQueue.nodeArray).toMatchObject([ - { data: 2, priority: 0 }, - { data: 3, priority: 0 } - ]) - }) -}) +// it('Verify clear() behavior', () => { +// const fixedPriorityQueue = new FixedPriorityQueue() +// fixedPriorityQueue.start = 1 +// fixedPriorityQueue.size = 2 +// fixedPriorityQueue.maxSize = 2 +// fixedPriorityQueue.nodeArray = [ +// { data: 2, priority: 0 }, +// { data: 3, priority: 0 } +// ] +// fixedPriorityQueue.clear() +// expect(fixedPriorityQueue.start).toBe(0) +// expect(fixedPriorityQueue.size).toBe(0) +// expect(fixedPriorityQueue.maxSize).toBe(0) +// expect(fixedPriorityQueue.nodeArray).toMatchObject([ +// { data: 2, priority: 0 }, +// { data: 3, priority: 0 } +// ]) +// }) +// })