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 286 matching lines...) Loading... |
297 } | 297 } |
298 | 298 |
299 class Collector extends DiagnosticReporter { | 299 class Collector extends DiagnosticReporter { |
300 int token = -1; | 300 int token = -1; |
301 | 301 |
302 void reportFatalError(Token token) { | 302 void reportFatalError(Token token) { |
303 this.token = token.kind; | 303 this.token = token.kind; |
304 throw this; | 304 throw this; |
305 } | 305 } |
306 | 306 |
307 void reportError( | 307 void reportError(DiagnosticMessage message, |
308 DiagnosticMessage message, | |
309 [List<DiagnosticMessage> infos = const <DiagnosticMessage>[]]) { | 308 [List<DiagnosticMessage> infos = const <DiagnosticMessage>[]]) { |
310 reportFatalError(message.spannable); | 309 reportFatalError(message.spannable); |
311 } | 310 } |
312 | 311 |
313 void log(message) { | 312 void log(message) { |
314 print(message); | 313 print(message); |
315 } | 314 } |
316 | 315 |
317 noSuchMethod(Invocation invocation) { | 316 noSuchMethod(Invocation invocation) { |
318 throw 'unsupported operation'; | 317 throw 'unsupported operation'; |
319 } | 318 } |
320 | 319 |
321 @override | 320 @override |
322 DiagnosticMessage createMessage( | 321 DiagnosticMessage createMessage(spannable, messageKind, |
323 spannable, messageKind, [arguments = const {}]) { | 322 [arguments = const {}]) { |
324 return new DiagnosticMessage(null, spannable, null); | 323 return new DiagnosticMessage(null, spannable, null); |
325 } | 324 } |
326 } | 325 } |
327 | 326 |
328 void testMissingCloseParen() { | 327 void testMissingCloseParen() { |
329 final String source = | 328 final String source = '''foo(x { // <= missing closing ")" |
330 '''foo(x { // <= missing closing ")" | |
331 return x; | 329 return x; |
332 }'''; | 330 }'''; |
333 parse() { | 331 parse() { |
334 parseMember(source, reporter: new Collector()); | 332 parseMember(source, reporter: new Collector()); |
335 } | 333 } |
336 check(Collector c) { | 334 check(Collector c) { |
337 Expect.equals(OPEN_CURLY_BRACKET_TOKEN, c.token); | 335 Expect.equals(OPEN_CURLY_BRACKET_TOKEN, c.token); |
338 return true; | 336 return true; |
339 } | 337 } |
340 Expect.throws(parse, check); | 338 Expect.throws(parse, check); |
(...skipping 35 matching lines...) Loading... |
376 testConditionalExpression(); | 374 testConditionalExpression(); |
377 testNullOperators(); | 375 testNullOperators(); |
378 testAssignment(); | 376 testAssignment(); |
379 testIndex(); | 377 testIndex(); |
380 testPostfix(); | 378 testPostfix(); |
381 testOperatorParse(); | 379 testOperatorParse(); |
382 testMissingCloseParen(); | 380 testMissingCloseParen(); |
383 testMissingCloseBraceInClass(); | 381 testMissingCloseBraceInClass(); |
384 testUnmatchedAngleBracket(); | 382 testUnmatchedAngleBracket(); |
385 } | 383 } |
OLD | NEW |