3 <script src=
"../http/tests/inspector/inspector-test.js"></script>
8 InspectorTest
.runTestSuite([
9 function testMatchQuotes(next
)
12 {"odd back slashes with text around":"tes\\\"t"},
13 {"escaped double quotes":"\"test\""},
14 {"escaped back slash before double quote":"test\\"},
17 {"nested brackets":{}},
18 {"nested brackets with double quotes":{"":""}},
20 {"etc":{"\\\\":"\\"}},
21 {"etc":{"\\\\\"":"\\\\\""}}
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
);
33 function testMatchSequenceUsingOneShot(next
)
37 [{"one":"one"}, {"two":"two"}],
38 [{"one":"one"}, {"two":"two"}, {"three":"three"}],
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
);
50 function testMatchSequenceUsingMultiple(next
)
54 [{"one":"one"}, {"two":"two"}],
55 [{"one":"one"}, {"two":"two"}, {"three":"three"}],
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
);
67 function testIncrementalWrites(next
)
70 {"odd back slashes with text around":"tes\\\"t"},
71 {"escaped double quotes":"\"test\""},
72 {"escaped back slash before double quote":"test\\"},
75 {"nested brackets":{}},
76 {"nested brackets with double quotes":{"":""}},
78 {"etc":{"\\\\":"\\"}},
79 {"etc":{"\\\\\"":"\\\\\""}}
81 var string
= JSON
.stringify(testStrings
);
82 var tokenizer
= new WebInspector
.TextUtils
.BalancedJSONTokenizer(InspectorTest
.addResult
.bind(InspectorTest
), true);
83 InspectorTest
.addResult("\nRunning at once:");
84 tokenizer
.write(string
);
86 for (var sample
of [3, 15, 50]) {
87 tokenizer
= new WebInspector
.TextUtils
.BalancedJSONTokenizer(InspectorTest
.addResult
.bind(InspectorTest
), true);
88 InspectorTest
.addResult("\nRunning by " + sample
+ ":");
89 for (var i
= 0; i
< string
.length
; i
+= sample
)
90 tokenizer
.write(string
.substring(i
, i
+ sample
));
98 <body onload=
"runTest()">
99 Test WebInspector.TextUtils.BalancedJSONTokenizer.