OLD | NEW |
1 /* | 1 /* |
2 * Copyright (c) 2012, the Dart project authors. | 2 * Copyright (c) 2012, the Dart project authors. |
3 * | 3 * |
4 * Licensed under the Eclipse Public License v1.0 (the "License"); you may not u
se this file except | 4 * Licensed under the Eclipse Public License v1.0 (the "License"); you may not u
se this file except |
5 * in compliance with the License. You may obtain a copy of the License at | 5 * in compliance with the License. You may obtain a copy of the License at |
6 * | 6 * |
7 * http://www.eclipse.org/legal/epl-v10.html | 7 * http://www.eclipse.org/legal/epl-v10.html |
8 * | 8 * |
9 * Unless required by applicable law or agreed to in writing, software distribut
ed under the License | 9 * Unless required by applicable law or agreed to in writing, software distribut
ed under the License |
10 * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY K
IND, either express | 10 * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY K
IND, either express |
(...skipping 265 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
276 assertTrue(expression.getRightOperand().isSynthetic()); | 276 assertTrue(expression.getRightOperand().isSynthetic()); |
277 } | 277 } |
278 | 278 |
279 public void test_equalityExpression_missing_RHS_super() throws Exception { | 279 public void test_equalityExpression_missing_RHS_super() throws Exception { |
280 BinaryExpression expression = parseExpression("super =="); | 280 BinaryExpression expression = parseExpression("super =="); |
281 assertInstanceOf(SimpleIdentifier.class, expression.getRightOperand()); | 281 assertInstanceOf(SimpleIdentifier.class, expression.getRightOperand()); |
282 assertTrue(expression.getRightOperand().isSynthetic()); | 282 assertTrue(expression.getRightOperand().isSynthetic()); |
283 } | 283 } |
284 | 284 |
285 public void test_equalityExpression_precedence_relational_left() throws Except
ion { | 285 public void test_equalityExpression_precedence_relational_left() throws Except
ion { |
286 BinaryExpression expression = parseExpression("is ==", ParserErrorCode.MISSI
NG_IDENTIFIER); | 286 BinaryExpression expression = parseExpression("is ==", ParserErrorCode.EXPEC
TED_TYPE_NAME); |
287 assertInstanceOf(IsExpression.class, expression.getLeftOperand()); | 287 assertInstanceOf(IsExpression.class, expression.getLeftOperand()); |
288 } | 288 } |
289 | 289 |
290 public void test_equalityExpression_precedence_relational_right() throws Excep
tion { | 290 public void test_equalityExpression_precedence_relational_right() throws Excep
tion { |
291 BinaryExpression expression = parseExpression("== is", ParserErrorCode.MISSI
NG_IDENTIFIER); | 291 BinaryExpression expression = parseExpression("== is", ParserErrorCode.EXPEC
TED_TYPE_NAME); |
292 assertInstanceOf(IsExpression.class, expression.getRightOperand()); | 292 assertInstanceOf(IsExpression.class, expression.getRightOperand()); |
293 } | 293 } |
294 | 294 |
295 public void test_equalityExpression_super() throws Exception { | 295 public void test_equalityExpression_super() throws Exception { |
296 BinaryExpression expression = parseExpression("super == =="); | 296 BinaryExpression expression = parseExpression("super == =="); |
297 assertInstanceOf(BinaryExpression.class, expression.getLeftOperand()); | 297 assertInstanceOf(BinaryExpression.class, expression.getLeftOperand()); |
298 } | 298 } |
299 | 299 |
300 public void test_expressionList_multiple_end() throws Exception { | 300 public void test_expressionList_multiple_end() throws Exception { |
301 List<Expression> result = parse("parseExpressionList", ", 2, 3, 4"); | 301 List<Expression> result = parse("parseExpressionList", ", 2, 3, 4"); |
(...skipping 15 matching lines...) Expand all Loading... |
317 List<Expression> result = parse("parseExpressionList", "1, 2, 3,"); | 317 List<Expression> result = parse("parseExpressionList", "1, 2, 3,"); |
318 assertSize(4, result); | 318 assertSize(4, result); |
319 Expression syntheticExpression = result.get(3); | 319 Expression syntheticExpression = result.get(3); |
320 assertInstanceOf(SimpleIdentifier.class, syntheticExpression); | 320 assertInstanceOf(SimpleIdentifier.class, syntheticExpression); |
321 assertTrue(syntheticExpression.isSynthetic()); | 321 assertTrue(syntheticExpression.isSynthetic()); |
322 } | 322 } |
323 | 323 |
324 public void test_isExpression_noType() throws Exception { | 324 public void test_isExpression_noType() throws Exception { |
325 CompilationUnit unit = parseCompilationUnit( | 325 CompilationUnit unit = parseCompilationUnit( |
326 "class Bar<T extends Foo> {m(x){if (x is ) return;if (x is !)}}", | 326 "class Bar<T extends Foo> {m(x){if (x is ) return;if (x is !)}}", |
327 ParserErrorCode.MISSING_IDENTIFIER, | 327 ParserErrorCode.EXPECTED_TYPE_NAME, |
328 ParserErrorCode.MISSING_IDENTIFIER, | 328 ParserErrorCode.EXPECTED_TYPE_NAME, |
329 ParserErrorCode.MISSING_STATEMENT); | 329 ParserErrorCode.MISSING_STATEMENT); |
330 ClassDeclaration declaration = (ClassDeclaration) unit.getDeclarations().get
(0); | 330 ClassDeclaration declaration = (ClassDeclaration) unit.getDeclarations().get
(0); |
331 MethodDeclaration method = (MethodDeclaration) declaration.getMembers().get(
0); | 331 MethodDeclaration method = (MethodDeclaration) declaration.getMembers().get(
0); |
332 BlockFunctionBody body = (BlockFunctionBody) method.getBody(); | 332 BlockFunctionBody body = (BlockFunctionBody) method.getBody(); |
333 IfStatement ifStatement = (IfStatement) body.getBlock().getStatements().get(
1); | 333 IfStatement ifStatement = (IfStatement) body.getBlock().getStatements().get(
1); |
334 IsExpression expression = (IsExpression) ifStatement.getCondition(); | 334 IsExpression expression = (IsExpression) ifStatement.getCondition(); |
335 assertNotNull(expression.getExpression()); | 335 assertNotNull(expression.getExpression()); |
336 assertNotNull(expression.getIsOperator()); | 336 assertNotNull(expression.getIsOperator()); |
337 assertNotNull(expression.getNotOperator()); | 337 assertNotNull(expression.getNotOperator()); |
338 TypeName type = expression.getType(); | 338 TypeName type = expression.getType(); |
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
449 assertEquals(TokenType.MINUS, expression.getOperator().getType()); | 449 assertEquals(TokenType.MINUS, expression.getOperator().getType()); |
450 } | 450 } |
451 | 451 |
452 public void test_relationalExpression_missing_LHS() throws Exception { | 452 public void test_relationalExpression_missing_LHS() throws Exception { |
453 IsExpression expression = parseExpression("is y"); | 453 IsExpression expression = parseExpression("is y"); |
454 assertInstanceOf(SimpleIdentifier.class, expression.getExpression()); | 454 assertInstanceOf(SimpleIdentifier.class, expression.getExpression()); |
455 assertTrue(expression.getExpression().isSynthetic()); | 455 assertTrue(expression.getExpression().isSynthetic()); |
456 } | 456 } |
457 | 457 |
458 public void test_relationalExpression_missing_LHS_RHS() throws Exception { | 458 public void test_relationalExpression_missing_LHS_RHS() throws Exception { |
459 IsExpression expression = parseExpression("is", ParserErrorCode.MISSING_IDEN
TIFIER); | 459 IsExpression expression = parseExpression("is", ParserErrorCode.EXPECTED_TYP
E_NAME); |
460 assertInstanceOf(SimpleIdentifier.class, expression.getExpression()); | 460 assertInstanceOf(SimpleIdentifier.class, expression.getExpression()); |
461 assertTrue(expression.getExpression().isSynthetic()); | 461 assertTrue(expression.getExpression().isSynthetic()); |
462 assertInstanceOf(TypeName.class, expression.getType()); | 462 assertInstanceOf(TypeName.class, expression.getType()); |
463 assertTrue(expression.getType().isSynthetic()); | 463 assertTrue(expression.getType().isSynthetic()); |
464 } | 464 } |
465 | 465 |
466 public void test_relationalExpression_missing_RHS() throws Exception { | 466 public void test_relationalExpression_missing_RHS() throws Exception { |
467 IsExpression expression = parseExpression("x is", ParserErrorCode.MISSING_ID
ENTIFIER); | 467 IsExpression expression = parseExpression("x is", ParserErrorCode.EXPECTED_T
YPE_NAME); |
468 assertInstanceOf(TypeName.class, expression.getType()); | 468 assertInstanceOf(TypeName.class, expression.getType()); |
469 assertTrue(expression.getType().isSynthetic()); | 469 assertTrue(expression.getType().isSynthetic()); |
470 } | 470 } |
471 | 471 |
472 public void test_relationalExpression_precedence_shift_right() throws Exceptio
n { | 472 public void test_relationalExpression_precedence_shift_right() throws Exceptio
n { |
473 IsExpression expression = parseExpression("<< is", ParserErrorCode.MISSING_I
DENTIFIER); | 473 IsExpression expression = parseExpression("<< is", ParserErrorCode.EXPECTED_
TYPE_NAME); |
474 assertInstanceOf(BinaryExpression.class, expression.getExpression()); | 474 assertInstanceOf(BinaryExpression.class, expression.getExpression()); |
475 } | 475 } |
476 | 476 |
477 public void test_shiftExpression_missing_LHS() throws Exception { | 477 public void test_shiftExpression_missing_LHS() throws Exception { |
478 BinaryExpression expression = parseExpression("<< y"); | 478 BinaryExpression expression = parseExpression("<< y"); |
479 assertInstanceOf(SimpleIdentifier.class, expression.getLeftOperand()); | 479 assertInstanceOf(SimpleIdentifier.class, expression.getLeftOperand()); |
480 assertTrue(expression.getLeftOperand().isSynthetic()); | 480 assertTrue(expression.getLeftOperand().isSynthetic()); |
481 } | 481 } |
482 | 482 |
483 public void test_shiftExpression_missing_LHS_RHS() throws Exception { | 483 public void test_shiftExpression_missing_LHS_RHS() throws Exception { |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
523 CompilationUnit unit = parseCompilationUnit( | 523 CompilationUnit unit = parseCompilationUnit( |
524 "typedef n", | 524 "typedef n", |
525 ParserErrorCode.EXPECTED_TOKEN, | 525 ParserErrorCode.EXPECTED_TOKEN, |
526 ParserErrorCode.MISSING_TYPEDEF_PARAMETERS); | 526 ParserErrorCode.MISSING_TYPEDEF_PARAMETERS); |
527 NodeList<CompilationUnitMember> declarations = unit.getDeclarations(); | 527 NodeList<CompilationUnitMember> declarations = unit.getDeclarations(); |
528 assertSize(1, declarations); | 528 assertSize(1, declarations); |
529 CompilationUnitMember member = declarations.get(0); | 529 CompilationUnitMember member = declarations.get(0); |
530 assertInstanceOf(FunctionTypeAlias.class, member); | 530 assertInstanceOf(FunctionTypeAlias.class, member); |
531 } | 531 } |
532 } | 532 } |
OLD | NEW |