mirror of
https://github.com/josdejong/mathjs.git
synced 2026-01-25 15:07:57 +00:00
Fixed #190: imported, wrapped functions not accepting null and undefined as function arguments.
This commit is contained in:
parent
0fea9f0a1b
commit
aa80ae8fc8
@ -2,6 +2,12 @@
|
||||
https://github.com/josdejong/mathjs
|
||||
|
||||
|
||||
## not yet released, version 0.23.1
|
||||
|
||||
- Fixed imported, wrapped functions not accepting `null` and `undefined` as
|
||||
function arguments.
|
||||
|
||||
|
||||
## 2014-06-10, version 0.23.0
|
||||
|
||||
- Renamed some functions (everything now has a logical, camel case name):
|
||||
|
||||
@ -117,7 +117,8 @@ module.exports = function (math) {
|
||||
math[name] = function () {
|
||||
var args = [];
|
||||
for (var i = 0, len = arguments.length; i < len; i++) {
|
||||
args[i] = arguments[i].valueOf();
|
||||
var arg = arguments[i];
|
||||
args[i] = arg && arg.valueOf();
|
||||
}
|
||||
return value.apply(math, args);
|
||||
};
|
||||
|
||||
@ -59,6 +59,26 @@ describe('import', function() {
|
||||
assert.equal(math.getSizeNotWrapped(math.matrix([1,2,3])), undefined);
|
||||
});
|
||||
|
||||
it('wrapped imported functions should accept undefined and null', function () {
|
||||
math.import({
|
||||
isNull: function (obj) {
|
||||
return obj === null;
|
||||
}
|
||||
}, { wrap: true });
|
||||
assert.equal(math.isNull(null), true);
|
||||
assert.equal(math.isNull(0), false);
|
||||
|
||||
math.import({
|
||||
isUndefined: function (obj) {
|
||||
return obj === undefined;
|
||||
}
|
||||
}, { wrap: true });
|
||||
assert.equal(math.isUndefined(undefined), true);
|
||||
assert.equal(math.isUndefined(0), false);
|
||||
assert.equal(math.isUndefined(null), false);
|
||||
|
||||
});
|
||||
|
||||
it('should extend math with numbers', function() {
|
||||
// extend math.js with numbers.js
|
||||
// examples copied from https://github.com/sjkaliski/numbers.js/blob/master/examples/statistic.js
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user