Sha256: 74e598b309a0ab4bc0bcdfefcf79c4684ad67b87ba656836b3d255c058bbc5fb

Contents?: true

Size: 1.56 KB

Versions: 255

Compression:

Stored size: 1.56 KB

Contents

var BigInt = require('./big-integer');


describe('The big-integer module\'s returned object', function () {
  var bigI;

  beforeEach(function() {
    bigI = BigInt(42);
  });

  afterEach(function() {
    bigI = null;
  });

  it('is not a number', function () {
    expect(typeof 42).toBe('number');
    expect(typeof bigI).not.toBe('number');
    expect(typeof bigI).toBe('object');
  });

  it('can be compared to a stringified number by calling \'.toString()\'',
     function () {

    expect(bigI).not.toBe(42);
    expect(bigI).not.toBe('42');
    expect(bigI.toString()).toBe('42');
    // NOTE:
    // The '==' operator calls '.toString()' here in order to compare.
    expect(bigI == '42').toBe(true);
    // While the line above is easier to write and read, we will use the
    // 'expect(bigI.toString()).toBe(expected)' way so that test failure
    // messages will be more informative. Eg,
    // "Expected '84' to be '42'." instead of
    // "Expected false to be true."
  });

  it('is immutable', function () {
    bigI.add(10);
    expect(bigI.toString()).toBe('42');
    bigI.subtract(10);
    expect(bigI.toString()).toBe('42');
  });

  it('can add', function () {
    bigI = bigI.add(42);

    expect(bigI.toString()).toBe('84');
  });

  it('can perform power operations', function () {
    bigI = BigInt(10);
    bigI = bigI.pow(2);
    expect(bigI.toString()).toBe('100');
  });

  // ...see the official docs for more info, if you want.
  // The "Methods" section of the README is especially useful:
  //
  // https://github.com/peterolson/BigInteger.js#methods
});

Version data entries

255 entries across 255 versions & 1 rubygems

Version Path
trackler-2.2.1.37 tracks/javascript/exercises/grains/big-integer.spec.js
trackler-2.2.1.36 tracks/javascript/exercises/grains/big-integer.spec.js
trackler-2.2.1.35 tracks/javascript/exercises/grains/big-integer.spec.js
trackler-2.2.1.34 tracks/javascript/exercises/grains/big-integer.spec.js
trackler-2.2.1.33 tracks/javascript/exercises/grains/big-integer.spec.js
trackler-2.2.1.32 tracks/javascript/exercises/grains/big-integer.spec.js
trackler-2.2.1.31 tracks/javascript/exercises/grains/big-integer.spec.js
trackler-2.2.1.30 tracks/javascript/exercises/grains/big-integer.spec.js
trackler-2.2.1.29 tracks/javascript/exercises/grains/big-integer.spec.js
trackler-2.2.1.28 tracks/javascript/exercises/grains/big-integer.spec.js
trackler-2.2.1.27 tracks/javascript/exercises/grains/big-integer.spec.js
trackler-2.2.1.26 tracks/javascript/exercises/grains/big-integer.spec.js
trackler-2.2.1.25 tracks/javascript/exercises/grains/big-integer.spec.js
trackler-2.2.1.24 tracks/javascript/exercises/grains/big-integer.spec.js
trackler-2.2.1.23 tracks/javascript/exercises/grains/big-integer.spec.js
trackler-2.2.1.22 tracks/javascript/exercises/grains/big-integer.spec.js
trackler-2.2.1.21 tracks/javascript/exercises/grains/big-integer.spec.js
trackler-2.2.1.20 tracks/javascript/exercises/grains/big-integer.spec.js
trackler-2.2.1.19 tracks/javascript/exercises/grains/big-integer.spec.js
trackler-2.2.1.18 tracks/javascript/exercises/grains/big-integer.spec.js