mirror of
https://github.com/josdejong/mathjs.git
synced 2025-12-08 19:46:04 +00:00
35 lines
1.2 KiB
JavaScript
35 lines
1.2 KiB
JavaScript
var assert = require('assert'),
|
|
ArgumentsError = require('../../lib/error/ArgumentsError');
|
|
|
|
describe('ArgumentsError', function () {
|
|
|
|
it('should construct an ArgumentsError without max', function () {
|
|
var err = new ArgumentsError('myfunction', 1, 2);
|
|
assert(err instanceof Error);
|
|
assert(err instanceof ArgumentsError);
|
|
assert.equal(err.fn, 'myfunction');
|
|
assert.equal(err.count, 1);
|
|
assert.equal(err.min, 2);
|
|
assert.equal(err.max, undefined);
|
|
assert.equal(err.toString(), 'ArgumentsError: Wrong number of arguments in function myfunction (1 provided, 2 expected)');
|
|
});
|
|
|
|
it('should construct an ArgumentsError with max', function () {
|
|
var err = new ArgumentsError('myfunction', 1, 2, 3);
|
|
assert(err instanceof Error);
|
|
assert(err instanceof ArgumentsError);
|
|
assert.equal(err.fn, 'myfunction');
|
|
assert.equal(err.count, 1);
|
|
assert.equal(err.min, 2);
|
|
assert.equal(err.max, 3);
|
|
assert.equal(err.toString(), 'ArgumentsError: Wrong number of arguments in function myfunction (1 provided, 2-3 expected)');
|
|
});
|
|
|
|
it('should throw an error when operator new is missing', function () {
|
|
assert.throws(function () {
|
|
ArgumentsError();
|
|
}, SyntaxError);
|
|
});
|
|
|
|
});
|