summaryrefslogtreecommitdiffstats
path: root/spec
diff options
context:
space:
mode:
authorUlrich-Matthias Schäfer <ulima.ums@googlemail.com>2017-03-06 13:39:53 +0100
committerUlrich-Matthias Schäfer <ulima.ums@googlemail.com>2017-03-06 13:39:53 +0100
commit083d4eb0362152c38c6824bbeb0d785cd13c2b67 (patch)
treef8548ba67c3d61e2c4affd0a345c9864bf0c7972 /spec
parent250f97ff2c615ad08c15e902bbed4cb9cf3fdcd9 (diff)
downloadsvg.js-083d4eb0362152c38c6824bbeb0d785cd13c2b67.tar.gz
svg.js-083d4eb0362152c38c6824bbeb0d785cd13c2b67.zip
speed up path parsing for most cases
added test, added pathArray speed bench
Diffstat (limited to 'spec')
-rw-r--r--spec/spec/array.js7
1 files changed, 7 insertions, 0 deletions
diff --git a/spec/spec/array.js b/spec/spec/array.js
index e3bd926..45d3d5a 100644
--- a/spec/spec/array.js
+++ b/spec/spec/array.js
@@ -219,6 +219,9 @@ describe('PathArray', function () {
p2 = new SVG.PathArray('m10 80 c 40 10 65 10 95 80 s 150 150 180 80 t 300 300 q 52 10 95 80 z')
p3 = new SVG.PathArray('m80 80 A 45 45, 0, 0, 0, 125 125 L 125 80 z')
p4 = new SVG.PathArray('M215.458,245.23c0,0,77.403,0,94.274,0S405,216.451,405,138.054S329.581,15,287.9,15c-41.68,0-139.924,0-170.688,0C86.45,15,15,60.65,15,134.084c0,73.434,96.259,112.137,114.122,112.137C146.984,246.221,215.458,245.23,215.458,245.23z')
+ p5 = new SVG.PathArray(
+ 'M10 10-45-30.5.5 .89L2e-2.5.5.5-.5C.5.5.5.5.5.5L-3-4z'
+ )
})
@@ -229,6 +232,10 @@ describe('PathArray', function () {
expect(p4.toString()).toBe('M215.458 245.23C215.458 245.23 292.861 245.23 309.73199999999997 245.23S405 216.451 405 138.054S329.581 15 287.9 15C246.21999999999997 15 147.97599999999997 15 117.21199999999999 15C86.45 15 15 60.65 15 134.084C15 207.518 111.259 246.221 129.122 246.221C146.984 246.221 215.458 245.23 215.458 245.23Z ')
})
+ it('parses difficult syntax correctly', function() {
+ expect(p5.toString()).toBe('M10 10L-45 -30.5L0.5 0.89L0.02 0.5L0.5 -0.5C0.5 0.5 0.5 0.5 0.5 0.5L-3 -4Z ')
+ })
+
// this test is designed to cover a certain line but it doesnt work because of #608
it('returns the valueOf when PathArray is given', function() {
var p = new SVG.PathArray('m10 10 h 80 v 80 h -80 l 300 400 z')