mirror of
https://github.com/josdejong/mathjs.git
synced 2026-01-25 15:07:57 +00:00
Fixed undefined variables/globals
This commit is contained in:
parent
9170e27618
commit
b0ec2d4739
@ -4,7 +4,7 @@
|
||||
* This simply preloads mathjs and drops you into a REPL to
|
||||
* help interactive debugging.
|
||||
**/
|
||||
math = require('../index')
|
||||
global.math = require('../index')
|
||||
const repl = require('repl')
|
||||
|
||||
repl.start({useGlobal: true})
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
importScripts('../../../dist/math.js')
|
||||
|
||||
// create a parser
|
||||
const parser = math.parser()
|
||||
const parser = self.math.parser()
|
||||
|
||||
self.addEventListener('message', function (event) {
|
||||
const request = JSON.parse(event.data)
|
||||
|
||||
@ -481,7 +481,7 @@ function factory (type, config, load, typed) {
|
||||
}
|
||||
|
||||
return lhs + '<span class="math-operator math-binary-operator math-explicit-binary-operator">' + escape(this.op) + '</span>' + rhs
|
||||
} else if ((args.length > 2) && ((this.getIdentifier() === 'OperatorNode:add') || (this.getIdentifier() === 'OperatorNode:multiply'))) {
|
||||
} else {
|
||||
const stringifiedArgs = args.map(function (arg, index) {
|
||||
arg = arg.toHTML(options)
|
||||
if (parens[index]) { // put in parenthesis?
|
||||
@ -491,14 +491,16 @@ function factory (type, config, load, typed) {
|
||||
return arg
|
||||
})
|
||||
|
||||
if (this.implicit && (this.getIdentifier() === 'OperatorNode:multiply') && (implicit === 'hide')) {
|
||||
return stringifiedArgs.join('<span class="math-operator math-binary-operator math-implicit-binary-operator"></span>')
|
||||
}
|
||||
if ((args.length > 2) && ((this.getIdentifier() === 'OperatorNode:add') || (this.getIdentifier() === 'OperatorNode:multiply'))) {
|
||||
if (this.implicit && (this.getIdentifier() === 'OperatorNode:multiply') && (implicit === 'hide')) {
|
||||
return stringifiedArgs.join('<span class="math-operator math-binary-operator math-implicit-binary-operator"></span>')
|
||||
}
|
||||
|
||||
return stringifiedArgs.join('<span class="math-operator math-binary-operator math-explicit-binary-operator">' + escape(this.op) + '</span>')
|
||||
} else {
|
||||
// fallback to formatting as a function call
|
||||
return '<span class="math-function">' + escape(this.fn) + '</span><span class="math-paranthesis math-round-parenthesis">(</span>' + stringifiedArgs.join('<span class="math-separator">,</span>') + '<span class="math-paranthesis math-round-parenthesis">)</span>'
|
||||
return stringifiedArgs.join('<span class="math-operator math-binary-operator math-explicit-binary-operator">' + escape(this.op) + '</span>')
|
||||
} else {
|
||||
// fallback to formatting as a function call
|
||||
return '<span class="math-function">' + escape(this.fn) + '</span><span class="math-paranthesis math-round-parenthesis">(</span>' + stringifiedArgs.join('<span class="math-separator">,</span>') + '<span class="math-paranthesis math-round-parenthesis">)</span>'
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -84,7 +84,7 @@ function factory (type, config, load, typed) {
|
||||
* @private
|
||||
*/
|
||||
function _max (array) {
|
||||
let max = undefined
|
||||
let max
|
||||
|
||||
deepForEach(array, function (value) {
|
||||
try {
|
||||
|
||||
@ -84,7 +84,7 @@ function factory (type, config, load, typed) {
|
||||
* @private
|
||||
*/
|
||||
function _min (array) {
|
||||
let min = undefined
|
||||
let min
|
||||
|
||||
deepForEach(array, function (value) {
|
||||
try {
|
||||
|
||||
@ -181,6 +181,7 @@ describe('divide', function () {
|
||||
})
|
||||
|
||||
it('should divide a matrix by a matrix containing a scalar', function () {
|
||||
const a = math.matrix([[1, 2], [3, 4]])
|
||||
assert.throws(function () { divide(a, [[1]]) })
|
||||
})
|
||||
|
||||
|
||||
@ -106,10 +106,10 @@ describe('ctranspose', function () {
|
||||
|
||||
it('should throw an error for invalid matrix transpose', function () {
|
||||
let m = math.matrix([[]])
|
||||
assert.throws(function () { transpose(m) })
|
||||
assert.throws(function () { ctranspose(m) })
|
||||
|
||||
m = math.matrix([[[1], [2]], [[3], [4]]])
|
||||
assert.throws(function () { transpose(m) })
|
||||
assert.throws(function () { ctranspose(m) })
|
||||
})
|
||||
})
|
||||
|
||||
@ -150,7 +150,7 @@ describe('ctranspose', function () {
|
||||
|
||||
it('should throw an error for invalid matrix transpose', function () {
|
||||
const m = math.matrix([[]], 'sparse')
|
||||
assert.throws(function () { transpose(m) })
|
||||
assert.throws(function () { ctranspose(m) })
|
||||
})
|
||||
})
|
||||
|
||||
|
||||
@ -141,7 +141,7 @@ describe('range', function () {
|
||||
// FIXME: should give the right error
|
||||
it.skip('should not cast a single number or boolean to string', function () {
|
||||
assert.throws(function () { range(2) }, /TypeError: Too few arguments/)
|
||||
assert.throws(function () { range(boolean) }, /TypeError: Unexpected type of argument/)
|
||||
assert.throws(function () { range(true) }, /TypeError: Unexpected type of argument/)
|
||||
})
|
||||
|
||||
it('should LaTeX range', function () {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user