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: dart/tests/compiler/dart2js/parser_test.dart

Issue 11367007: Tests owed. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 8 years, 1 month 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) 2011, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2011, 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('parser_helper.dart'); 5 #import('parser_helper.dart');
6 #import("../../../lib/compiler/implementation/tree/tree.dart"); 6 #import("../../../lib/compiler/implementation/tree/tree.dart");
7 7
8 void testStatement(String statement) { 8 void testStatement(String statement) {
9 Node node = parseStatement(statement); 9 Node node = parseStatement(statement);
10 Expect.isNotNull(node.toString()); 10 Expect.isNotNull(node.toString());
(...skipping 247 matching lines...) Expand 10 before | Expand all | Expand 10 after
258 FunctionExpression function = parseMember('operator -() => null;'); 258 FunctionExpression function = parseMember('operator -() => null;');
259 Send name = function.name.asSend(); 259 Send name = function.name.asSend();
260 Expect.isNotNull(name); 260 Expect.isNotNull(name);
261 Expect.stringEquals('operator', name.receiver.source.stringValue); 261 Expect.stringEquals('operator', name.receiver.source.stringValue);
262 Expect.stringEquals('-', name.selector.source.stringValue); 262 Expect.stringEquals('-', name.selector.source.stringValue);
263 Expect.isTrue(function.parameters.isEmpty); 263 Expect.isTrue(function.parameters.isEmpty);
264 Expect.isNull(function.returnType); 264 Expect.isNull(function.returnType);
265 Expect.isNull(function.getOrSet); 265 Expect.isNull(function.getOrSet);
266 } 266 }
267 267
268 class Collector implements DiagnosticListener {
269 final List<int> tokens = <int>[];
270
271 void cancel(String reason, {node, token, instruction, element}) {
272 tokens.add(token.kind);
273 throw this;
274 }
275
276 void log(message) {
277 print(message);
278 }
279 }
280
281 void testMissingCloseParen() {
282 final String source =
283 '''foo(x { // <= missing closing ")"
284 return x;
285 }''';
286 Expect.throws(() => parseMember(source, lc: new Collector()),
287 (Collector c) {
288 Expect.listEquals(const <int>[OPEN_CURLY_BRACKET_TOKEN],
289 c.tokens);
290 return true;
291 });
292 }
293
268 void main() { 294 void main() {
269 testGenericTypes(); 295 testGenericTypes();
270 // TODO(ahe): Enable this test when we handle library prefixes. 296 // TODO(ahe): Enable this test when we handle library prefixes.
271 // testPrefixedGenericTypes(); 297 // testPrefixedGenericTypes();
272 testUnaryExpression(); 298 testUnaryExpression();
273 testChainedMethodCalls(); 299 testChainedMethodCalls();
274 testFunctionStatement(); 300 testFunctionStatement();
275 testDoStatement(); 301 testDoStatement();
276 testWhileStatement(); 302 testWhileStatement();
277 testConditionalExpression(); 303 testConditionalExpression();
278 testAssignment(); 304 testAssignment();
279 testIndex(); 305 testIndex();
280 testPostfix(); 306 testPostfix();
281 testOperatorParse(); 307 testOperatorParse();
308 testMissingCloseParen();
282 } 309 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698