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 233 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
244 Expression expression; | 244 Expression expression; |
245 SendSet sendSet; | 245 SendSet sendSet; |
246 | 246 |
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() { | 257 void testOperatorParse() { |
258 FunctionExpression function = parseMember('operator -() => null;'); | 258 FunctionExpression function = parseMember('operator -() => null;'); |
259 Send name = function.name.asSend(); | 259 Send name = function.name.asSend(); |
260 Expect.isNotNull(name); | 260 Expect.isNotNull(name); |
261 Expect.stringEquals('operator', name.receiver.source.stringValue); | 261 Expect.stringEquals('operator', name.receiver.source.stringValue); |
262 Expect.stringEquals('-', name.selector.source.stringValue); | 262 Expect.stringEquals('-', name.selector.source.stringValue); |
263 Expect.isTrue(function.parameters.isEmpty()); | 263 Expect.isTrue(function.parameters.isEmpty); |
264 Expect.isNull(function.returnType); | 264 Expect.isNull(function.returnType); |
265 Expect.isNull(function.getOrSet); | 265 Expect.isNull(function.getOrSet); |
266 } | 266 } |
267 | 267 |
268 void main() { | 268 void main() { |
269 testGenericTypes(); | 269 testGenericTypes(); |
270 // TODO(ahe): Enable this test when we handle library prefixes. | 270 // TODO(ahe): Enable this test when we handle library prefixes. |
271 // testPrefixedGenericTypes(); | 271 // testPrefixedGenericTypes(); |
272 testUnaryExpression(); | 272 testUnaryExpression(); |
273 testChainedMethodCalls(); | 273 testChainedMethodCalls(); |
274 testFunctionStatement(); | 274 testFunctionStatement(); |
275 testDoStatement(); | 275 testDoStatement(); |
276 testWhileStatement(); | 276 testWhileStatement(); |
277 testConditionalExpression(); | 277 testConditionalExpression(); |
278 testAssignment(); | 278 testAssignment(); |
279 testIndex(); | 279 testIndex(); |
280 testPostfix(); | 280 testPostfix(); |
281 testOperatorParse(); | 281 testOperatorParse(); |
282 } | 282 } |
OLD | NEW |