| OLD | NEW |
| 1 <html> | 1 <html> |
| 2 <head> | 2 <head> |
| 3 <script src="../http/tests/inspector/inspector-test.js"></script> | 3 <script src="../http/tests/inspector/inspector-test.js"></script> |
| 4 <script> | 4 <script> |
| 5 | 5 |
| 6 function initialize_DiffTest() | 6 function initialize_DiffTest() |
| 7 { | 7 { |
| 8 InspectorTest.preloadModule("diff"); | 8 InspectorTest.preloadModule("diff"); |
| 9 } | 9 } |
| 10 | 10 |
| 11 function test() | 11 function test() |
| 12 { | 12 { |
| 13 print(WebInspector.Diff.charDiff("test this sentence.", "test that sentence"
)); | 13 print(Diff.Diff.charDiff("test this sentence.", "test that sentence")); |
| 14 print(WebInspector.Diff.lineDiff(["test this sentence."], ["test that senten
ce"])); | 14 print(Diff.Diff.lineDiff(["test this sentence."], ["test that sentence"])); |
| 15 print(WebInspector.Diff.lineDiff(["a", "b", "c"], ["a", "c"])); | 15 print(Diff.Diff.lineDiff(["a", "b", "c"], ["a", "c"])); |
| 16 print(WebInspector.Diff.lineDiff(["a", "b", "c"], ["b", "a", "c"])); | 16 print(Diff.Diff.lineDiff(["a", "b", "c"], ["b", "a", "c"])); |
| 17 print(WebInspector.Diff.lineDiff(["a", "c"], ["a", "b", "c"])); | 17 print(Diff.Diff.lineDiff(["a", "c"], ["a", "b", "c"])); |
| 18 print(WebInspector.Diff.lineDiff( | 18 print(Diff.Diff.lineDiff( |
| 19 [ | 19 [ |
| 20 "for (var i = 0; i < 100; i++) {", | 20 "for (var i = 0; i < 100; i++) {", |
| 21 " willBeLeftAlone()", | 21 " willBeLeftAlone()", |
| 22 " willBeDeleted();", | 22 " willBeDeleted();", |
| 23 "}", | 23 "}", |
| 24 "for (var j = 0; j < 100; j++) {", | 24 "for (var j = 0; j < 100; j++) {", |
| 25 " console.log('something changed');", | 25 " console.log('something changed');", |
| 26 " willBeDeletedAgain();", | 26 " willBeDeletedAgain();", |
| 27 "}" | 27 "}" |
| 28 ], | 28 ], |
| 29 [ | 29 [ |
| 30 "for (var i = 0; i < 100; i++) {", | 30 "for (var i = 0; i < 100; i++) {", |
| 31 " willBeLeftAlone();", | 31 " willBeLeftAlone();", |
| 32 "}", | 32 "}", |
| 33 "insertThisLine();", | 33 "insertThisLine();", |
| 34 "for (var j = 0; j < 100; j++) {", | 34 "for (var j = 0; j < 100; j++) {", |
| 35 " console.log('changed');", | 35 " console.log('changed');", |
| 36 "}" | 36 "}" |
| 37 ])); | 37 ])); |
| 38 InspectorTest.completeTest(); | 38 InspectorTest.completeTest(); |
| 39 function print(results) | 39 function print(results) |
| 40 { | 40 { |
| 41 InspectorTest.addResult(""); | 41 InspectorTest.addResult(""); |
| 42 for (var i = 0; i < results.length; i++) { | 42 for (var i = 0; i < results.length; i++) { |
| 43 var result = results[i]; | 43 var result = results[i]; |
| 44 var type = "Unknown"; | 44 var type = "Unknown"; |
| 45 if (result[0] === WebInspector.Diff.Operation.Equal) | 45 if (result[0] === Diff.Diff.Operation.Equal) |
| 46 type = "="; | 46 type = "="; |
| 47 else if (result[0] === WebInspector.Diff.Operation.Insert) | 47 else if (result[0] === Diff.Diff.Operation.Insert) |
| 48 type = "+"; | 48 type = "+"; |
| 49 else if (result[0] === WebInspector.Diff.Operation.Delete) | 49 else if (result[0] === Diff.Diff.Operation.Delete) |
| 50 type = "-"; | 50 type = "-"; |
| 51 else if (result[0] === WebInspector.Diff.Operation.Edit) | 51 else if (result[0] === Diff.Diff.Operation.Edit) |
| 52 type = "E"; | 52 type = "E"; |
| 53 InspectorTest.addResult(type + ": " + JSON.stringify(result[1], null
, 4)); | 53 InspectorTest.addResult(type + ": " + JSON.stringify(result[1], null
, 4)); |
| 54 } | 54 } |
| 55 } | 55 } |
| 56 } | 56 } |
| 57 </script> | 57 </script> |
| 58 </head> | 58 </head> |
| 59 <body onload="runTest()"> | 59 <body onload="runTest()"> |
| 60 <p>Tests that the Diff module correctly diffs things.</p> | 60 <p>Tests that the Diff module correctly diffs things.</p> |
| 61 </body> | 61 </body> |
| 62 </html> | 62 </html> |
| OLD | NEW |