| 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 '../../../sdk/lib/_internal/compiler/implementation/tree/tree.dart'; | 7 import '../../../sdk/lib/_internal/compiler/implementation/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 258 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 269 class Collector implements DiagnosticListener { | 269 class Collector implements DiagnosticListener { |
| 270 int token = -1; | 270 int token = -1; |
| 271 | 271 |
| 272 void reportFatalError(Token token, | 272 void reportFatalError(Token token, |
| 273 messageKind, | 273 messageKind, |
| 274 [Map arguments = const {}]) { | 274 [Map arguments = const {}]) { |
| 275 this.token = token.kind; | 275 this.token = token.kind; |
| 276 throw this; | 276 throw this; |
| 277 } | 277 } |
| 278 | 278 |
| 279 void reportError(Token token, |
| 280 messageKind, |
| 281 [Map arguments = const {}]) { |
| 282 reportFatalError(token, messageKind, arguments); |
| 283 } |
| 284 |
| 279 void log(message) { | 285 void log(message) { |
| 280 print(message); | 286 print(message); |
| 281 } | 287 } |
| 282 } | 288 } |
| 283 | 289 |
| 284 void testMissingCloseParen() { | 290 void testMissingCloseParen() { |
| 285 final String source = | 291 final String source = |
| 286 '''foo(x { // <= missing closing ")" | 292 '''foo(x { // <= missing closing ")" |
| 287 return x; | 293 return x; |
| 288 }'''; | 294 }'''; |
| 289 parse() { | 295 parse() { |
| 290 parseMember(source, diagnosticHandler: new Collector()); | 296 parseMember(source, diagnosticHandler: new Collector()); |
| 291 } | 297 } |
| 292 check(Collector c) { | 298 check(Collector c) { |
| 293 Expect.equals(OPEN_CURLY_BRACKET_TOKEN, c.token); | 299 Expect.equals(OPEN_CURLY_BRACKET_TOKEN, c.token); |
| 294 return true; | 300 return true; |
| 295 } | 301 } |
| 296 Expect.throws(parse, check); | 302 Expect.throws(parse, check); |
| 297 } | 303 } |
| 298 | 304 |
| 299 void testMissingCloseBraceInClass() { | 305 void testMissingCloseBraceInClass() { |
| 300 final String source = 'class Foo {'; // Missing close '}'. | 306 final String source = 'class Foo {'; // Missing close '}'. |
| 301 parse() { | 307 parse() { |
| 302 fullParseUnit(source, diagnosticHandler: new Collector()); | 308 fullParseUnit(source, diagnosticHandler: new Collector()); |
| 303 } | 309 } |
| 304 check(Collector c) { | 310 check(Collector c) { |
| 305 Expect.equals(EOF_TOKEN, c.token); | 311 Expect.equals(BAD_INPUT_TOKEN, c.token); |
| 306 return true; | 312 return true; |
| 307 } | 313 } |
| 308 Expect.throws(parse, check); | 314 Expect.throws(parse, check); |
| 309 } | 315 } |
| 310 | 316 |
| 311 void testUnmatchedAngleBracket() { | 317 void testUnmatchedAngleBracket() { |
| 312 final String source = 'A<'; // unmatched '<' | 318 final String source = 'A<'; // unmatched '<' |
| 313 parse() { | 319 parse() { |
| 314 fullParseUnit(source, diagnosticHandler: new Collector()); | 320 fullParseUnit(source, diagnosticHandler: new Collector()); |
| 315 } | 321 } |
| (...skipping 15 matching lines...) Expand all Loading... |
| 331 testWhileStatement(); | 337 testWhileStatement(); |
| 332 testConditionalExpression(); | 338 testConditionalExpression(); |
| 333 testAssignment(); | 339 testAssignment(); |
| 334 testIndex(); | 340 testIndex(); |
| 335 testPostfix(); | 341 testPostfix(); |
| 336 testOperatorParse(); | 342 testOperatorParse(); |
| 337 testMissingCloseParen(); | 343 testMissingCloseParen(); |
| 338 testMissingCloseBraceInClass(); | 344 testMissingCloseBraceInClass(); |
| 339 testUnmatchedAngleBracket(); | 345 testUnmatchedAngleBracket(); |
| 340 } | 346 } |
| OLD | NEW |