Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(149)

Side by Side Diff: pkg/third_party/html5lib/test/tokenizer_test.dart

Issue 23540004: Remove use of dart:json from third_party. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « pkg/third_party/html5lib/test/parser_test.dart ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 library tokenizer_test; 1 library tokenizer_test;
2 2
3 // Note: mirrors used to match the getattr usage in the original test 3 // Note: mirrors used to match the getattr usage in the original test
4 import 'dart:async'; 4 import 'dart:async';
5 import 'dart:convert';
5 import 'dart:io'; 6 import 'dart:io';
6 import 'dart:json' as json;
7 import 'dart:mirrors'; 7 import 'dart:mirrors';
8 import 'dart:utf'; 8 import 'dart:utf';
9 import 'package:path/path.dart' as pathos; 9 import 'package:path/path.dart' as pathos;
10 import 'package:unittest/unittest.dart'; 10 import 'package:unittest/unittest.dart';
11 import 'package:html5lib/src/char_encodings.dart'; 11 import 'package:html5lib/src/char_encodings.dart';
12 import 'package:html5lib/src/constants.dart' as constants; 12 import 'package:html5lib/src/constants.dart' as constants;
13 import 'package:html5lib/src/token.dart'; 13 import 'package:html5lib/src/token.dart';
14 import 'package:html5lib/src/tokenizer.dart'; 14 import 'package:html5lib/src/tokenizer.dart';
15 import 'package:html5lib/src/utils.dart'; 15 import 'package:html5lib/src/utils.dart';
16 import 'support.dart'; 16 import 'support.dart';
(...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after
200 "\nInput:", testInfo['input'], 200 "\nInput:", testInfo['input'],
201 "\nExpected:", expected, 201 "\nExpected:", expected,
202 "\nreceived:", tokens].map((s) => '$s').join('\n'); 202 "\nreceived:", tokens].map((s) => '$s').join('\n');
203 var ignoreErrorOrder = testInfo['ignoreErrorOrder']; 203 var ignoreErrorOrder = testInfo['ignoreErrorOrder'];
204 if (ignoreErrorOrder == null) ignoreErrorOrder = false; 204 if (ignoreErrorOrder == null) ignoreErrorOrder = false;
205 205
206 expectTokensMatch(expected, received, ignoreErrorOrder, true, errorMsg); 206 expectTokensMatch(expected, received, ignoreErrorOrder, true, errorMsg);
207 } 207 }
208 208
209 Map unescape(Map testInfo) { 209 Map unescape(Map testInfo) {
210 // TODO(sigmundch,jmesserly): we currently use json.parse to unescape the 210 // TODO(sigmundch,jmesserly): we currently use JSON.decode to unescape the
211 // unicode characters in the string, we should use a decoding that works with 211 // unicode characters in the string, we should use a decoding that works with
212 // any control characters. 212 // any control characters.
213 decode(inp) => inp == '\u0000' ? inp : json.parse('"$inp"'); 213 decode(inp) => inp == '\u0000' ? inp : JSON.decode('"$inp"');
214 214
215 testInfo["input"] = decode(testInfo["input"]); 215 testInfo["input"] = decode(testInfo["input"]);
216 for (var token in testInfo["output"]) { 216 for (var token in testInfo["output"]) {
217 if (token == "ParseError") { 217 if (token == "ParseError") {
218 continue; 218 continue;
219 } else { 219 } else {
220 token[1] = decode(token[1]); 220 token[1] = decode(token[1]);
221 if (token.length > 2) { 221 if (token.length > 2) {
222 for (var pair in token[2]) { 222 for (var pair in token[2]) {
223 var key = pair[0]; 223 var key = pair[0];
(...skipping 17 matching lines...) Expand all
241 result.write(match.group(2)); 241 result.write(match.group(2));
242 } 242 }
243 return result.toString(); 243 return result.toString();
244 } 244 }
245 245
246 void main() { 246 void main() {
247 for (var path in getDataFiles('tokenizer')) { 247 for (var path in getDataFiles('tokenizer')) {
248 if (!path.endsWith('.test')) continue; 248 if (!path.endsWith('.test')) continue;
249 249
250 var text = new File(path).readAsStringSync(); 250 var text = new File(path).readAsStringSync();
251 var tests = json.parse(text); 251 var tests = JSON.decode(text);
252 var testName = pathos.basenameWithoutExtension(path); 252 var testName = pathos.basenameWithoutExtension(path);
253 var testList = tests['tests']; 253 var testList = tests['tests'];
254 if (testList == null) continue; 254 if (testList == null) continue;
255 255
256 group(testName, () { 256 group(testName, () {
257 for (int index = 0; index < testList.length; index++) { 257 for (int index = 0; index < testList.length; index++) {
258 final testInfo = testList[index]; 258 final testInfo = testList[index];
259 259
260 testInfo.putIfAbsent("initialStates", () => ["Data state"]); 260 testInfo.putIfAbsent("initialStates", () => ["Data state"]);
261 for (var initialState in testInfo["initialStates"]) { 261 for (var initialState in testInfo["initialStates"]) {
262 test(testInfo["description"], () { 262 test(testInfo["description"], () {
263 testInfo["initialState"] = camelCase(initialState); 263 testInfo["initialState"] = camelCase(initialState);
264 runTokenizerTest(testInfo); 264 runTokenizerTest(testInfo);
265 }); 265 });
266 } 266 }
267 } 267 }
268 }); 268 });
269 } 269 }
270 } 270 }
OLDNEW
« no previous file with comments | « pkg/third_party/html5lib/test/parser_test.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698