Chromium Code Reviews| 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('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 236 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 247 node = parseStatement("a.b++;"); | 247 node = parseStatement("a.b++;"); |
| 248 // Should parse as: (a.b)++. | 248 // Should parse as: (a.b)++. |
| 249 expression = node.expression; | 249 expression = node.expression; |
| 250 Expect.isNotNull(sendSet = expression.asSendSet()); | 250 Expect.isNotNull(sendSet = expression.asSendSet()); |
| 251 Expect.stringEquals("a", sendSet.receiver.toString()); | 251 Expect.stringEquals("a", sendSet.receiver.toString()); |
| 252 Expect.stringEquals("b", sendSet.selector.toString()); | 252 Expect.stringEquals("b", sendSet.selector.toString()); |
| 253 Expect.stringEquals("++", sendSet.assignmentOperator.toString()); | 253 Expect.stringEquals("++", sendSet.assignmentOperator.toString()); |
| 254 Expect.isTrue(sendSet.arguments.isEmpty()); | 254 Expect.isTrue(sendSet.arguments.isEmpty()); |
| 255 } | 255 } |
| 256 | 256 |
| 257 void testOperatorParse() { | |
| 258 FunctionDeclaration node = parseStatement('operator negate() => null;'); | |
| 259 FunctionExpression expr = node.function; | |
|
ahe
2012/08/06 10:35:38
Look at the rest of this file. We don't abbreviate
Anton Muhin
2012/08/06 11:36:18
Done.
| |
| 260 Node name = expr.name; | |
| 261 Expect.isTrue(name is Send); | |
|
ahe
2012/08/06 10:35:38
See the above code in testPostfix. This should be:
Anton Muhin
2012/08/06 11:36:18
Done.
| |
| 262 Expect.equals(name.receiver.source.stringValue, 'operator'); | |
|
ahe
2012/08/06 10:35:38
Use stringEquals and put the expected value first.
Anton Muhin
2012/08/06 11:36:18
Done.
| |
| 263 Expect.equals(name.selector.source.stringValue, 'negate'); | |
|
ahe
2012/08/06 10:35:38
Ditto.
Anton Muhin
2012/08/06 11:36:19
Done.
| |
| 264 Expect.isTrue(expr.parameters.isEmpty()); | |
| 265 Expect.isNull(expr.returnType); | |
| 266 Expect.isNull(expr.getOrSet); | |
| 267 } | |
| 268 | |
| 257 void main() { | 269 void main() { |
| 258 testGenericTypes(); | 270 testGenericTypes(); |
| 259 // TODO(ahe): Enable this test when we handle library prefixes. | 271 // TODO(ahe): Enable this test when we handle library prefixes. |
| 260 // testPrefixedGenericTypes(); | 272 // testPrefixedGenericTypes(); |
| 261 testUnaryExpression(); | 273 testUnaryExpression(); |
| 262 testChainedMethodCalls(); | 274 testChainedMethodCalls(); |
| 263 testFunctionStatement(); | 275 testFunctionStatement(); |
| 264 testDoStatement(); | 276 testDoStatement(); |
| 265 testWhileStatement(); | 277 testWhileStatement(); |
| 266 testConditionalExpression(); | 278 testConditionalExpression(); |
| 267 testAssignment(); | 279 testAssignment(); |
| 268 testIndex(); | 280 testIndex(); |
| 269 testPostfix(); | 281 testPostfix(); |
| 282 testOperatorParse(); | |
| 270 } | 283 } |
| OLD | NEW |