| OLD | NEW |
| 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, 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 package com.google.dart.compiler.parser; | 5 package com.google.dart.compiler.parser; |
| 6 | 6 |
| 7 import com.google.common.base.Joiner; | 7 import com.google.common.base.Joiner; |
| 8 import com.google.dart.compiler.DartCompilerListener; | 8 import com.google.dart.compiler.DartCompilerListener; |
| 9 import com.google.dart.compiler.DartSourceTest; | 9 import com.google.dart.compiler.DartSourceTest; |
| 10 import com.google.dart.compiler.ast.DartAnnotation; | 10 import com.google.dart.compiler.ast.DartAnnotation; |
| (...skipping 22 matching lines...) Expand all Loading... |
| 33 import com.google.dart.compiler.ast.DartStringLiteral; | 33 import com.google.dart.compiler.ast.DartStringLiteral; |
| 34 import com.google.dart.compiler.ast.DartTryStatement; | 34 import com.google.dart.compiler.ast.DartTryStatement; |
| 35 import com.google.dart.compiler.ast.DartTypeExpression; | 35 import com.google.dart.compiler.ast.DartTypeExpression; |
| 36 import com.google.dart.compiler.ast.DartTypeNode; | 36 import com.google.dart.compiler.ast.DartTypeNode; |
| 37 import com.google.dart.compiler.ast.DartUnaryExpression; | 37 import com.google.dart.compiler.ast.DartUnaryExpression; |
| 38 import com.google.dart.compiler.ast.DartUnit; | 38 import com.google.dart.compiler.ast.DartUnit; |
| 39 import com.google.dart.compiler.ast.DartVariable; | 39 import com.google.dart.compiler.ast.DartVariable; |
| 40 import com.google.dart.compiler.ast.DartVariableStatement; | 40 import com.google.dart.compiler.ast.DartVariableStatement; |
| 41 import com.google.dart.compiler.ast.NodeList; | 41 import com.google.dart.compiler.ast.NodeList; |
| 42 | 42 |
| 43 import static com.google.dart.compiler.common.ErrorExpectation.assertErrors; |
| 44 import static com.google.dart.compiler.common.ErrorExpectation.errEx; |
| 45 |
| 43 import java.util.List; | 46 import java.util.List; |
| 44 | 47 |
| 45 public class SyntaxTest extends AbstractParserTest { | 48 public class SyntaxTest extends AbstractParserTest { |
| 46 public void test_exportDirective_combinators() { | 49 public void test_exportDirective_combinators() { |
| 47 parseUnit("test.dart", Joiner.on("\n").join( | 50 parseUnit("test.dart", Joiner.on("\n").join( |
| 48 "library lib;", | 51 "library lib;", |
| 49 "export 'a.dart' show A, B hide C, D;")); | 52 "export 'a.dart' show A, B hide C, D;")); |
| 50 } | 53 } |
| 51 | 54 |
| 52 public void test_exportDirective_noCombinators() { | 55 public void test_exportDirective_noCombinators() { |
| (...skipping 24 matching lines...) Expand all Loading... |
| 77 public void test_switch_noLBrace() { | 80 public void test_switch_noLBrace() { |
| 78 parseUnit("test.dart", Joiner.on("\n").join( | 81 parseUnit("test.dart", Joiner.on("\n").join( |
| 79 "// filler filler filler filler filler filler filler filler filler fille
r", | 82 "// filler filler filler filler filler filler filler filler filler fille
r", |
| 80 "main() {", | 83 "main() {", |
| 81 " switch (0)", | 84 " switch (0)", |
| 82 "}", | 85 "}", |
| 83 ""), | 86 ""), |
| 84 ParserErrorCode.EXPECTED_TOKEN, 3, 12); | 87 ParserErrorCode.EXPECTED_TOKEN, 3, 12); |
| 85 } | 88 } |
| 86 | 89 |
| 90 /** |
| 91 * There was bug that handling missing identifier (method name) after "cursor.
" in switch caused |
| 92 * infinite parsing loop. |
| 93 * <p> |
| 94 * http://code.google.com/p/dart/issues/detail?id=6908 |
| 95 */ |
| 96 public void test_switch_noMethodName_inCase() { |
| 97 DartParserRunner runner = parseSource(Joiner.on("\n").join( |
| 98 "// filler filler filler filler filler filler filler filler filler fille
r", |
| 99 "void main() {", |
| 100 " print((e) {", |
| 101 " switch (e) {", |
| 102 " case 'Up': cursor.();", |
| 103 " case 'Down':", |
| 104 " }", |
| 105 " }); ", |
| 106 "}", |
| 107 "")); |
| 108 assertErrors(runner.getErrors(), |
| 109 errEx(ParserErrorCode.INVALID_IDENTIFIER, 5, 24, 1)); |
| 110 } |
| 111 |
| 87 public void test_getter() { | 112 public void test_getter() { |
| 88 parseUnit("getter.dart", Joiner.on("\n").join( | 113 parseUnit("getter.dart", Joiner.on("\n").join( |
| 89 "class G {", | 114 "class G {", |
| 90 " // Old getter syntax", | 115 " // Old getter syntax", |
| 91 " int get g1 => 1;", | 116 " int get g1 => 1;", |
| 92 " // New getter syntax", | 117 " // New getter syntax", |
| 93 " int get g2 => 2;", | 118 " int get g2 => 2;", |
| 94 "}")); | 119 "}")); |
| 95 } | 120 } |
| 96 | 121 |
| (...skipping 1419 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1516 "typedef func(var arg());", | 1541 "typedef func(var arg());", |
| 1517 ParserErrorCode.FUNCTION_TYPED_PARAMETER_IS_VAR, 1, 18); | 1542 ParserErrorCode.FUNCTION_TYPED_PARAMETER_IS_VAR, 1, 18); |
| 1518 } | 1543 } |
| 1519 | 1544 |
| 1520 public void test_finalInFunctionType() throws Exception { | 1545 public void test_finalInFunctionType() throws Exception { |
| 1521 parseUnit("phony_var_in_function_type.dart", | 1546 parseUnit("phony_var_in_function_type.dart", |
| 1522 "typedef func(final arg());", | 1547 "typedef func(final arg());", |
| 1523 ParserErrorCode.FUNCTION_TYPED_PARAMETER_IS_FINAL, 1, 20); | 1548 ParserErrorCode.FUNCTION_TYPED_PARAMETER_IS_FINAL, 1, 20); |
| 1524 } | 1549 } |
| 1525 } | 1550 } |
| OLD | NEW |