| OLD | NEW |
| 1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2015, 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 library analyzer.test.src.summary.summary_common; | 5 library analyzer.test.src.summary.summary_common; |
| 6 | 6 |
| 7 import 'package:analyzer/analyzer.dart'; | 7 import 'package:analyzer/analyzer.dart'; |
| 8 import 'package:analyzer/dart/ast/ast.dart'; | 8 import 'package:analyzer/dart/ast/ast.dart'; |
| 9 import 'package:analyzer/dart/element/element.dart'; | 9 import 'package:analyzer/dart/element/element.dart'; |
| 10 import 'package:analyzer/src/generated/engine.dart'; | 10 import 'package:analyzer/src/generated/engine.dart'; |
| (...skipping 528 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 539 {LinkedUnit linkedSourceUnit, UnlinkedUnit unlinkedSourceUnit}) { | 539 {LinkedUnit linkedSourceUnit, UnlinkedUnit unlinkedSourceUnit}) { |
| 540 // When serializing from the element model, unresolved type refs lose their | 540 // When serializing from the element model, unresolved type refs lose their |
| 541 // name. | 541 // name. |
| 542 checkTypeRef(typeRef, null, null, checkAstDerivedData ? expectedName : null, | 542 checkTypeRef(typeRef, null, null, checkAstDerivedData ? expectedName : null, |
| 543 expectedPrefix: expectedPrefix, | 543 expectedPrefix: expectedPrefix, |
| 544 expectedKind: ReferenceKind.unresolved, | 544 expectedKind: ReferenceKind.unresolved, |
| 545 linkedSourceUnit: linkedSourceUnit, | 545 linkedSourceUnit: linkedSourceUnit, |
| 546 unlinkedSourceUnit: unlinkedSourceUnit); | 546 unlinkedSourceUnit: unlinkedSourceUnit); |
| 547 } | 547 } |
| 548 | 548 |
| 549 /** |
| 550 * Verify that the given [typeRef] represents the type `void`. |
| 551 */ |
| 552 void checkVoidTypeRef(EntityRef typeRef) { |
| 553 checkTypeRef(typeRef, null, null, 'void'); |
| 554 } |
| 555 |
| 549 fail_enum_value_documented() { | 556 fail_enum_value_documented() { |
| 550 // TODO(paulberry): currently broken because of dartbug.com/25385 | 557 // TODO(paulberry): currently broken because of dartbug.com/25385 |
| 551 String text = ''' | 558 String text = ''' |
| 552 enum E { | 559 enum E { |
| 553 /** | 560 /** |
| 554 * Docs | 561 * Docs |
| 555 */ | 562 */ |
| 556 v | 563 v |
| 557 }'''; | 564 }'''; |
| 558 UnlinkedEnumValue value = serializeEnumText(text).values[0]; | 565 UnlinkedEnumValue value = serializeEnumText(text).values[0]; |
| (...skipping 2037 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2596 'class C { void operator[]=(int i, bool v) => null; }') | 2603 'class C { void operator[]=(int i, bool v) => null; }') |
| 2597 .executables[0]; | 2604 .executables[0]; |
| 2598 expect(executable.kind, UnlinkedExecutableKind.functionOrMethod); | 2605 expect(executable.kind, UnlinkedExecutableKind.functionOrMethod); |
| 2599 expect(executable.name, '[]='); | 2606 expect(executable.name, '[]='); |
| 2600 expect(executable.hasImplicitReturnType, false); | 2607 expect(executable.hasImplicitReturnType, false); |
| 2601 expect(executable.isAbstract, false); | 2608 expect(executable.isAbstract, false); |
| 2602 expect(executable.isConst, false); | 2609 expect(executable.isConst, false); |
| 2603 expect(executable.isFactory, false); | 2610 expect(executable.isFactory, false); |
| 2604 expect(executable.isStatic, false); | 2611 expect(executable.isStatic, false); |
| 2605 expect(executable.parameters, hasLength(2)); | 2612 expect(executable.parameters, hasLength(2)); |
| 2606 expect(executable.returnType, isNull); | 2613 checkVoidTypeRef(executable.returnType); |
| 2607 expect(executable.typeParameters, isEmpty); | 2614 expect(executable.typeParameters, isEmpty); |
| 2608 } | 2615 } |
| 2609 | 2616 |
| 2610 test_executable_operator_less_equal() { | 2617 test_executable_operator_less_equal() { |
| 2611 UnlinkedExecutable executable = | 2618 UnlinkedExecutable executable = |
| 2612 serializeClassText('class C { bool operator<=(C other) => false; }') | 2619 serializeClassText('class C { bool operator<=(C other) => false; }') |
| 2613 .executables[0]; | 2620 .executables[0]; |
| 2614 expect(executable.name, '<='); | 2621 expect(executable.name, '<='); |
| 2615 } | 2622 } |
| 2616 | 2623 |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2652 executable.parameters[0].type, 'dart:core', 'dart:core', 'int'); | 2659 executable.parameters[0].type, 'dart:core', 'dart:core', 'int'); |
| 2653 } | 2660 } |
| 2654 | 2661 |
| 2655 test_executable_param_function_typed_return_type_implicit() { | 2662 test_executable_param_function_typed_return_type_implicit() { |
| 2656 UnlinkedExecutable executable = serializeExecutableText('f(g()) {}'); | 2663 UnlinkedExecutable executable = serializeExecutableText('f(g()) {}'); |
| 2657 checkDynamicTypeRef(executable.parameters[0].type); | 2664 checkDynamicTypeRef(executable.parameters[0].type); |
| 2658 } | 2665 } |
| 2659 | 2666 |
| 2660 test_executable_param_function_typed_return_type_void() { | 2667 test_executable_param_function_typed_return_type_void() { |
| 2661 UnlinkedExecutable executable = serializeExecutableText('f(void g()) {}'); | 2668 UnlinkedExecutable executable = serializeExecutableText('f(void g()) {}'); |
| 2662 expect(executable.parameters[0].type, isNull); | 2669 checkVoidTypeRef(executable.parameters[0].type); |
| 2663 } | 2670 } |
| 2664 | 2671 |
| 2665 test_executable_param_kind_named() { | 2672 test_executable_param_kind_named() { |
| 2666 UnlinkedExecutable executable = serializeExecutableText('f({x}) {}'); | 2673 UnlinkedExecutable executable = serializeExecutableText('f({x}) {}'); |
| 2667 expect(executable.parameters[0].kind, UnlinkedParamKind.named); | 2674 expect(executable.parameters[0].kind, UnlinkedParamKind.named); |
| 2668 } | 2675 } |
| 2669 | 2676 |
| 2670 test_executable_param_kind_positional() { | 2677 test_executable_param_kind_positional() { |
| 2671 UnlinkedExecutable executable = serializeExecutableText('f([x]) {}'); | 2678 UnlinkedExecutable executable = serializeExecutableText('f([x]) {}'); |
| 2672 expect(executable.parameters[0].kind, UnlinkedParamKind.positional); | 2679 expect(executable.parameters[0].kind, UnlinkedParamKind.positional); |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2727 } | 2734 } |
| 2728 | 2735 |
| 2729 test_executable_return_type_implicit() { | 2736 test_executable_return_type_implicit() { |
| 2730 UnlinkedExecutable executable = serializeExecutableText('f() {}'); | 2737 UnlinkedExecutable executable = serializeExecutableText('f() {}'); |
| 2731 checkDynamicTypeRef(executable.returnType); | 2738 checkDynamicTypeRef(executable.returnType); |
| 2732 expect(executable.hasImplicitReturnType, isTrue); | 2739 expect(executable.hasImplicitReturnType, isTrue); |
| 2733 } | 2740 } |
| 2734 | 2741 |
| 2735 test_executable_return_type_void() { | 2742 test_executable_return_type_void() { |
| 2736 UnlinkedExecutable executable = serializeExecutableText('void f() {}'); | 2743 UnlinkedExecutable executable = serializeExecutableText('void f() {}'); |
| 2737 expect(executable.returnType, isNull); | 2744 checkVoidTypeRef(executable.returnType); |
| 2738 } | 2745 } |
| 2739 | 2746 |
| 2740 test_executable_setter() { | 2747 test_executable_setter() { |
| 2741 String text = 'void set f(value) {}'; | 2748 String text = 'void set f(value) {}'; |
| 2742 UnlinkedExecutable executable = serializeExecutableText(text, 'f='); | 2749 UnlinkedExecutable executable = serializeExecutableText(text, 'f='); |
| 2743 expect(executable.kind, UnlinkedExecutableKind.setter); | 2750 expect(executable.kind, UnlinkedExecutableKind.setter); |
| 2744 expect(executable.hasImplicitReturnType, isFalse); | 2751 expect(executable.hasImplicitReturnType, isFalse); |
| 2745 expect(executable.isExternal, isFalse); | 2752 expect(executable.isExternal, isFalse); |
| 2746 expect(executable.nameOffset, text.indexOf('f')); | 2753 expect(executable.nameOffset, text.indexOf('f')); |
| 2747 expect(findVariable('f'), isNull); | 2754 expect(findVariable('f'), isNull); |
| (...skipping 18 matching lines...) Expand all Loading... |
| 2766 } | 2773 } |
| 2767 | 2774 |
| 2768 test_executable_setter_private() { | 2775 test_executable_setter_private() { |
| 2769 serializeExecutableText('void set _f(value) {}', '_f='); | 2776 serializeExecutableText('void set _f(value) {}', '_f='); |
| 2770 expect(unlinkedUnits[0].publicNamespace.names, isEmpty); | 2777 expect(unlinkedUnits[0].publicNamespace.names, isEmpty); |
| 2771 } | 2778 } |
| 2772 | 2779 |
| 2773 test_executable_setter_type() { | 2780 test_executable_setter_type() { |
| 2774 UnlinkedExecutable executable = | 2781 UnlinkedExecutable executable = |
| 2775 serializeExecutableText('void set f(int value) {}', 'f='); | 2782 serializeExecutableText('void set f(int value) {}', 'f='); |
| 2776 expect(executable.returnType, isNull); | 2783 checkVoidTypeRef(executable.returnType); |
| 2777 expect(executable.parameters, hasLength(1)); | 2784 expect(executable.parameters, hasLength(1)); |
| 2778 expect(executable.parameters[0].name, 'value'); | 2785 expect(executable.parameters[0].name, 'value'); |
| 2779 checkTypeRef( | 2786 checkTypeRef( |
| 2780 executable.parameters[0].type, 'dart:core', 'dart:core', 'int'); | 2787 executable.parameters[0].type, 'dart:core', 'dart:core', 'int'); |
| 2781 } | 2788 } |
| 2782 | 2789 |
| 2783 test_executable_static() { | 2790 test_executable_static() { |
| 2784 UnlinkedExecutable executable = | 2791 UnlinkedExecutable executable = |
| 2785 serializeClassText('class C { static f() {} }').executables[0]; | 2792 serializeClassText('class C { static f() {} }').executables[0]; |
| 2786 expect(executable.isStatic, isTrue); | 2793 expect(executable.isStatic, isTrue); |
| (...skipping 1433 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4220 expect(constExpr.operations, operators); | 4227 expect(constExpr.operations, operators); |
| 4221 expect(constExpr.ints, ints); | 4228 expect(constExpr.ints, ints); |
| 4222 expect(constExpr.doubles, doubles); | 4229 expect(constExpr.doubles, doubles); |
| 4223 expect(constExpr.strings, strings); | 4230 expect(constExpr.strings, strings); |
| 4224 expect(constExpr.references, hasLength(referenceValidators.length)); | 4231 expect(constExpr.references, hasLength(referenceValidators.length)); |
| 4225 for (int i = 0; i < referenceValidators.length; i++) { | 4232 for (int i = 0; i < referenceValidators.length; i++) { |
| 4226 referenceValidators[i](constExpr.references[i]); | 4233 referenceValidators[i](constExpr.references[i]); |
| 4227 } | 4234 } |
| 4228 } | 4235 } |
| 4229 } | 4236 } |
| OLD | NEW |