MCPcopy
hub / github.com/josdejong/mathjs / simplifyAndCompare

Function simplifyAndCompare

test/unit-tests/function/algebra/simplify.test.js:8–42  ·  view source on GitHub ↗
(left, right, rules, scope, opt, stringOpt)

Source from the content-addressed store, hash-verified

6const expLibrary = []
7// eslint-disable-next-line mocha/no-exports
8export function simplifyAndCompare (left, right, rules, scope, opt, stringOpt) {
9 expLibrary.push(left)
10 let simpLeft
11 try {
12 if (Array.isArray(rules)) {
13 if (opt) {
14 simpLeft = math.simplify(left, rules, scope, opt)
15 } else if (scope) {
16 simpLeft = math.simplify(left, rules, scope)
17 } else {
18 simpLeft = math.simplify(left, rules)
19 }
20 } else {
21 if (opt) stringOpt = opt
22 if (scope) opt = scope
23 if (rules) scope = rules
24 if (opt) {
25 simpLeft = math.simplify(left, scope, opt)
26 } else if (scope) {
27 simpLeft = math.simplify(left, scope)
28 } else {
29 simpLeft = math.simplify(left)
30 }
31 }
32 } catch (err) {
33 if (err instanceof Error) {
34 console.log(err.stack)
35 } else {
36 console.log(new Error(err))
37 }
38 throw err
39 }
40 assert.strictEqual(
41 simpLeft.toString(stringOpt), math.parse(right).toString(stringOpt))
42}
43
44describe('simplify', function () {
45 function simplifyAndCompareEval (left, right, scope) {

Callers 2

resolve.test.jsFile · 0.90
simplify.test.jsFile · 0.85

Calls 4

simplifyMethod · 0.65
logMethod · 0.65
toStringMethod · 0.65
parseMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…