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

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

Issue 10558023: New treatment of native methods. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Tests added Created 8 years, 6 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 | « lib/compiler/implementation/typechecker.dart ('k') | tests/compiler/dart2js/unparser_test.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 NodeListener listener = new NodeListener(lc, null); 31 Script script = new Script(new Uri(scheme: "source"), new MockFile(text));
32 Library library = new LibraryElement(script);
33 library.canUseNative = true;
34 NodeListener listener = new NodeListener(lc, library);
32 Parser parser = new Parser(listener); 35 Parser parser = new Parser(listener);
33 Token endToken = parseMethod(parser, tokens); 36 Token endToken = parseMethod(parser, tokens);
34 assert(endToken.kind == EOF_TOKEN); 37 assert(endToken.kind == EOF_TOKEN);
35 Node node = listener.popNode(); 38 Node node = listener.popNode();
36 Expect.isNotNull(node); 39 Expect.isNotNull(node);
37 Expect.isTrue(listener.nodes.isEmpty(), 'Not empty: ${listener.nodes}'); 40 Expect.isTrue(listener.nodes.isEmpty(), 'Not empty: ${listener.nodes}');
38 return node; 41 return node;
39 } 42 }
40 43
41 Node parseStatement(String text) => 44 Node parseStatement(String text) =>
(...skipping 26 matching lines...) Expand all
68 compiler.withCurrentElement(unit, () => parser.parseUnit(tokens)); 71 compiler.withCurrentElement(unit, () => parser.parseUnit(tokens));
69 return unit.topLevelElements; 72 return unit.topLevelElements;
70 } 73 }
71 74
72 // TODO(ahe): We define this method to avoid having to import 75 // TODO(ahe): We define this method to avoid having to import
73 // the scanner in the tests. We should move SourceString to another 76 // the scanner in the tests. We should move SourceString to another
74 // location instead. 77 // location instead.
75 SourceString buildSourceString(String name) { 78 SourceString buildSourceString(String name) {
76 return new SourceString(name); 79 return new SourceString(name);
77 } 80 }
OLDNEW
« no previous file with comments | « lib/compiler/implementation/typechecker.dart ('k') | tests/compiler/dart2js/unparser_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698