11cb0ef41Sopenharmony_ci// Flags: --expose-internals
21cb0ef41Sopenharmony_ci'use strict';
31cb0ef41Sopenharmony_ci
41cb0ef41Sopenharmony_cirequire('../common');
51cb0ef41Sopenharmony_ci
61cb0ef41Sopenharmony_ciconst assert = require('assert');
71cb0ef41Sopenharmony_ciconst FixedQueue = require('internal/fixed_queue');
81cb0ef41Sopenharmony_ci
91cb0ef41Sopenharmony_ci{
101cb0ef41Sopenharmony_ci  const queue = new FixedQueue();
111cb0ef41Sopenharmony_ci  assert.strictEqual(queue.head, queue.tail);
121cb0ef41Sopenharmony_ci  assert(queue.isEmpty());
131cb0ef41Sopenharmony_ci  queue.push('a');
141cb0ef41Sopenharmony_ci  assert(!queue.isEmpty());
151cb0ef41Sopenharmony_ci  assert.strictEqual(queue.shift(), 'a');
161cb0ef41Sopenharmony_ci  assert.strictEqual(queue.shift(), null);
171cb0ef41Sopenharmony_ci}
181cb0ef41Sopenharmony_ci
191cb0ef41Sopenharmony_ci{
201cb0ef41Sopenharmony_ci  const queue = new FixedQueue();
211cb0ef41Sopenharmony_ci  for (let i = 0; i < 2047; i++)
221cb0ef41Sopenharmony_ci    queue.push('a');
231cb0ef41Sopenharmony_ci  assert(queue.head.isFull());
241cb0ef41Sopenharmony_ci  queue.push('a');
251cb0ef41Sopenharmony_ci  assert(!queue.head.isFull());
261cb0ef41Sopenharmony_ci
271cb0ef41Sopenharmony_ci  assert.notStrictEqual(queue.head, queue.tail);
281cb0ef41Sopenharmony_ci  for (let i = 0; i < 2047; i++)
291cb0ef41Sopenharmony_ci    assert.strictEqual(queue.shift(), 'a');
301cb0ef41Sopenharmony_ci  assert.strictEqual(queue.head, queue.tail);
311cb0ef41Sopenharmony_ci  assert(!queue.isEmpty());
321cb0ef41Sopenharmony_ci  assert.strictEqual(queue.shift(), 'a');
331cb0ef41Sopenharmony_ci  assert(queue.isEmpty());
341cb0ef41Sopenharmony_ci}
35