Web Inspector: add InspectorTest.expectException() and use it
[WebKit-https.git] / LayoutTests / inspector / unit-tests / test-harness-expect-functions.html
index c60ff69df49e77c7e51b3973f559162fc4d06f8e..cbe66fffc52926450bd8407a20a8971d63a1e6fa 100644 (file)
@@ -5,23 +5,12 @@
 <script>
 function test()
 {
-    console.assert(false, "FAIL ASSERTION!!!!!!!");
-
-    let suite = InspectorTest.createSyncSuite("InspectorTestExpectFunctions");
+    let suite = InspectorTest.createSyncSuite("InspectorTest.ExpectFunctions.Sync");
 
     function toArray(a) {
         return a instanceof Array && a.length ? a : [a];
     }
 
-    function stringifyArguments(args) {
-        return args.map((a) => {
-            if (typeof a === "number")
-                return a;
-            // Append empty string so `undefined` is displayed correctly.
-            return JSON.stringify(a) + "";
-        }).join(", ");
-    }
-
     function addTestCase({functionName, passingInputs, failingInputs}) {
         let functionUnderTest = InspectorTest[functionName];
         InspectorTest.assert(typeof functionUnderTest === "function", "Unknown InspectorTest function: " + functionName);
@@ -36,10 +25,8 @@ function test()
                     }
 
                     InspectorTest.log("Expected to " + (shouldPass ? "PASS" : "FAIL"));
-                    for (let input of inputs.map(toArray)) {
-                        let argumentsString = stringifyArguments(input);
-                        functionUnderTest.call(InspectorTest, ...input, `${functionName}(${argumentsString})`);
-                    }
+                    for (let input of inputs.map(toArray))
+                        functionUnderTest.call(InspectorTest, ...input);
                 }
 
                 exerciseFunction(passingInputs, true);
@@ -70,12 +57,15 @@ function test()
     addInverseTestCase("expectNotNull", expectNullTestCase);
 
     let object1 = {a: 1, b: 2};
-    let object2 = {c: 3, d: 4};
+    let object2 = {a: 1, b: 2};
+    let customObject1 = new WI.CSSStyleDeclaration;
+    let customObject2 = new WI.CSSRule;
     let expectEqualTestCase = {
         functionName: "expectEqual",
         passingInputs: [
             [true, true],
             [object1, object1],
+            [customObject1, customObject1],
             [1.23, 1.23],
             ["abc", "abc"],
             [null, null],
@@ -84,6 +74,7 @@ function test()
         failingInputs: [
             [true, false],
             [object1, object2],
+            [customObject1, customObject2],
             [1.23, 4.56],
             ["abc", "def"],
             [null, undefined],
@@ -100,11 +91,17 @@ function test()
         passingInputs: [
             [{a: 1, b: 2}, {a: 1, b: 2}],
             [{}, {}],
+            [[1, 2], [1, 2]],
+            [[{a: 1}, {a: 2}], [{a: 1}, {a: 2}]],
+            [[{}], [{}]],
             [[], []],
         ],
         failingInputs: [
             [{a: 1, b: 2}, {a: 3, b: 4}],
             [{}, []],
+            [[1, 2], [3, 4]],
+            [[{a: 1}, {a: 2}], [{a: 3}, {a: 4}]],
+            [[{a: 1}, {a: 2}], [{b: 1}, {b: 2}]],
         ]
     };
     addTestCase(expectShallowEqualTestCase);