From 2730edfd601cd42b81afe74272bb57bfec9082da Mon Sep 17 00:00:00 2001 From: josdejong Date: Sun, 6 Apr 2014 13:03:45 +0200 Subject: [PATCH] Removed errors for stuff deprecated since v0.16.0 --- lib/util/bignumber.js | 8 -------- lib/util/number.js | 8 -------- test/deprecated.test.js | 12 ------------ test/type/Complex.test.js | 10 ++++++++++ 4 files changed, 10 insertions(+), 28 deletions(-) diff --git a/lib/util/bignumber.js b/lib/util/bignumber.js index 786f296ce..04fbb4b11 100644 --- a/lib/util/bignumber.js +++ b/lib/util/bignumber.js @@ -110,10 +110,6 @@ exports.format = function format(value, options) { case 'fixed': return exports.toFixed(value, precision); - // TODO: notation 'scientific' is deprecated since version 0.16.0, remove this some day - case 'scientific': - throw new Error('Format notation "scientific" is deprecated. Use "exponential" instead.'); - case 'exponential': return exports.toExponential(value, precision); @@ -130,10 +126,6 @@ exports.format = function format(value, options) { upper = options.exponential.upper; } } - else if (options && options.scientific) { - // TODO: 'options.scientific' is deprecated since version 0.16.0, remove this some day - throw new Error('options.scientific is deprecated, use options.exponential instead.'); - } // adjust the configuration of the BigNumber constructor (yeah, this is quite tricky...) var oldConfig = value.constructor.config({}); diff --git a/lib/util/number.js b/lib/util/number.js index 789cb2293..4c68814dd 100644 --- a/lib/util/number.js +++ b/lib/util/number.js @@ -139,10 +139,6 @@ exports.format = function format(value, options) { case 'fixed': return exports.toFixed(value, precision); - // TODO: notation 'scientific' is deprecated since version 0.16.0, remove this some day - case 'scientific': - throw new Error('Format notation "scientific" is deprecated. Use "exponential" instead.'); - case 'exponential': return exports.toExponential(value, precision); @@ -159,10 +155,6 @@ exports.format = function format(value, options) { upper = options.exponential.upper; } } - else if (options && options.scientific) { - // TODO: 'options.scientific' is deprecated since version 0.16.0, remove this some day - throw new Error('options.scientific is deprecated, use options.exponential instead.'); - } // handle special case zero if (value === 0) return '0'; diff --git a/test/deprecated.test.js b/test/deprecated.test.js index 91f9bbfd5..382fcefe3 100644 --- a/test/deprecated.test.js +++ b/test/deprecated.test.js @@ -74,16 +74,4 @@ describe('deprecated stuff', function() { }, /Deprecated keyword "function"/); }); - it ('should throw an error when using deprecated notation "scientific in number.format"', function () { - assert.throws(function () { - new number.format(2.3, {notation: 'scientific'}); - }, /Format notation "scientific" is deprecated/); - }); - - it ('should throw an error when using deprecated option "scientific in number.format"', function () { - assert.throws(function () { - new number.format(2.3, {notation: 'auto', scientific: 5}); - }, /options.scientific is deprecated/); - }); - }); diff --git a/test/type/Complex.test.js b/test/type/Complex.test.js index bc954aca0..b66e54370 100644 --- a/test/type/Complex.test.js +++ b/test/type/Complex.test.js @@ -32,6 +32,11 @@ describe('Complex', function () { assert.throws(function () { new Complex(true, 2); }); }); + it('should throw an error if called with wrong type of arguments', function() { + assert.throws(function () { new Complex(1, true); }); + assert.throws(function () { new Complex({}); }, /Object with the re and im or r and phi properties expected/); + }); + it('should throw an error if called without new operator', function() { assert.throws(function () { Complex(3, -4); }); }); @@ -238,6 +243,11 @@ describe('Complex', function () { assert.throws(function() { Complex.fromPolar(1, true)}); assert.throws(function() { Complex.fromPolar(1, {})}); }); + + it('should throw an error in case of wrong number of arguments', function() { + assert.throws(function() { Complex.fromPolar(1,2,3)}, /Wrong number of arguments/); + assert.throws(function() { Complex.fromPolar()}, /Wrong number of arguments/); + }); }); describe('toPolar', function() {