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

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

Issue 10850015: Changed default Uri constructor to Uri.fromComponents(), new default constructor is Uri.fromString(… (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 8 years, 4 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 #library('parser_helper'); 5 #library('parser_helper');
6 6
7 #import("dart:uri"); 7 #import("dart:uri");
8 8
9 #import("../../../lib/compiler/implementation/elements/elements.dart"); 9 #import("../../../lib/compiler/implementation/elements/elements.dart");
10 #import("../../../lib/compiler/implementation/tree/tree.dart"); 10 #import("../../../lib/compiler/implementation/tree/tree.dart");
(...skipping 10 matching lines...) Expand all
21 void log(message) { 21 void log(message) {
22 print(message); 22 print(message);
23 } 23 }
24 } 24 }
25 25
26 Token scan(String text) => new StringScanner(text).tokenize(); 26 Token scan(String text) => new StringScanner(text).tokenize();
27 27
28 Node parseBodyCode(String text, Function parseMethod) { 28 Node parseBodyCode(String text, Function parseMethod) {
29 Token tokens = scan(text); 29 Token tokens = scan(text);
30 LoggerCanceler lc = new LoggerCanceler(); 30 LoggerCanceler lc = new LoggerCanceler();
31 Script script = new Script(new Uri(scheme: "source"), new MockFile(text)); 31 Script script =
32 new Script(
33 new Uri.fromComponents(scheme: "source"),
34 new MockFile(text));
32 LibraryElement library = new LibraryElement(script); 35 LibraryElement library = new LibraryElement(script);
33 library.canUseNative = true; 36 library.canUseNative = true;
34 NodeListener listener = new NodeListener(lc, library); 37 NodeListener listener = new NodeListener(lc, library);
35 Parser parser = new Parser(listener); 38 Parser parser = new Parser(listener);
36 Token endToken = parseMethod(parser, tokens); 39 Token endToken = parseMethod(parser, tokens);
37 assert(endToken.kind == EOF_TOKEN); 40 assert(endToken.kind == EOF_TOKEN);
38 Node node = listener.popNode(); 41 Node node = listener.popNode();
39 Expect.isNotNull(node); 42 Expect.isNotNull(node);
40 Expect.isTrue(listener.nodes.isEmpty(), 'Not empty: ${listener.nodes}'); 43 Expect.isTrue(listener.nodes.isEmpty(), 'Not empty: ${listener.nodes}');
41 return node; 44 return node;
(...skipping 13 matching lines...) Expand all
55 parseBodyCode(text, (parser, tokens) => parser.parseMember(tokens)); 58 parseBodyCode(text, (parser, tokens) => parser.parseMember(tokens));
56 59
57 class MockFile extends SourceFile { 60 class MockFile extends SourceFile {
58 MockFile(text) 61 MockFile(text)
59 : super('<string>', text); 62 : super('<string>', text);
60 } 63 }
61 64
62 Link<Element> parseUnit(String text, Compiler compiler, 65 Link<Element> parseUnit(String text, Compiler compiler,
63 LibraryElement library) { 66 LibraryElement library) {
64 Token tokens = scan(text); 67 Token tokens = scan(text);
65 Uri uri = new Uri(scheme: "source"); 68 Uri uri = new Uri.fromComponents(scheme: "source");
66 var script = new Script(uri, new MockFile(text)); 69 var script = new Script(uri, new MockFile(text));
67 var unit = new CompilationUnitElement(script, library); 70 var unit = new CompilationUnitElement(script, library);
68 int id = 0; 71 int id = 0;
69 ElementListener listener = new ElementListener(compiler, unit, () => id++); 72 ElementListener listener = new ElementListener(compiler, unit, () => id++);
70 PartialParser parser = new PartialParser(listener); 73 PartialParser parser = new PartialParser(listener);
71 compiler.withCurrentElement(unit, () => parser.parseUnit(tokens)); 74 compiler.withCurrentElement(unit, () => parser.parseUnit(tokens));
72 return unit.topLevelElements; 75 return unit.topLevelElements;
73 } 76 }
74 77
75 // TODO(ahe): We define this method to avoid having to import 78 // TODO(ahe): We define this method to avoid having to import
76 // the scanner in the tests. We should move SourceString to another 79 // the scanner in the tests. We should move SourceString to another
77 // location instead. 80 // location instead.
78 SourceString buildSourceString(String name) { 81 SourceString buildSourceString(String name) {
79 return new SourceString(name); 82 return new SourceString(name);
80 } 83 }
OLDNEW
« no previous file with comments | « dart/tests/compiler/dart2js/mock_compiler.dart ('k') | dart/tests/compiler/dart2js/source_mapping_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698