HEX
Server: Apache/2.4.52 (Ubuntu)
System: Linux ip-172-31-4-197 6.8.0-1036-aws #38~22.04.1-Ubuntu SMP Fri Aug 22 15:44:33 UTC 2025 x86_64
User: ubuntu (1000)
PHP: 7.4.33
Disabled: 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,
Upload Files
File: //var/www/api-management/node_modules/alce/test/array.js
var ast = require('../lib/ast');

describe('array', function() {
  describe('#length', function() {
    it('should return length', function() {
      ast.fromValue([1, 2]).length.should.equal(2);
    });
    it('should set length', function() {
      var value = ast.fromValue([1, 2]);
      value.length = 1;
      value.toObject().should.eql([1]);
    });
  });

  describe('#splice', function() {
    it('should insert/remove', function() {
      var value = ast.fromValue([1, 2, 5]);
      value.splice(1, 4, 3, 4).should.eql([2, 5]);
      value.toObject().should.eql([1, 3, 4]);
    });
  });

  describe('#push', function() {
    it('should push new values', function() {
      var value = ast.fromValue([1, 2]);
      value.push(3, 4).should.equal(4);
      value.toObject().should.eql([1, 2, 3, 4]);
    });
  });
  describe('#pop', function() {
    it('should remove values', function() {
      var value = ast.fromValue([1, 2]);
      value.pop().should.equal(2);
      value.toObject().should.eql([1]);
    });
  });

  describe('#unshift', function() {
    it('should unshift new values', function() {
      var value = ast.fromValue([1, 2]);
      value.unshift(3, 4).should.equal(4);
      value.toObject().should.eql([3, 4, 1, 2]);
    });
  });
  describe('#shift', function() {
    it('should remove values', function() {
      var value = ast.fromValue([1, 2]);
      value.shift().should.equal(1);
      value.toObject().should.eql([2]);
    });
  });
});