mathjs
Version:
Math.js is an extensive math library for JavaScript and Node.js. It features a flexible expression parser with support for symbolic computation, comes with a large set of built-in functions and constants, and offers an integrated solution to work with dif
41 lines (35 loc) • 1.02 kB
JavaScript
var assert = require('assert')
var cp = require('child_process')
function run(args, done) {
cp.exec('bin/cli.js "' + args +'"', function(e,r) {
done(e, r.replace(/\n$/g, ''))
})
}
describe('evaluate expression', function() {
it('should sum numbers', function(done) {
run('1+1', function(e, result) {
assert.equal(result, 2)
done()
})
})
it('should multiply matrices', function(done) {
run('[1,2] * [3,4]', function(e, result) {
assert.equal(result, 11)
done()
})
})
it('should thow error', function(done) {
run('y=x', function(e, result) {
assert.equal(/^Error/g.test(e.toString()),true)
done()
})
})
it('should interpret scripts', function(done) {
run('test/cli/script1" "test/cli/script2', function(e, result){
result = result.split('\n')
assert.equal(result[0], 2)
assert.equal(result[1], 8)
done()
})
})
})