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

Side by Side Diff: tests/compiler/dart2js/unparser2_test.dart

Issue 27510003: Scanner for UTF-8 byte arrays (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: fixes compiler tests Created 7 years, 2 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
OLDNEW
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 import "package:expect/expect.dart"; 5 import "package:expect/expect.dart";
6 import "../../../sdk/lib/_internal/compiler/implementation/scanner/scannerlib.da rt"; 6 import "../../../sdk/lib/_internal/compiler/implementation/scanner/scannerlib.da rt";
7 import "../../../sdk/lib/_internal/compiler/implementation/tree/tree.dart"; 7 import "../../../sdk/lib/_internal/compiler/implementation/tree/tree.dart";
8 8
9 import "../../../sdk/lib/_internal/compiler/implementation/dart2jslib.dart" 9 import "../../../sdk/lib/_internal/compiler/implementation/dart2jslib.dart"
10 show DiagnosticListener, 10 show DiagnosticListener,
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
53 53
54 void compareCode(String code) { 54 void compareCode(String code) {
55 Expect.equals(code, doUnparse(code)); 55 Expect.equals(code, doUnparse(code));
56 } 56 }
57 57
58 String doUnparse(String source) { 58 String doUnparse(String source) {
59 MessageCollector diagnosticListener = new MessageCollector(); 59 MessageCollector diagnosticListener = new MessageCollector();
60 Script script = new Script(null, null); 60 Script script = new Script(null, null);
61 LibraryElement lib = new LibraryElementX(script); 61 LibraryElement lib = new LibraryElementX(script);
62 CompilationUnitElement element = new CompilationUnitElementX(script, lib); 62 CompilationUnitElement element = new CompilationUnitElementX(script, lib);
63 StringScanner scanner = new StringScanner(source); 63 StringScanner scanner = new StringScanner.fromString(source);
64 Token beginToken = scanner.tokenize(); 64 Token beginToken = scanner.tokenize();
65 NodeListener listener = new NodeListener(diagnosticListener, element); 65 NodeListener listener = new NodeListener(diagnosticListener, element);
66 Parser parser = new Parser(listener); 66 Parser parser = new Parser(listener);
67 parser.parseUnit(beginToken); 67 parser.parseUnit(beginToken);
68 Node node = listener.popNode(); 68 Node node = listener.popNode();
69 Expect.isTrue(listener.nodes.isEmpty); 69 Expect.isTrue(listener.nodes.isEmpty);
70 return unparse(node); 70 return unparse(node);
71 } 71 }
72 72
73 class MessageCollector implements DiagnosticListener { 73 class MessageCollector implements DiagnosticListener {
(...skipping 10 matching lines...) Expand all
84 } 84 }
85 void internalErrorOnElement(Element element, String message) { 85 void internalErrorOnElement(Element element, String message) {
86 throw message; 86 throw message;
87 } 87 }
88 void internalError(String message, 88 void internalError(String message,
89 {Node node, Token token, dynamic instruction, 89 {Node node, Token token, dynamic instruction,
90 Element element}) { 90 Element element}) {
91 throw message; 91 throw message;
92 } 92 }
93 } 93 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698