mirror of
https://github.com/josdejong/mathjs.git
synced 2025-12-08 19:46:04 +00:00
This is a sequel to #2531. Uniformizes the signatures of ceil, fix, floor, and round, and updates the TypeScript declarations to match. Adds the optional "number of places" argument to the chain versions of ceil, fix, and floor. Adds TypeScript tests for all rounding functions. Also corrects the TypeScript declaration for `bignumber()` and introduces a couple more common abbreviations for TypeScript types. Fixes the number-only implementations of floor, ceil, fix, and nthRoot to match the full implementation behavior on numbers, and tests this for floor. Includes some minor documentation updates and additional unit tests for the rounding functions. Reverts inclusion in AUTHORS of incorrect email for one contributor, that occurred in #2531. Resolves #2526. Resolves #2529.
24 lines
817 B
JavaScript
24 lines
817 B
JavaScript
// Only use native node.js API's and references to ./lib here, this file is not transpiled!
|
|
const assert = require('assert')
|
|
const cp = require('child_process')
|
|
const path = require('path')
|
|
|
|
describe('lib/cjs', function () {
|
|
it('should load via commonjs', function (done) {
|
|
const filename = path.join(__dirname, 'commonjsApp.cjs')
|
|
cp.exec('node ' + filename, function (error, result) {
|
|
assert.strictEqual(error, null)
|
|
assert.strictEqual(result, '2\n2i\n')
|
|
done()
|
|
})
|
|
})
|
|
it('should load numbers only via commonjs', function (done) {
|
|
const filename = path.join(__dirname, 'commonjsAppNumberOnly.cjs')
|
|
cp.exec('node ' + filename, function (error, result) {
|
|
assert.strictEqual(error, null)
|
|
assert.strictEqual(result, '2\nNaN\n2\n4\n7\n')
|
|
done()
|
|
})
|
|
})
|
|
})
|