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