X-Git-Url: http://git.osdn.net/view?a=blobdiff_plain;f=tool%2FSpec%2Fspec%2FBaseJSSpec.js;h=c091eeee1d1648abda41b281d51489ad2e64787b;hb=5f90d5d41cc7df8a8953444c2a98a3e7ac7343e6;hp=f8064dc8264676c06853552e09090efef2759981;hpb=9ae3a0ebce7c59241ad43a3da01a857130822a70;p=sie%2Fsie.git diff --git a/tool/Spec/spec/BaseJSSpec.js b/tool/Spec/spec/BaseJSSpec.js index f8064dc..c091eee 100644 --- a/tool/Spec/spec/BaseJSSpec.js +++ b/tool/Spec/spec/BaseJSSpec.js @@ -420,8 +420,7 @@ describe("base.js", function() { } ).toThrow("No arguments error"); } ); }); - - describe("an 'call' method", function() { + describe("a 'call' method", function() { it("limit value analysis", function() { expect(typeof base("$bfp").call).toBe("function"); expect(base("$bfp").call()).toBe(base("$bfp")); @@ -492,7 +491,7 @@ describe("base.js", function() { expect(base("$cfp").up("$bfp").of({a:base("$bfp")}).call()).toBe(base("$cfp").$bfp); /*循環参照は防ぐようにする*/ - expect(base("$bfp").$b.up().of( {b: base("$bfp").$b.$1} ).call()).toBe(base("$bfp").$b.$1); + expect(base("$bfp").$b.up().of( {b: base("$bfp").$b.$1} ).call()).toBe(15); /*ofメソッドで指定されたfuncメソッドなどは、callメソッドで呼び出し時に実行される(thisはcallメソッドのレシーバ)*/ expect( base("$cfp").up("$a").of( { @@ -529,7 +528,31 @@ describe("base.js", function() { }).toThrow(); } ); }); - + + describe("an 'initToEval' method", function() { + it("limit value analysis", function() { + base("$ifp").of( + {a: function(){return 1;}, b: base("$ifp"), + call: function() {return 2;} + } + ).initToEval(); + expect(base("$ifp").a).toBeUndefined(); + expect(base("$ifp").b).toBeUndefined(); + expect(base("$ifp").b__).toBe(base("$ifp")); + base("$ifp").call(); + expect(base("$ifp").a).toBe(1); + expect(base("$ifp").b).toBe(2); + expect(base("$ifp").b__).toBe(base("$ifp")); + base("$ifp").initToEval().mix( {a__: function(){return 2;}} ); + expect(base("$ifp").a).toBe(1); + base("$ifp").call(); + expect(base("$ifp").a).toBe(2); + expect(base("$ifp").b).toBe(2); + expect(base("$ifp").b__).toBe(base("$ifp")); + + } ); + } ); + it("should occur an error, if no arguments", function(){ var message = "No arguments error"; expect(function(){