• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

nicolewhite / algebra.js / 87 / 1
95%
master: 95%

Build:
DEFAULT BRANCH: master
Ran 22 Aug 2015 04:00PM UTC
Files 8
Run time 0s
Badge
Embed ▾
README BADGES
x

If you need to use a raster PNG badge, change the '.svg' to '.png' in the link

Markdown

Textile

RDoc

HTML

Rst

22 Aug 2015 03:58PM UTC coverage: 98.247% (+0.02%) from 98.23%
87.1

push

travis-ci

nicolewhite
Fix bug in Expression.simplify

The original implementation of Expression._combineLikeTerms was written
when Expressions were always simplified. In some cases where like-terms
show up multiple times and are scattered, terms would be missed because
I was splicing on the array that was being iterated through (which is
probably bad in general). It’s been rewritten to keep track of which
terms have already been encountered.

E.g., this used to fail:

var exp = algebra.parse("x + y + 3");
var unsimplified = exp.pow(3, false);
unsimplified.toString();

// xxx + xyy + yxx + yxy + yyx + yyy + xxy + xyx + 3yx + 3xy + 3xy +
3yy + 3xx + 3xx + 3yy + 3yx + 3yy + 3yx + 3xx + 3xy + 3 * 3x + 3 * 3y +
3 * 3x + 3 * 3y + 3 * 3x + 3 * 3y + 3 * 3 * 3

var simplified = unsimplified.simplify();
simplified.toString();
// x^3 + y^3 + 2x^2y + y^2x + x^2y + 2y^2x + 6y^2 + 9x^2 + 3y^2 + 3xy +
15yx + 27x + 18y + 9y + 27

Notice the 2x^2y and x^2y terms are not combined when they should be.

This now works correctly:

var simplified = unsimplified.simplify();
simplified.toString();
// x^3 + y^3 + 3x^2y + 3y^2x + 9x^2 + 9y^2 + 18xy + 27x + 27y + 27

1009 of 1027 relevant lines covered (98.25%)

799.45 hits per line

Source Files on job 87.1
  • Tree
  • List 0
  • Changed 6
  • Source Changed 1
  • Coverage Changed 6
Coverage ∆ File Lines Relevant Covered Missed Hits/Line
  • Back to Build 87
  • Travis Job 87.1
  • 96b0e467 on github
  • Prev Job for on master (#86.1)
  • Next Job for on master (#88.1)
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc