| OLD | NEW |
| 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 "package:expect/expect.dart"; | 5 import "package:expect/expect.dart"; |
| 6 import 'parser_helper.dart'; | 6 import 'parser_helper.dart'; |
| 7 import 'package:compiler/src/tree/tree.dart'; | 7 import 'package:compiler/src/tree/tree.dart'; |
| 8 | 8 |
| 9 void testStatement(String statement) { | 9 void testStatement(String statement) { |
| 10 Node node = parseStatement(statement); | 10 Node node = parseStatement(statement); |
| (...skipping 274 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 285 FunctionExpression function = parseMember('operator -() => null;'); | 285 FunctionExpression function = parseMember('operator -() => null;'); |
| 286 Send name = function.name.asSend(); | 286 Send name = function.name.asSend(); |
| 287 Expect.isNotNull(name); | 287 Expect.isNotNull(name); |
| 288 Expect.stringEquals('operator', name.receiver.toString()); | 288 Expect.stringEquals('operator', name.receiver.toString()); |
| 289 Expect.stringEquals('-', name.selector.toString()); | 289 Expect.stringEquals('-', name.selector.toString()); |
| 290 Expect.isTrue(function.parameters.isEmpty); | 290 Expect.isTrue(function.parameters.isEmpty); |
| 291 Expect.isNull(function.returnType); | 291 Expect.isNull(function.returnType); |
| 292 Expect.isNull(function.getOrSet); | 292 Expect.isNull(function.getOrSet); |
| 293 } | 293 } |
| 294 | 294 |
| 295 class Collector implements DiagnosticListener { | 295 class Collector extends DiagnosticListener { |
| 296 int token = -1; | 296 int token = -1; |
| 297 | 297 |
| 298 void reportFatalError(Token token, | 298 void reportFatalError(Token token) { |
| 299 messageKind, | |
| 300 [Map arguments = const {}]) { | |
| 301 this.token = token.kind; | 299 this.token = token.kind; |
| 302 throw this; | 300 throw this; |
| 303 } | 301 } |
| 304 | 302 |
| 305 void reportError(Token token, | 303 void reportError( |
| 306 messageKind, | 304 DiagnosticMessage message, |
| 307 [Map arguments = const {}]) { | 305 [List<DiagnosticMessage> infos = const <DiagnosticMessage>[]]) { |
| 308 reportFatalError(token, messageKind, arguments); | 306 reportFatalError(message.spannable); |
| 309 } | 307 } |
| 310 | 308 |
| 311 void log(message) { | 309 void log(message) { |
| 312 print(message); | 310 print(message); |
| 313 } | 311 } |
| 314 | 312 |
| 315 noSuchMethod(Invocation invocation) => throw 'unsupported operation'; | 313 noSuchMethod(Invocation invocation) { |
| 314 throw 'unsupported operation'; |
| 315 } |
| 316 |
| 317 @override |
| 318 DiagnosticMessage createMessage(spannable, messageKind, [arguments]) { |
| 319 return new DiagnosticMessage(null, spannable, null); |
| 320 } |
| 316 } | 321 } |
| 317 | 322 |
| 318 void testMissingCloseParen() { | 323 void testMissingCloseParen() { |
| 319 final String source = | 324 final String source = |
| 320 '''foo(x { // <= missing closing ")" | 325 '''foo(x { // <= missing closing ")" |
| 321 return x; | 326 return x; |
| 322 }'''; | 327 }'''; |
| 323 parse() { | 328 parse() { |
| 324 parseMember(source, diagnosticHandler: new Collector()); | 329 parseMember(source, diagnosticHandler: new Collector()); |
| 325 } | 330 } |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 366 testConditionalExpression(); | 371 testConditionalExpression(); |
| 367 testNullOperators(); | 372 testNullOperators(); |
| 368 testAssignment(); | 373 testAssignment(); |
| 369 testIndex(); | 374 testIndex(); |
| 370 testPostfix(); | 375 testPostfix(); |
| 371 testOperatorParse(); | 376 testOperatorParse(); |
| 372 testMissingCloseParen(); | 377 testMissingCloseParen(); |
| 373 testMissingCloseBraceInClass(); | 378 testMissingCloseBraceInClass(); |
| 374 testUnmatchedAngleBracket(); | 379 testUnmatchedAngleBracket(); |
| 375 } | 380 } |
| OLD | NEW |