Skip to content

Commit ae271c2

Browse files
committed
test: In doc test, ignore comment-only lines that don't say "returns/throws"
Plus knock-on changes. This "simple" change unsurprisingly altered what doc tests occurred, leading to shaking out a bug in doc testing, which in turn shook out a bug in logical `and` (!). All should be well now. Also prevent `numeric(blah, 'bigint')` from throwing when it needs to round.
1 parent c87c980 commit ae271c2

File tree

28 files changed

+122
-76
lines changed

28 files changed

+122
-76
lines changed

src/core/function/import.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ export function importFactory (typed, load, math, importedFactories) {
4545
* return 'hello, ' + name + '!'
4646
* }
4747
* })
48-
* // use the imported function and variable
48+
* // use the imported function and variable
4949
* math.myvalue * 2 // 84
5050
*
5151
* math.hello('user') // 'hello, user!'

src/function/algebra/polynomialRoot.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,17 +42,18 @@ export const createPolynomialRoot = /* #__PURE__ */ factory(name, dependencies,
4242
* math.polynomialRoot(constant, linearCoeff, quadraticCoeff, cubicCoeff)
4343
*
4444
* Examples:
45-
* // linear
45+
* // linear
4646
* math.polynomialRoot(6, 3) // [-2]
4747
* math.polynomialRoot(math.complex(6,3), 3) // [-2 - i]
4848
* math.polynomialRoot(math.complex(6,3), math.complex(2,1)) // [-3 + 0i]
49-
* // quadratic
49+
* // quadratic
5050
* math.polynomialRoot(2, -3, 1) // [2, 1]
5151
* math.polynomialRoot(8, 8, 2) // [-2]
5252
* math.polynomialRoot(-2, 0, 1) // [1.4142135623730951, -1.4142135623730951]
5353
* math.polynomialRoot(2, -2, 1) // [1 + i, 1 - i]
5454
* math.polynomialRoot(math.complex(1,3), math.complex(-3, -2), 1) // [2 + i, 1 + i]
55-
* // cubic
55+
*
56+
* // cubic
5657
* math.polynomialRoot(-6, 11, -6, 1) // [1, 3, 2]
5758
* math.polynomialRoot(-8, 0, 0, 1) // [-1 - 1.7320508075688774i, 2, -1 + 1.7320508075688774i]
5859
* math.polynomialRoot(0, 8, 8, 2) // [0, -2]

src/function/algebra/rationalize.js

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -75,24 +75,24 @@ export const createRationalize = /* #__PURE__ */ factory(name, dependencies, ({
7575
* Examples:
7676
*
7777
* math.rationalize('sin(x)+y')
78-
* // Error: There is an unsolved function call
79-
* math.rationalize('2x/y - y/(x+1)')
80-
* // (2*x^2-y^2+2*x)/(x*y+y)
81-
* math.rationalize('(2x+1)^6')
82-
* // 64*x^6+192*x^5+240*x^4+160*x^3+60*x^2+12*x+1
78+
* // throws Error: There is an unsolved function call
79+
* math.rationalize('2x/y - y/(x+1)') // (2*x^2-y^2+2*x)/(x*y+y)
80+
* // math.rationalize('(2x+1)^6') // hangs, see #3351
81+
* // returns 64*x^6+192*x^5+240*x^4+160*x^3+60*x^2+12*x+1
8382
* math.rationalize('2x/( (2x-1) / (3x+2) ) - 5x/ ( (3x+4) / (2x^2-5) ) + 3')
84-
* // -20*x^4+28*x^3+104*x^2+6*x-12)/(6*x^2+5*x-4)
85-
* math.rationalize('x/(1-x)/(x-2)/(x-3)/(x-4) + 2x/ ( (1-2x)/(2-3x) )/ ((3-4x)/(4-5x) )') =
86-
* // (-30*x^7+344*x^6-1506*x^5+3200*x^4-3472*x^3+1846*x^2-381*x)/
87-
* // (-8*x^6+90*x^5-383*x^4+780*x^3-797*x^2+390*x-72)
83+
* // returns -20*x^4+28*x^3+104*x^2+6*x-12)/(6*x^2+5*x-4)
84+
* // math.rationalize('x/(1-x)/(x-2)/(x-3)/(x-4) + 2x/ ( (1-2x)/(2-3x) )/ ((3-4x)/(4-5x) )') // hangs, see #3351
85+
* // returns (-30*x^7+344*x^6-1506*x^5+3200*x^4-3472*x^3+1846*x^2-381*x)/(-8*x^6+90*x^5-383*x^4+780*x^3-797*x^2+390*x-72)
8886
*
8987
* math.rationalize('x+x+x+y',{y:1}) // 3*x+1
9088
* math.rationalize('x+x+x+y',{}) // 3*x+y
9189
*
92-
* const ret = math.rationalize('x+x+x+y',{},true)
93-
* // ret.expression=3*x+y, ret.variables = ["x","y"]
94-
* const ret = math.rationalize('-2+5x^2',{},true)
95-
* // ret.expression=5*x^2-2, ret.variables = ["x"], ret.coefficients=[-2,0,5]
90+
* const r = math.rationalize('x+x+x+y',{},true);
91+
* [r.expression.toString(), r.variables] // ['3 * x + y', ['x', 'y']]
92+
*
93+
* const ret = math.rationalize('-2+5x^2',{},true);
94+
* [ret.expression.toString(), ret.variables, ret.coefficients]
95+
* // returns ['5 * x ^ 2 - 2', ['x'], [-2,0,5]]
9696
*
9797
* See also:
9898
*

src/function/algebra/solver/lsolve.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ export const createLsolve = /* #__PURE__ */ factory(name, dependencies, ({ typed
2828
*
2929
* const a = [[-2, 3], [2, 1]]
3030
* const b = [11, 9]
31-
* const x = lsolve(a, b) // [[-5.5], [20]]
31+
* math.lsolve(a, b) // [[-5.5], [20]]
3232
*
3333
* See also:
3434
*

src/function/algebra/solver/lsolveAll.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ export const createLsolveAll = /* #__PURE__ */ factory(name, dependencies, ({ ty
2828
*
2929
* const a = [[-2, 3], [2, 1]]
3030
* const b = [11, 9]
31-
* const x = lsolveAll(a, b) // [ [[-5.5], [20]] ]
31+
* math.lsolveAll(a, b) // [ [[-5.5], [20]] ]
3232
*
3333
* See also:
3434
*

src/function/algebra/solver/usolve.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ export const createUsolve = /* #__PURE__ */ factory(name, dependencies, ({ typed
2828
*
2929
* const a = [[-2, 3], [2, 1]]
3030
* const b = [11, 9]
31-
* const x = usolve(a, b) // [[8], [9]]
31+
* math.usolve(a, b) // [[8], [9]]
3232
*
3333
* See also:
3434
*

src/function/algebra/solver/usolveAll.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ export const createUsolveAll = /* #__PURE__ */ factory(name, dependencies, ({ ty
2828
*
2929
* const a = [[-2, 3], [2, 1]]
3030
* const b = [11, 9]
31-
* const x = usolveAll(a, b) // [ [[8], [9]] ]
31+
* math.usolveAll(a, b) // [ [[8], [9]] ]
3232
*
3333
* See also:
3434
*

src/function/arithmetic/add.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ export const createAdd = /* #__PURE__ */ factory(
4545
*
4646
* const c = math.unit('5 cm')
4747
* const d = math.unit('2.1 mm')
48-
* math.add(c, d) // returns Unit 52.1 mm
48+
* math.add(c, d) // returns Unit 5.21 cm
4949
*
5050
* math.add("2.3", "4") // returns number 6.3
5151
*

src/function/arithmetic/cbrt.js

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -37,11 +37,8 @@ export const createCbrt = /* #__PURE__ */ factory(name, dependencies, ({ config,
3737
*
3838
* const x = math.complex('8i')
3939
* math.cbrt(x) // returns Complex 1.7320508075689 + i
40-
* math.cbrt(x, true) // returns Matrix [
41-
* // 1.7320508075689 + i
42-
* // -1.7320508075689 + i
43-
* // -2i
44-
* // ]
40+
* math.cbrt(x, true)
41+
* // returns [1.7320508075689 + i, -1.7320508075689 + i, -2i]
4542
*
4643
* See also:
4744
*

src/function/arithmetic/dotDivide.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,8 @@ export const createDotDivide = /* #__PURE__ */ factory(name, dependencies, ({ ty
3737
*
3838
* math.dotDivide(2, 4) // returns 0.5
3939
*
40-
* a = [[9, 5], [6, 1]]
41-
* b = [[3, 2], [5, 2]]
42-
*
40+
* const a = [[9, 5], [6, 1]]
41+
* const b = [[3, 2], [5, 2]]
4342
* math.dotDivide(a, b) // returns [[3, 2.5], [1.2, 0.5]]
4443
* math.divide(a, b) // returns [[1.75, 0.75], [-1.75, 2.25]]
4544
*

0 commit comments

Comments
 (0)