Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 <html> | |
| 2 <head> | |
| 3 <script src="../http/tests/inspector/inspector-test.js"></script> | |
| 4 | |
| 5 <script> | |
| 6 function test() | |
| 7 { | |
| 8 InspectorTest.runTestSuite([ | |
| 9 function testMatchQuotes(next) | |
| 10 { | |
| 11 var testStrings = [ | |
| 12 {"odd back slashes with text around":"tes\\\"t"}, | |
| 13 {"escaped double quotes":"\"test\""}, | |
| 14 {"escaped back slash before double quote":"test\\"}, | |
| 15 {1:2}, | |
| 16 {"":""}, | |
| 17 {"nested brackets":{}}, | |
| 18 {"nested brackets with double quotes":{"":""}}, | |
| 19 {"etc":{"\\":"\""}}, | |
| 20 {"etc":{"\\\\":"\\"}}, | |
| 21 {"etc":{"\\\\\"":"\\\\\""}} | |
| 22 ]; | |
| 23 | |
| 24 for (var i = 0; i < testStrings.length; ++i) { | |
| 25 var string = JSON.stringify(testStrings[i]); | |
| 26 InspectorTest.addResult("\nParsing " + string); | |
| 27 var tokenizer = new WebInspector.TextUtils.BalancedJSONTokenizer (InspectorTest.addResult.bind(InspectorTest)); | |
| 28 tokenizer.write(string); | |
| 29 } | |
| 30 next(); | |
| 31 }, | |
| 32 | |
| 33 function testMatchSequenceUsingOneShot(next) | |
| 34 { | |
| 35 var testData = [ | |
| 36 {"one":"one"}, | |
| 37 [{"one":"one"}, {"two":"two"}], | |
| 38 [{"one":"one"}, {"two":"two"}, {"three":"three"}], | |
| 39 ]; | |
| 40 | |
| 41 for (var i = 0; i < testData.length; ++i) { | |
| 42 var string = JSON.stringify(testData[i]); | |
| 43 InspectorTest.addResult("\nParsing " + string); | |
| 44 var tokenizer = new WebInspector.TextUtils.BalancedJSONTokenizer (InspectorTest.addResult.bind(InspectorTest)); | |
| 45 tokenizer.write(string); | |
| 46 } | |
| 47 next(); | |
| 48 }, | |
| 49 | |
| 50 function testMatchSequenceUsingMultiple(next) | |
| 51 { | |
| 52 var testData = [ | |
| 53 {"one":"one"}, | |
| 54 [{"one":"one"}, {"two":"two"}], | |
| 55 [{"one":"one"}, {"two":"two"}, {"three":"three"}], | |
| 56 ]; | |
| 57 | |
| 58 for (var i = 0; i < testData.length; ++i) { | |
| 59 var string = JSON.stringify(testData[i]); | |
| 60 InspectorTest.addResult("\nParsing " + string); | |
| 61 var tokenizer = new WebInspector.TextUtils.BalancedJSONTokenizer (InspectorTest.addResult.bind(InspectorTest), true); | |
| 62 tokenizer.write(string); | |
| 63 } | |
| 64 next(); | |
| 65 }, | |
| 66 | |
| 67 function testIncrementalWrites(next) | |
| 68 { | |
| 69 var testStrings = [ | |
| 70 {"odd back slashes with text around":"tes\\\"t"}, | |
| 71 {"escaped double quotes":"\"test\""}, | |
| 72 {"escaped back slash before double quote":"test\\"}, | |
| 73 {1:2}, | |
| 74 {"":""}, | |
| 75 {"nested brackets":{}}, | |
| 76 {"nested brackets with double quotes":{"":""}}, | |
| 77 {"etc":{"\\":"\""}}, | |
| 78 {"etc":{"\\\\":"\\"}}, | |
| 79 {"etc":{"\\\\\"":"\\\\\""}} | |
| 80 ]; | |
| 81 var string = JSON.stringify(testStrings); | |
| 82 var tokenizer = new WebInspector.TextUtils.BalancedJSONTokenizer(Ins pectorTest.addResult.bind(InspectorTest), true); | |
| 83 InspectorTest.addResult("\nRunning at once:"); | |
| 84 tokenizer.write(string); | |
| 85 | |
| 86 tokenizer = new WebInspector.TextUtils.BalancedJSONTokenizer(Inspect orTest.addResult.bind(InspectorTest), true); | |
|
alph
2015/03/01 11:30:13
great place to have a loop over [3, 15, 50].
pfeldman
2015/03/01 12:18:53
Done.
| |
| 87 InspectorTest.addResult("\nRunning by 3:"); | |
| 88 for (var i = 0; i < string.length; i += 3) | |
| 89 tokenizer.write(string.substring(i, i + 3)); | |
| 90 | |
| 91 tokenizer = new WebInspector.TextUtils.BalancedJSONTokenizer(Inspect orTest.addResult.bind(InspectorTest), true); | |
| 92 InspectorTest.addResult("\nRunning by 15:"); | |
| 93 for (var i = 0; i < string.length; i += 15) | |
| 94 tokenizer.write(string.substring(i, i + 15)); | |
| 95 | |
| 96 tokenizer = new WebInspector.TextUtils.BalancedJSONTokenizer(Inspect orTest.addResult.bind(InspectorTest), true); | |
| 97 InspectorTest.addResult("\nRunning by 50:"); | |
| 98 for (var i = 0; i < string.length; i += 50) | |
| 99 tokenizer.write(string.substring(i, i + 50)); | |
| 100 | |
| 101 next(); | |
| 102 } | |
| 103 ]); | |
| 104 } | |
| 105 </script> | |
| 106 | |
| 107 <body onload="runTest()"> | |
| 108 Test WebInspector.TextUtils.BalancedJSONTokenizer. | |
| 109 </p> | |
| 110 </body> | |
| 111 </html> | |
| OLD | NEW |