mathjs
Version:
Math.js is an extensive math library for JavaScript and Node.js. It features a flexible expression parser and offers an integrated solution to work with numbers, big numbers, complex numbers, units, and matrices.
24 lines (19 loc) • 895 B
JavaScript
// test index construction
var assert = require('assert'),
error = require('../../../lib/error/index'),
math = require('../../../index');
describe('index', function() {
it('should create an index', function() {
var index = math.index([2,6]);
assert.ok(index instanceof math.type.Index);
assert.deepEqual(index._ranges, [{start:2, end:6, step:1}]);
var index2 = math.index([0,4], [5,2,-1]);
assert.ok(index2 instanceof math.type.Index);
assert.deepEqual(index2._ranges, [{start:0, end:4, step: 1}, {start:5, end: 2, step:-1}]);
});
it('should create an index from bignumbers (downgrades to numbers)', function() {
var index = math.index([math.bignumber(2), math.bignumber(6)], math.bignumber(3));
assert.ok(index instanceof math.type.Index);
assert.deepEqual(index._ranges, [{start:2, end:6, step:1}, {start: 3, end: 4, step: 1}]);
});
});