This repository was archived by the owner on Aug 29, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 282
Expand file tree
/
Copy pathchecks.test.js
More file actions
54 lines (48 loc) · 1.64 KB
/
checks.test.js
File metadata and controls
54 lines (48 loc) · 1.64 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
const checks = require('../../lib/checks');
const TestUtil = require('../TestUtil');
function testCanCombine(exprStr, canCombine) {
TestUtil.testBooleanFunction(checks.canSimplifyPolynomialTerms, exprStr, canCombine);
}
describe('canSimplifyPolynomialTerms multiplication', function() {
const tests = [
['x^2 * x * x', true],
// false b/c coefficient
['x^2 * 3x * x', false],
['y * y^3', true],
['5 * y^3', false], // just needs flattening
['5/7 * x', false], // just needs flattening
['5/7 * 9 * x', false],
];
tests.forEach(t => testCanCombine(t[0], t[1]));
});
describe('canSimplifyPolynomialTerms addition', function() {
const tests = [
['x + x', true],
['4y^2 + 7y^2 + y^2', true],
['4y^2 + 7y^2 + y^2 + y', false],
['y', false],
];
tests.forEach(t => testCanCombine(t[0], t[1]));
});
describe('canSimplifyPolynomialTerms denominator in numerator', function() {
const tests = [
['(x+1)/(x-2)', true],
['(2x)/(x+4)', true],
['(x)/(x+4)', true],
['(x)/(2x+4)', true],
['(x+3)/(x)', false], // Normal breakup function already solves this
['(2x + 3)/(2x + 2)', true],
['(2x+3)/(2x)', false], // Normal breakup function already solves this
['(2x)/(2x + 2)', true],
['(5x + 3)/(4)', false], // Normal breakup function already solves this
// Not supported yet
['(2x)/(2 + 2x)', false],
['(2 + 2x)/(3x + 4)', false],
['(x + 3)/(2x^2 + 5)', false],
['(3x^2 + 3)/(2x^2 + 5)', false],
['(5x^2 + 3)/(2x + 5)', false],
['(5x^2-4x + 3)/(2x + 5)', false],
['(-4x + 3)/(2x^2 + 5x +7)', false],
];
tests.forEach(t => testCanCombine(t[0], t[1]));
});