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 241 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
252 Expect.stringEquals("a", sendSet.receiver.toString()); | 252 Expect.stringEquals("a", sendSet.receiver.toString()); |
253 Expect.stringEquals("b", sendSet.selector.toString()); | 253 Expect.stringEquals("b", sendSet.selector.toString()); |
254 Expect.stringEquals("++", sendSet.assignmentOperator.toString()); | 254 Expect.stringEquals("++", sendSet.assignmentOperator.toString()); |
255 Expect.isTrue(sendSet.arguments.isEmpty); | 255 Expect.isTrue(sendSet.arguments.isEmpty); |
256 } | 256 } |
257 | 257 |
258 void testOperatorParse() { | 258 void testOperatorParse() { |
259 FunctionExpression function = parseMember('operator -() => null;'); | 259 FunctionExpression function = parseMember('operator -() => null;'); |
260 Send name = function.name.asSend(); | 260 Send name = function.name.asSend(); |
261 Expect.isNotNull(name); | 261 Expect.isNotNull(name); |
262 Expect.stringEquals('operator', name.receiver.source); | 262 Expect.stringEquals('operator', name.receiver.toString()); |
263 Expect.stringEquals('-', name.selector.source); | 263 Expect.stringEquals('-', name.selector.toString()); |
264 Expect.isTrue(function.parameters.isEmpty); | 264 Expect.isTrue(function.parameters.isEmpty); |
265 Expect.isNull(function.returnType); | 265 Expect.isNull(function.returnType); |
266 Expect.isNull(function.getOrSet); | 266 Expect.isNull(function.getOrSet); |
267 } | 267 } |
268 | 268 |
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, | 279 void reportError(Token token, |
280 messageKind, | 280 messageKind, |
281 [Map arguments = const {}]) { | 281 [Map arguments = const {}]) { |
282 reportFatalError(token, messageKind, arguments); | 282 reportFatalError(token, messageKind, arguments); |
283 } | 283 } |
284 | 284 |
285 void log(message) { | 285 void log(message) { |
286 print(message); | 286 print(message); |
287 } | 287 } |
| 288 |
| 289 noSuchMethod(Invocation invocation) => throw 'unsupported operation'; |
288 } | 290 } |
289 | 291 |
290 void testMissingCloseParen() { | 292 void testMissingCloseParen() { |
291 final String source = | 293 final String source = |
292 '''foo(x { // <= missing closing ")" | 294 '''foo(x { // <= missing closing ")" |
293 return x; | 295 return x; |
294 }'''; | 296 }'''; |
295 parse() { | 297 parse() { |
296 parseMember(source, diagnosticHandler: new Collector()); | 298 parseMember(source, diagnosticHandler: new Collector()); |
297 } | 299 } |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
337 testWhileStatement(); | 339 testWhileStatement(); |
338 testConditionalExpression(); | 340 testConditionalExpression(); |
339 testAssignment(); | 341 testAssignment(); |
340 testIndex(); | 342 testIndex(); |
341 testPostfix(); | 343 testPostfix(); |
342 testOperatorParse(); | 344 testOperatorParse(); |
343 testMissingCloseParen(); | 345 testMissingCloseParen(); |
344 testMissingCloseBraceInClass(); | 346 testMissingCloseBraceInClass(); |
345 testUnmatchedAngleBracket(); | 347 testUnmatchedAngleBracket(); |
346 } | 348 } |
OLD | NEW |