OLD | NEW |
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:convert'; |
6 import 'dart:io'; | 6 import 'dart:io'; |
7 import 'dart:mirrors'; | 7 import 'dart:mirrors'; |
8 import 'package:path/path.dart' as pathos; | 8 import 'package:path/path.dart' as pathos; |
9 import 'package:unittest/unittest.dart'; | 9 import 'package:unittest/unittest.dart'; |
10 import 'package:html5lib/src/char_encodings.dart'; | 10 import 'package:html5lib/src/char_encodings.dart'; |
(...skipping 15 matching lines...) Expand all Loading... |
26 | 26 |
27 List parse(String str) { | 27 List parse(String str) { |
28 // Note: we need to pass bytes to the tokenizer if we want it to handle BOM. | 28 // Note: we need to pass bytes to the tokenizer if we want it to handle BOM. |
29 var bytes = codepointsToUtf8(toCodepoints(str)); | 29 var bytes = codepointsToUtf8(toCodepoints(str)); |
30 var tokenizer = new HtmlTokenizer(bytes, encoding: 'utf-8'); | 30 var tokenizer = new HtmlTokenizer(bytes, encoding: 'utf-8'); |
31 outputTokens = []; | 31 outputTokens = []; |
32 | 32 |
33 // Note: we can't get a closure of the state method. However, we can | 33 // Note: we can't get a closure of the state method. However, we can |
34 // create a new closure to invoke it via mirrors. | 34 // create a new closure to invoke it via mirrors. |
35 var mtok = reflect(tokenizer); | 35 var mtok = reflect(tokenizer); |
36 tokenizer.state = () => deprecatedFutureValue( | 36 tokenizer.state = () => |
37 mtok.invokeAsync(new Symbol(_state), const [])).reflectee; | 37 mtok.invoke(new Symbol(_state), const []).reflectee; |
38 | 38 |
39 if (_lastStartTag != null) { | 39 if (_lastStartTag != null) { |
40 tokenizer.currentToken = new StartTagToken(_lastStartTag); | 40 tokenizer.currentToken = new StartTagToken(_lastStartTag); |
41 } | 41 } |
42 | 42 |
43 while (tokenizer.moveNext()) { | 43 while (tokenizer.moveNext()) { |
44 var token = tokenizer.current; | 44 var token = tokenizer.current; |
45 switch (token.kind) { | 45 switch (token.kind) { |
46 case TokenKind.characters: | 46 case TokenKind.characters: |
47 processCharacters(token); | 47 processCharacters(token); |
(...skipping 213 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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 } |
OLD | NEW |