MCPcopy Create free account
hub / github.com/cortex-js/compute-engine / checkSimplify

Function checkSimplify

test/compute-engine/simplify.test.ts:11–28  ·  view source on GitHub ↗

* Helper: parse input, simplify, check semantic equality with expected. * On failure, reports LaTeX for readability.

(
  input: string | Expression,
  expected: string | number | Expression
)

Source from the content-addressed store, hash-verified

9 * On failure, reports LaTeX for readability.
10 */
11function checkSimplify(
12 input: string | Expression,
13 expected: string | number | Expression
14) {
15 const a = typeof input === 'string' ? ce.parse(input) : ce.expr(input);
16 const b =
17 typeof expected === 'number'
18 ? ce.expr(expected)
19 : typeof expected === 'string'
20 ? ce.parse(expected)
21 : ce.expr(expected);
22
23 const result = a.simplify();
24 if (!result.isSame(b)) {
25 // Provide readable failure message
26 expect(`${result.latex}`).toBe(`${b.latex}`);
27 }
28}
29
30// ============================================================
31// CANONICALIZATION TEST CASES

Callers 1

simplify.test.tsFile · 0.70

Calls 4

parseMethod · 0.65
exprMethod · 0.65
simplifyMethod · 0.65
isSameMethod · 0.65

Tested by

no test coverage detected