describe("A $activate object", function() {\r
var from = base("$from");\r
beforeEach( function() {\r
+ from.string = "";\r
+ $from = from.up();\r
} );\r
/*境界条件を調べておく (limit value analysis)*/\r
it("should be this for the value (limit value analysis)", function() {\r
expect(from.string).toBe("");\r
expect(from.numList()).toBeNull();\r
expect(from.strList()).toBeNull();\r
+\r
+ from.string = "0";\r
+ expect(from.numList()[0]).toEqual(0);\r
+ expect(from.strList()).toBeNull();\r
+ \r
+ from.string = " 0 ";\r
+ expect(from.numList()[0]).toEqual(0);\r
+ expect(from.strList().join("")).toBe(" ");\r
+\r
+ from.string = "a";\r
+ expect(from.numList()).toBeNull();\r
+ expect(from.strList()[0]).toBe("a");\r
+ \r
+ from.string = null;\r
+ expect( function() {\r
+ from.numList();\r
+ } ).toThrow();\r
+ expect( function() {\r
+ from.strList();\r
+ } ).toThrow();\r
} );\r
/*同値分割をして、有効同値クラスを調べておく (Equivalence partitioning, the following is the valid partion)*/\r
it("should be this for the value (the valid partion)", function() {\r
+ from.string = "0a";\r
+ expect(from.numList()[0]).toEqual(0);\r
+ expect(from.strList()[0]).toBe("a");\r
+\r
+ from.string = "a0";\r
+ expect(from.numList()[0]).toEqual(0);\r
+ expect(from.strList()[0]).toBe("a");\r
+\r
+ from.string = "0.1";\r
+ expect(from.numList()[0]).toEqual(0.1);\r
+ expect(from.strList()).toBeNull();\r
+\r
+ from.string = "+0.1";\r
+ expect(from.numList()[0]).toEqual(0.1);\r
+ expect(from.strList()).toBeNull();\r
+\r
+ from.string = "-0.1";\r
+ expect(from.numList()[0]).toEqual(-0.1);\r
+ expect(from.strList()).toBeNull();\r
+\r
+ from.string = "1e-1";\r
+ expect(from.numList()[0]).toEqual(1e-1);\r
+ expect(from.strList()).toBeNull();\r
+\r
+ from.string = "1E-1";\r
+ expect(from.numList()[0]).toEqual(1E-1);\r
+ expect(from.strList()).toBeNull();\r
+\r
+ from.string = "0,0";\r
+ expect(from.numList().toString()).toBe("0,0");\r
+ expect(from.strList().join("")).toBe(",");\r
+\r
+ from.string = "a00a";\r
+ expect(from.numList()[0]).toBe(0);\r
+ expect(from.strList().join("")).toBe("aa");\r
+\r
+ from.string = "a0b0a";\r
+ expect(from.numList().toString()).toBe("0,0");\r
+ expect(from.strList().join("")).toBe("aba");\r
+\r
+ from.string = "0b0a";\r
+ expect(from.numList().toString()).toBe("0,0");\r
+ expect(from.strList().join("")).toBe("ba");\r
+\r
+ from.string = "0b-1.0a";\r
+ expect(from.numList()[1]).toBe(-1);\r
+ expect(from.strList().join("")).toBe("ba");\r
} );\r
/*無効同値クラスを調べておく (Equivalence partitioning, the following is the invalid partion)*/\r
it("should be this for the value (the invalid partion)", function() {\r
+ from.string = NaN;\r
+ expect(function(){\r
+ from.numList();\r
+ } ).toThrow();\r
+ expect(function(){\r
+ from.strList();\r
+ } ).toThrow();\r
+\r
+ from.string = "eE";\r
+ expect(from.strList()).toBeNull();\r
+ expect(from.strList()).toBeNull();\r
} )\r
} );\r
} );\r