Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright (c) 2017, the Dart project authors. Please see the AUTHORS file | |
| 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. | |
| 4 | |
| 5 import 'package:analyzer/dart/ast/ast.dart'; | |
| 6 import 'package:analyzer/dart/element/element.dart'; | |
| 7 import 'package:analyzer/error/error.dart'; | |
| 8 import 'package:front_end/src/fasta/analyzer/ast_builder.dart'; | |
| 9 import 'package:front_end/src/fasta/analyzer/element_store.dart'; | |
| 10 import 'package:front_end/src/fasta/builder/scope.dart'; | |
| 11 import 'package:front_end/src/fasta/kernel/kernel_builder.dart'; | |
| 12 import 'package:front_end/src/fasta/kernel/kernel_library_builder.dart'; | |
| 13 import 'package:front_end/src/fasta/parser/parser.dart'; | |
| 14 import 'package:front_end/src/fasta/scanner/string_scanner.dart'; | |
| 15 import 'package:test/test.dart'; | |
| 16 import 'package:test_reflective_loader/test_reflective_loader.dart'; | |
| 17 | |
| 18 import 'parser_test.dart'; | |
| 19 | |
| 20 main() { | |
| 21 defineReflectiveSuite(() { | |
| 22 defineReflectiveTests(ComplexParserTest_Fasta); | |
| 23 }); | |
| 24 } | |
| 25 | |
| 26 /** | |
| 27 * Proxy implementation of [Builder] used by Fasta parser tests. | |
| 28 * | |
| 29 * All undeclared identifiers are presumed to resolve via an instance of this | |
| 30 * class. | |
| 31 */ | |
| 32 class BuilderProxy implements Builder { | |
|
ahe
2017/02/07 09:47:16
Do you need to use @proxy?
Paul Berry
2017/02/07 13:45:13
No. "@proxy" is appropriate when the class's impl
| |
| 33 noSuchMethod(Invocation invocation) => super.noSuchMethod(invocation); | |
| 34 } | |
| 35 | |
| 36 /** | |
| 37 * Tests of the fasta parser based on [ComplexParserTestMixin]. | |
| 38 */ | |
| 39 @reflectiveTest | |
| 40 class ComplexParserTest_Fasta extends FastaParserTestCase | |
| 41 with ComplexParserTestMixin { | |
| 42 @override | |
| 43 @failingTest | |
| 44 void test_additiveExpression_precedence_multiplicative_left_withSuper() { | |
| 45 // TODO(paulberry,ahe): AstBuilder doesn't implement | |
| 46 // handleSuperExpression(). | |
| 47 super.test_additiveExpression_precedence_multiplicative_left_withSuper(); | |
| 48 } | |
| 49 | |
| 50 @override | |
| 51 @failingTest | |
| 52 void test_additiveExpression_super() { | |
| 53 // TODO(paulberry,ahe): AstBuilder doesn't implement | |
| 54 // handleSuperExpression(). | |
| 55 super.test_additiveExpression_super(); | |
| 56 } | |
| 57 | |
| 58 @override | |
| 59 @failingTest | |
| 60 void test_assignableExpression_arguments_normal_chain() { | |
| 61 // TODO(paulberry,ahe): AstBuilder.doInvocation doesn't handle receiver | |
| 62 // other than SimpleIdentifier. | |
| 63 super.test_assignableExpression_arguments_normal_chain(); | |
| 64 } | |
| 65 | |
| 66 @override | |
| 67 @failingTest | |
| 68 void test_assignableExpression_arguments_normal_chain_typeArgumentComments() { | |
| 69 // TODO(paulberry,ahe): Fasta doesn't support generic method comment syntax. | |
| 70 super | |
| 71 .test_assignableExpression_arguments_normal_chain_typeArgumentComments() ; | |
|
ahe
2017/02/07 09:47:16
Long line.
Paul Berry
2017/02/07 13:45:13
Acknowledged.
| |
| 72 } | |
| 73 | |
| 74 @override | |
| 75 @failingTest | |
| 76 void test_assignableExpression_arguments_normal_chain_typeArguments() { | |
| 77 // TODO(paulberry,ahe): AstBuilder doesn't implement | |
| 78 // endTypeArguments(). | |
| 79 super.test_assignableExpression_arguments_normal_chain_typeArguments(); | |
| 80 } | |
| 81 | |
| 82 @override | |
| 83 @failingTest | |
| 84 void test_assignmentExpression_prefixedIdentifier() { | |
| 85 // TODO(paulberry,ahe): Analyzer expects "x.y" to be parsed as a | |
| 86 // PrefixedIdentifier, even if x is not a prefix. | |
| 87 super.test_assignmentExpression_prefixedIdentifier(); | |
| 88 } | |
| 89 | |
| 90 @override | |
| 91 @failingTest | |
| 92 void test_assignmentExpression_propertyAccess() { | |
| 93 // TODO(paulberry,ahe): AstBuilder doesn't implement | |
| 94 // handleSuperExpression(). | |
| 95 super.test_assignmentExpression_propertyAccess(); | |
| 96 } | |
| 97 | |
| 98 @override | |
| 99 @failingTest | |
| 100 void test_bitwiseAndExpression_super() { | |
| 101 // TODO(paulberry,ahe): AstBuilder doesn't implement | |
| 102 // handleSuperExpression(). | |
| 103 super.test_bitwiseAndExpression_super(); | |
| 104 } | |
| 105 | |
| 106 @override | |
| 107 @failingTest | |
| 108 void test_bitwiseOrExpression_super() { | |
| 109 // TODO(paulberry,ahe): AstBuilder doesn't implement | |
| 110 // handleSuperExpression(). | |
| 111 super.test_bitwiseOrExpression_super(); | |
| 112 } | |
| 113 | |
| 114 @override | |
| 115 @failingTest | |
| 116 void test_bitwiseXorExpression_super() { | |
| 117 // TODO(paulberry,ahe): AstBuilder doesn't implement | |
| 118 // handleSuperExpression(). | |
| 119 super.test_bitwiseXorExpression_super(); | |
| 120 } | |
| 121 | |
| 122 @override | |
| 123 @failingTest | |
| 124 void test_cascade_withAssignment() { | |
| 125 // TODO(paulberry,ahe): AstBuilder doesn't implement | |
| 126 // endConstructorReference(). | |
| 127 super.test_cascade_withAssignment(); | |
| 128 } | |
| 129 | |
| 130 @override | |
| 131 @failingTest | |
| 132 void test_conditionalExpression_precedence_nullableType_as() { | |
| 133 // TODO(paulberry,ahe): Fasta doesn't support NNBD syntax yet. | |
| 134 super.test_conditionalExpression_precedence_nullableType_as(); | |
| 135 } | |
| 136 | |
| 137 @override | |
| 138 @failingTest | |
| 139 void test_conditionalExpression_precedence_nullableType_is() { | |
| 140 // TODO(paulberry,ahe): Fasta doesn't support NNBD syntax yet. | |
| 141 super.test_conditionalExpression_precedence_nullableType_is(); | |
| 142 } | |
| 143 | |
| 144 @override | |
| 145 @failingTest | |
| 146 void test_equalityExpression_normal() { | |
| 147 // TODO(paulberry,ahe): bad error recovery | |
| 148 super.test_equalityExpression_normal(); | |
| 149 } | |
| 150 | |
| 151 @override | |
| 152 @failingTest | |
| 153 void test_equalityExpression_super() { | |
| 154 // TODO(paulberry,ahe): AstBuilder doesn't implement | |
| 155 // handleSuperExpression(). | |
| 156 super.test_equalityExpression_super(); | |
| 157 } | |
| 158 | |
| 159 @override | |
| 160 @failingTest | |
| 161 void test_logicalAndExpression_precedence_nullableType() { | |
| 162 // TODO(paulberry,ahe): Fasta doesn't support NNBD syntax yet. | |
| 163 super.test_logicalAndExpression_precedence_nullableType(); | |
| 164 } | |
| 165 | |
| 166 @override | |
| 167 @failingTest | |
| 168 void test_logicalOrExpression_precedence_nullableType() { | |
| 169 // TODO(paulberry,ahe): Fasta doesn't support NNBD syntax yet. | |
| 170 super.test_logicalOrExpression_precedence_nullableType(); | |
| 171 } | |
| 172 | |
| 173 @override | |
| 174 @failingTest | |
| 175 void test_multiplicativeExpression_super() { | |
| 176 // TODO(paulberry,ahe): AstBuilder doesn't implement | |
| 177 // handleSuperExpression(). | |
| 178 super.test_multiplicativeExpression_super(); | |
| 179 } | |
| 180 | |
| 181 @override | |
| 182 @failingTest | |
| 183 void test_shiftExpression_super() { | |
| 184 // TODO(paulberry,ahe): AstBuilder doesn't implement | |
| 185 // handleSuperExpression(). | |
| 186 super.test_shiftExpression_super(); | |
| 187 } | |
| 188 | |
| 189 @override | |
| 190 @failingTest | |
| 191 void test_topLevelFunction_nestedGenericFunction() { | |
| 192 // TODO(paulberry): Implement parseCompilationUnitWithOptions | |
| 193 super.test_topLevelFunction_nestedGenericFunction(); | |
| 194 } | |
| 195 } | |
| 196 | |
| 197 /** | |
| 198 * Proxy implementation of [KernelClassElement] used by Fasta parser tests. | |
| 199 * | |
| 200 * All undeclared identifiers are presumed to resolve to an instance of this | |
| 201 * class. | |
| 202 */ | |
| 203 class ElementProxy implements KernelClassElement { | |
| 204 @override | |
| 205 final KernelInterfaceType rawType = new InterfaceTypeProxy(); | |
| 206 | |
| 207 noSuchMethod(Invocation invocation) => super.noSuchMethod(invocation); | |
| 208 } | |
| 209 | |
| 210 /** | |
| 211 * Proxy implementation of [KernelClassElement] used by Fasta parser tests. | |
| 212 * | |
| 213 * Any request for an element is satisfied by creating an instance of | |
| 214 * [ElementProxy]. | |
| 215 */ | |
| 216 class ElementStoreProxy implements ElementStore { | |
| 217 final _elements = <Builder, Element>{}; | |
| 218 | |
| 219 @override | |
| 220 Element operator [](Builder builder) => | |
| 221 _elements.putIfAbsent(builder, () => new ElementProxy()); | |
| 222 | |
| 223 noSuchMethod(Invocation invocation) => super.noSuchMethod(invocation); | |
| 224 } | |
| 225 | |
| 226 /** | |
| 227 * Implementation of [AbstractParserTestCase] specialized for testing the | |
| 228 * Fasta parser. | |
| 229 */ | |
| 230 class FastaParserTestCase implements AbstractParserTestCase { | |
| 231 @override | |
| 232 set enableGenericMethodComments(bool value) { | |
| 233 if (value == true) { | |
| 234 // TODO(paulberry,ahe): generic method comment syntax is not supported by | |
| 235 // Fasta. | |
| 236 throw new UnimplementedError(); | |
| 237 } | |
| 238 } | |
| 239 | |
| 240 @override | |
| 241 set enableNnbd(bool value) { | |
| 242 if (value == true) { | |
| 243 // TODO(paulberry,ahe): non-null-by-default syntax is not supported by | |
| 244 // Fasta. | |
| 245 throw new UnimplementedError(); | |
| 246 } | |
| 247 } | |
| 248 | |
| 249 @override | |
| 250 CompilationUnit parseCompilationUnitWithOptions(String source, | |
| 251 [List<ErrorCode> errorCodes = const <ErrorCode>[]]) { | |
| 252 // TODO(paulberry): implement parseCompilationUnitWithOptions | |
| 253 throw new UnimplementedError(); | |
| 254 } | |
| 255 | |
| 256 @override | |
| 257 Expression parseExpression(String source, | |
| 258 [List<ErrorCode> errorCodes = const <ErrorCode>[]]) { | |
| 259 var scanner = new StringScanner(source); | |
| 260 var token = scanner.tokenize(); | |
| 261 var library = new KernelLibraryBuilderProxy(); | |
| 262 var member = new BuilderProxy(); | |
| 263 var elementStore = new ElementStoreProxy(); | |
| 264 var scope = new ScopeProxy(); | |
| 265 var astBuilder = new AstBuilder(library, member, elementStore, scope); | |
| 266 var parser = new Parser(astBuilder); | |
| 267 var endToken = parser.parseExpression(token); | |
| 268 expect(endToken.isEof, isTrue); | |
| 269 expect(astBuilder.stack, hasLength(1)); | |
| 270 var expression = astBuilder.pop() as Expression; | |
| 271 return expression; | |
| 272 } | |
| 273 } | |
| 274 | |
| 275 /** | |
| 276 * Proxy implementation of [KernelClassElement] used by Fasta parser tests. | |
| 277 * | |
| 278 * Any element used as a type name is presumed to refer to an instance of this | |
| 279 * class. | |
| 280 */ | |
| 281 class InterfaceTypeProxy implements KernelInterfaceType { | |
| 282 noSuchMethod(Invocation invocation) => super.noSuchMethod(invocation); | |
| 283 } | |
| 284 | |
| 285 /** | |
| 286 * Proxy implementation of [KernelLibraryBuilderProxy] used by Fasta parser | |
| 287 * tests. | |
| 288 */ | |
| 289 class KernelLibraryBuilderProxy implements KernelLibraryBuilder { | |
| 290 @override | |
| 291 final uri = Uri.parse('file:///test.dart'); | |
| 292 | |
| 293 noSuchMethod(Invocation invocation) => super.noSuchMethod(invocation); | |
| 294 } | |
| 295 | |
| 296 /** | |
| 297 * Proxy implementation of [Scope] used by Fasta parser tests. | |
| 298 * | |
| 299 * Any name lookup request is satisfied by creating an instance of | |
| 300 * [BuilderProxy]. | |
| 301 */ | |
| 302 class ScopeProxy implements Scope { | |
| 303 final _locals = <String, Builder>{}; | |
| 304 | |
| 305 Builder lookup(String name) => | |
| 306 _locals.putIfAbsent(name, () => new BuilderProxy()); | |
| 307 | |
| 308 noSuchMethod(Invocation invocation) => super.noSuchMethod(invocation); | |
| 309 } | |
| OLD | NEW |