From aad33cb0ec035a6f71b4e3eb8f6294cb3e304a48 Mon Sep 17 00:00:00 2001 From: dhrname Date: Wed, 1 Apr 2015 22:36:22 +0900 Subject: [PATCH] Add the Spec for a splene mode --- org/w3c/dom/smil.js | 9 +++++++-- tool/Spec/spec/SvgDomSpec.js | 11 +++++++++-- 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/org/w3c/dom/smil.js b/org/w3c/dom/smil.js index 5d04e91..5b9d204 100644 --- a/org/w3c/dom/smil.js +++ b/org/w3c/dom/smil.js @@ -586,9 +586,14 @@ base("$from").of( { this.keyTime = this.to.distance(this.to.from) / this.norm; return f; } else if (this.mode === "spline") { + var tk = this.keySplines; + for (var i=0;i<4;++i) { + if (isNaN(tk[i])) { + throw new Error("A keySplines attribute error"); + } + } this.to.call(); - var tk = this.keySplines, - x2 = tk[0], + var x2 = tk[0], y2 = tk[1], x3 = tk[2], y3 = tk[3], diff --git a/tool/Spec/spec/SvgDomSpec.js b/tool/Spec/spec/SvgDomSpec.js index 13ffcce..3a61dd1 100644 --- a/tool/Spec/spec/SvgDomSpec.js +++ b/tool/Spec/spec/SvgDomSpec.js @@ -3267,13 +3267,13 @@ describe("SMIL Animation Spec", function() { calc.keySplines = k; calc.to.degit = 10; var b = bezier(0,0, k[0],k[1], k[2],k[3], 1,1), - epsiron = 1e-6; //誤差 + epsilon = 1e-6; //誤差 expect(calc.call()(0)).toBe(b(0).y.toFixed(10)); calc.to.from = from; expect(calc.call()(1)).toBe(b(1).y.toFixed(10)); calc.to.from = from; b = b(Math.random()); - expect(Math.abs(calc.call()(b.x) - b.y.toFixed(10))).toBeLessThan(epsiron); + expect(Math.abs(calc.call()(b.x) - b.y.toFixed(10))).toBeLessThan(epsilon); }; for (var i=0;i<10000;++i) { var rand = [Math.random(), Math.random(), Math.random(), Math.random()].sort(function(a,b){return a-b;}); @@ -3283,6 +3283,13 @@ describe("SMIL Animation Spec", function() { } ); /*無効同値クラスを調べておく (Equivalence partitioning, the following is the invalid partion)*/ it("should be this for the value (the invalid partion on a spline mode )", function() { + calc.mode = "spline"; + calc.keySplines = [0, NaN, 1, 1]; + calc.to.degit = 1; + calc.to.from = from; + expect( function() { + calc.up().call(); + } ).toThrow(); } ); } ); } ); -- 2.11.0