Chromium Code Reviews| Index: pkg/analyzer/test/generated/parser_test_fasta.dart |
| diff --git a/pkg/analyzer/test/generated/parser_test_fasta.dart b/pkg/analyzer/test/generated/parser_test_fasta.dart |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..618162efe423eb98e5b0487306b074b0bf0c12b4 |
| --- /dev/null |
| +++ b/pkg/analyzer/test/generated/parser_test_fasta.dart |
| @@ -0,0 +1,309 @@ |
| +// Copyright (c) 2017, the Dart project authors. Please see the AUTHORS file |
| +// for details. All rights reserved. Use of this source code is governed by a |
| +// BSD-style license that can be found in the LICENSE file. |
| + |
| +import 'package:analyzer/dart/ast/ast.dart'; |
| +import 'package:analyzer/dart/element/element.dart'; |
| +import 'package:analyzer/error/error.dart'; |
| +import 'package:front_end/src/fasta/analyzer/ast_builder.dart'; |
| +import 'package:front_end/src/fasta/analyzer/element_store.dart'; |
| +import 'package:front_end/src/fasta/builder/scope.dart'; |
| +import 'package:front_end/src/fasta/kernel/kernel_builder.dart'; |
| +import 'package:front_end/src/fasta/kernel/kernel_library_builder.dart'; |
| +import 'package:front_end/src/fasta/parser/parser.dart'; |
| +import 'package:front_end/src/fasta/scanner/string_scanner.dart'; |
| +import 'package:test/test.dart'; |
| +import 'package:test_reflective_loader/test_reflective_loader.dart'; |
| + |
| +import 'parser_test.dart'; |
| + |
| +main() { |
| + defineReflectiveSuite(() { |
| + defineReflectiveTests(ComplexParserTest_Fasta); |
| + }); |
| +} |
| + |
| +/** |
| + * Proxy implementation of [Builder] used by Fasta parser tests. |
| + * |
| + * All undeclared identifiers are presumed to resolve via an instance of this |
| + * class. |
| + */ |
| +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
|
| + noSuchMethod(Invocation invocation) => super.noSuchMethod(invocation); |
| +} |
| + |
| +/** |
| + * Tests of the fasta parser based on [ComplexParserTestMixin]. |
| + */ |
| +@reflectiveTest |
| +class ComplexParserTest_Fasta extends FastaParserTestCase |
| + with ComplexParserTestMixin { |
| + @override |
| + @failingTest |
| + void test_additiveExpression_precedence_multiplicative_left_withSuper() { |
| + // TODO(paulberry,ahe): AstBuilder doesn't implement |
| + // handleSuperExpression(). |
| + super.test_additiveExpression_precedence_multiplicative_left_withSuper(); |
| + } |
| + |
| + @override |
| + @failingTest |
| + void test_additiveExpression_super() { |
| + // TODO(paulberry,ahe): AstBuilder doesn't implement |
| + // handleSuperExpression(). |
| + super.test_additiveExpression_super(); |
| + } |
| + |
| + @override |
| + @failingTest |
| + void test_assignableExpression_arguments_normal_chain() { |
| + // TODO(paulberry,ahe): AstBuilder.doInvocation doesn't handle receiver |
| + // other than SimpleIdentifier. |
| + super.test_assignableExpression_arguments_normal_chain(); |
| + } |
| + |
| + @override |
| + @failingTest |
| + void test_assignableExpression_arguments_normal_chain_typeArgumentComments() { |
| + // TODO(paulberry,ahe): Fasta doesn't support generic method comment syntax. |
| + super |
| + .test_assignableExpression_arguments_normal_chain_typeArgumentComments(); |
|
ahe
2017/02/07 09:47:16
Long line.
Paul Berry
2017/02/07 13:45:13
Acknowledged.
|
| + } |
| + |
| + @override |
| + @failingTest |
| + void test_assignableExpression_arguments_normal_chain_typeArguments() { |
| + // TODO(paulberry,ahe): AstBuilder doesn't implement |
| + // endTypeArguments(). |
| + super.test_assignableExpression_arguments_normal_chain_typeArguments(); |
| + } |
| + |
| + @override |
| + @failingTest |
| + void test_assignmentExpression_prefixedIdentifier() { |
| + // TODO(paulberry,ahe): Analyzer expects "x.y" to be parsed as a |
| + // PrefixedIdentifier, even if x is not a prefix. |
| + super.test_assignmentExpression_prefixedIdentifier(); |
| + } |
| + |
| + @override |
| + @failingTest |
| + void test_assignmentExpression_propertyAccess() { |
| + // TODO(paulberry,ahe): AstBuilder doesn't implement |
| + // handleSuperExpression(). |
| + super.test_assignmentExpression_propertyAccess(); |
| + } |
| + |
| + @override |
| + @failingTest |
| + void test_bitwiseAndExpression_super() { |
| + // TODO(paulberry,ahe): AstBuilder doesn't implement |
| + // handleSuperExpression(). |
| + super.test_bitwiseAndExpression_super(); |
| + } |
| + |
| + @override |
| + @failingTest |
| + void test_bitwiseOrExpression_super() { |
| + // TODO(paulberry,ahe): AstBuilder doesn't implement |
| + // handleSuperExpression(). |
| + super.test_bitwiseOrExpression_super(); |
| + } |
| + |
| + @override |
| + @failingTest |
| + void test_bitwiseXorExpression_super() { |
| + // TODO(paulberry,ahe): AstBuilder doesn't implement |
| + // handleSuperExpression(). |
| + super.test_bitwiseXorExpression_super(); |
| + } |
| + |
| + @override |
| + @failingTest |
| + void test_cascade_withAssignment() { |
| + // TODO(paulberry,ahe): AstBuilder doesn't implement |
| + // endConstructorReference(). |
| + super.test_cascade_withAssignment(); |
| + } |
| + |
| + @override |
| + @failingTest |
| + void test_conditionalExpression_precedence_nullableType_as() { |
| + // TODO(paulberry,ahe): Fasta doesn't support NNBD syntax yet. |
| + super.test_conditionalExpression_precedence_nullableType_as(); |
| + } |
| + |
| + @override |
| + @failingTest |
| + void test_conditionalExpression_precedence_nullableType_is() { |
| + // TODO(paulberry,ahe): Fasta doesn't support NNBD syntax yet. |
| + super.test_conditionalExpression_precedence_nullableType_is(); |
| + } |
| + |
| + @override |
| + @failingTest |
| + void test_equalityExpression_normal() { |
| + // TODO(paulberry,ahe): bad error recovery |
| + super.test_equalityExpression_normal(); |
| + } |
| + |
| + @override |
| + @failingTest |
| + void test_equalityExpression_super() { |
| + // TODO(paulberry,ahe): AstBuilder doesn't implement |
| + // handleSuperExpression(). |
| + super.test_equalityExpression_super(); |
| + } |
| + |
| + @override |
| + @failingTest |
| + void test_logicalAndExpression_precedence_nullableType() { |
| + // TODO(paulberry,ahe): Fasta doesn't support NNBD syntax yet. |
| + super.test_logicalAndExpression_precedence_nullableType(); |
| + } |
| + |
| + @override |
| + @failingTest |
| + void test_logicalOrExpression_precedence_nullableType() { |
| + // TODO(paulberry,ahe): Fasta doesn't support NNBD syntax yet. |
| + super.test_logicalOrExpression_precedence_nullableType(); |
| + } |
| + |
| + @override |
| + @failingTest |
| + void test_multiplicativeExpression_super() { |
| + // TODO(paulberry,ahe): AstBuilder doesn't implement |
| + // handleSuperExpression(). |
| + super.test_multiplicativeExpression_super(); |
| + } |
| + |
| + @override |
| + @failingTest |
| + void test_shiftExpression_super() { |
| + // TODO(paulberry,ahe): AstBuilder doesn't implement |
| + // handleSuperExpression(). |
| + super.test_shiftExpression_super(); |
| + } |
| + |
| + @override |
| + @failingTest |
| + void test_topLevelFunction_nestedGenericFunction() { |
| + // TODO(paulberry): Implement parseCompilationUnitWithOptions |
| + super.test_topLevelFunction_nestedGenericFunction(); |
| + } |
| +} |
| + |
| +/** |
| + * Proxy implementation of [KernelClassElement] used by Fasta parser tests. |
| + * |
| + * All undeclared identifiers are presumed to resolve to an instance of this |
| + * class. |
| + */ |
| +class ElementProxy implements KernelClassElement { |
| + @override |
| + final KernelInterfaceType rawType = new InterfaceTypeProxy(); |
| + |
| + noSuchMethod(Invocation invocation) => super.noSuchMethod(invocation); |
| +} |
| + |
| +/** |
| + * Proxy implementation of [KernelClassElement] used by Fasta parser tests. |
| + * |
| + * Any request for an element is satisfied by creating an instance of |
| + * [ElementProxy]. |
| + */ |
| +class ElementStoreProxy implements ElementStore { |
| + final _elements = <Builder, Element>{}; |
| + |
| + @override |
| + Element operator [](Builder builder) => |
| + _elements.putIfAbsent(builder, () => new ElementProxy()); |
| + |
| + noSuchMethod(Invocation invocation) => super.noSuchMethod(invocation); |
| +} |
| + |
| +/** |
| + * Implementation of [AbstractParserTestCase] specialized for testing the |
| + * Fasta parser. |
| + */ |
| +class FastaParserTestCase implements AbstractParserTestCase { |
| + @override |
| + set enableGenericMethodComments(bool value) { |
| + if (value == true) { |
| + // TODO(paulberry,ahe): generic method comment syntax is not supported by |
| + // Fasta. |
| + throw new UnimplementedError(); |
| + } |
| + } |
| + |
| + @override |
| + set enableNnbd(bool value) { |
| + if (value == true) { |
| + // TODO(paulberry,ahe): non-null-by-default syntax is not supported by |
| + // Fasta. |
| + throw new UnimplementedError(); |
| + } |
| + } |
| + |
| + @override |
| + CompilationUnit parseCompilationUnitWithOptions(String source, |
| + [List<ErrorCode> errorCodes = const <ErrorCode>[]]) { |
| + // TODO(paulberry): implement parseCompilationUnitWithOptions |
| + throw new UnimplementedError(); |
| + } |
| + |
| + @override |
| + Expression parseExpression(String source, |
| + [List<ErrorCode> errorCodes = const <ErrorCode>[]]) { |
| + var scanner = new StringScanner(source); |
| + var token = scanner.tokenize(); |
| + var library = new KernelLibraryBuilderProxy(); |
| + var member = new BuilderProxy(); |
| + var elementStore = new ElementStoreProxy(); |
| + var scope = new ScopeProxy(); |
| + var astBuilder = new AstBuilder(library, member, elementStore, scope); |
| + var parser = new Parser(astBuilder); |
| + var endToken = parser.parseExpression(token); |
| + expect(endToken.isEof, isTrue); |
| + expect(astBuilder.stack, hasLength(1)); |
| + var expression = astBuilder.pop() as Expression; |
| + return expression; |
| + } |
| +} |
| + |
| +/** |
| + * Proxy implementation of [KernelClassElement] used by Fasta parser tests. |
| + * |
| + * Any element used as a type name is presumed to refer to an instance of this |
| + * class. |
| + */ |
| +class InterfaceTypeProxy implements KernelInterfaceType { |
| + noSuchMethod(Invocation invocation) => super.noSuchMethod(invocation); |
| +} |
| + |
| +/** |
| + * Proxy implementation of [KernelLibraryBuilderProxy] used by Fasta parser |
| + * tests. |
| + */ |
| +class KernelLibraryBuilderProxy implements KernelLibraryBuilder { |
| + @override |
| + final uri = Uri.parse('file:///test.dart'); |
| + |
| + noSuchMethod(Invocation invocation) => super.noSuchMethod(invocation); |
| +} |
| + |
| +/** |
| + * Proxy implementation of [Scope] used by Fasta parser tests. |
| + * |
| + * Any name lookup request is satisfied by creating an instance of |
| + * [BuilderProxy]. |
| + */ |
| +class ScopeProxy implements Scope { |
| + final _locals = <String, Builder>{}; |
| + |
| + Builder lookup(String name) => |
| + _locals.putIfAbsent(name, () => new BuilderProxy()); |
| + |
| + noSuchMethod(Invocation invocation) => super.noSuchMethod(invocation); |
| +} |