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

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

Issue 1517873004: Enable conditional imports in unparser test. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 5 years 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
« no previous file with comments | « no previous file | 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 // 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 "package:expect/expect.dart"; 7 import "package:expect/expect.dart";
8 8
9 import "package:compiler/src/elements/elements.dart"; 9 import "package:compiler/src/elements/elements.dart";
10 import "package:compiler/src/tree/tree.dart"; 10 import "package:compiler/src/tree/tree.dart";
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
95 Node parseBodyCode(String text, Function parseMethod, 95 Node parseBodyCode(String text, Function parseMethod,
96 {DiagnosticReporter reporter}) { 96 {DiagnosticReporter reporter}) {
97 Token tokens = scan(text); 97 Token tokens = scan(text);
98 if (reporter == null) reporter = new LoggerCanceler(); 98 if (reporter == null) reporter = new LoggerCanceler();
99 Uri uri = new Uri(scheme: "source"); 99 Uri uri = new Uri(scheme: "source");
100 Script script = new Script(uri, uri,new MockFile(text)); 100 Script script = new Script(uri, uri,new MockFile(text));
101 LibraryElement library = new LibraryElementX(script); 101 LibraryElement library = new LibraryElementX(script);
102 NodeListener listener = new NodeListener( 102 NodeListener listener = new NodeListener(
103 new ScannerOptions(canUseNative: true), 103 new ScannerOptions(canUseNative: true),
104 reporter, library.entryCompilationUnit); 104 reporter, library.entryCompilationUnit);
105 Parser parser = new Parser(listener); 105 Parser parser = new Parser(listener, enableConditionalDirectives: true);
106 Token endToken = parseMethod(parser, tokens); 106 Token endToken = parseMethod(parser, tokens);
107 assert(endToken.kind == EOF_TOKEN); 107 assert(endToken.kind == EOF_TOKEN);
108 Node node = listener.popNode(); 108 Node node = listener.popNode();
109 Expect.isNotNull(node); 109 Expect.isNotNull(node);
110 Expect.isTrue(listener.nodes.isEmpty, 'Not empty: ${listener.nodes}'); 110 Expect.isTrue(listener.nodes.isEmpty, 'Not empty: ${listener.nodes}');
111 return node; 111 return node;
112 } 112 }
113 113
114 Node parseStatement(String text) => 114 Node parseStatement(String text) =>
115 parseBodyCode(text, (parser, tokens) => parser.parseStatement(tokens)); 115 parseBodyCode(text, (parser, tokens) => parser.parseStatement(tokens));
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
154 reporter.withCurrentElement(unit, () => parser.parseUnit(tokens)); 154 reporter.withCurrentElement(unit, () => parser.parseUnit(tokens));
155 return unit.localMembers; 155 return unit.localMembers;
156 } 156 }
157 157
158 NodeList fullParseUnit(String source, {DiagnosticReporter reporter}) { 158 NodeList fullParseUnit(String source, {DiagnosticReporter reporter}) {
159 return parseBodyCode( 159 return parseBodyCode(
160 source, 160 source,
161 (parser, tokens) => parser.parseUnit(tokens), 161 (parser, tokens) => parser.parseUnit(tokens),
162 reporter: reporter); 162 reporter: reporter);
163 } 163 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698