Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(139)

Side by Side Diff: pkg/analyzer/test/src/summary/linker_test.dart

Issue 1981363002: In summary AST linker, fix top level isStatic getters. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « pkg/analyzer/lib/src/summary/link.dart ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2016, 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 import 'package:analyzer/dart/element/type.dart'; 5 import 'package:analyzer/dart/element/type.dart';
6 import 'package:analyzer/src/summary/format.dart'; 6 import 'package:analyzer/src/summary/format.dart';
7 import 'package:analyzer/src/summary/link.dart'; 7 import 'package:analyzer/src/summary/link.dart';
8 import 'package:unittest/unittest.dart'; 8 import 'package:unittest/unittest.dart';
9 9
10 import '../../reflective_tests.dart'; 10 import '../../reflective_tests.dart';
(...skipping 580 matching lines...) Expand 10 before | Expand all | Expand 10 after
591 ParameterElementForLink g = f.parameters[0]; 591 ParameterElementForLink g = f.parameters[0];
592 FunctionType gType = g.type; 592 FunctionType gType = g.type;
593 FunctionElementForLink_FunctionTypedParam gTypeElement = gType.element; 593 FunctionElementForLink_FunctionTypedParam gTypeElement = gType.element;
594 expect(gTypeElement.typeParameterContext, same(f)); 594 expect(gTypeElement.typeParameterContext, same(f));
595 ParameterElementForLink h = gTypeElement.parameters[0]; 595 ParameterElementForLink h = gTypeElement.parameters[0];
596 FunctionType hType = h.type; 596 FunctionType hType = h.type;
597 FunctionElementForLink_FunctionTypedParam hTypeElement = hType.element; 597 FunctionElementForLink_FunctionTypedParam hTypeElement = hType.element;
598 expect(hTypeElement.typeParameterContext, same(f)); 598 expect(hTypeElement.typeParameterContext, same(f));
599 } 599 }
600 600
601 void test_topLevelFunction_isStatic() {
602 createLinker('f() {}');
603 LibraryElementForLink library = linker.getLibrary(linkerInputs.testDartUri);
604 TopLevelFunctionElementForLink f = library.getContainedName('f');
605 expect(f.isStatic, true);
606 }
607
608 void test_topLevelGetter_isStatic() {
609 createLinker('get x => null;');
610 LibraryElementForLink library = linker.getLibrary(linkerInputs.testDartUri);
611 PropertyAccessorElementForLink_Executable x = library.getContainedName('x');
612 expect(x.isStatic, true);
613 }
614
615 void test_topLevelSetter_isStatic() {
616 createLinker('void set x(value) {}');
617 LibraryElementForLink library = linker.getLibrary(linkerInputs.testDartUri);
618 PropertyAccessorElementForLink_Executable x =
619 library.getContainedName('x=');
620 expect(x.isStatic, true);
621 }
622
623 void test_topLevelVariable_isStatic() {
624 createLinker('var x;');
625 LibraryElementForLink library = linker.getLibrary(linkerInputs.testDartUri);
626 PropertyAccessorElementForLink_Variable x = library.getContainedName('x');
627 expect(x.isStatic, true);
628 expect(x.variable.isStatic, true);
629 }
630
601 void test_typeParameter_isTypeParameterInScope_direct() { 631 void test_typeParameter_isTypeParameterInScope_direct() {
602 createLinker('class C<T, U> {}'); 632 createLinker('class C<T, U> {}');
603 ClassElementForLink_Class c = testLibrary.getContainedName('C'); 633 ClassElementForLink_Class c = testLibrary.getContainedName('C');
604 TypeParameterElementForLink t = c.typeParameters[0]; 634 TypeParameterElementForLink t = c.typeParameters[0];
605 TypeParameterElementForLink u = c.typeParameters[1]; 635 TypeParameterElementForLink u = c.typeParameters[1];
606 expect(c.isTypeParameterInScope(t), true); 636 expect(c.isTypeParameterInScope(t), true);
607 expect(c.isTypeParameterInScope(u), true); 637 expect(c.isTypeParameterInScope(u), true);
608 } 638 }
609 639
610 void test_typeParameter_isTypeParameterInScope_indirect() { 640 void test_typeParameter_isTypeParameterInScope_indirect() {
(...skipping 23 matching lines...) Expand all
634 TypeParameterElementForLink t = c.typeParameters[0]; 664 TypeParameterElementForLink t = c.typeParameters[0];
635 TypeParameterElementForLink u = c.typeParameters[1]; 665 TypeParameterElementForLink u = c.typeParameters[1];
636 TypeParameterElementForLink v = d.typeParameters[0]; 666 TypeParameterElementForLink v = d.typeParameters[0];
637 TypeParameterElementForLink w = d.typeParameters[1]; 667 TypeParameterElementForLink w = d.typeParameters[1];
638 expect(c.isTypeParameterInScope(v), false); 668 expect(c.isTypeParameterInScope(v), false);
639 expect(c.isTypeParameterInScope(w), false); 669 expect(c.isTypeParameterInScope(w), false);
640 expect(d.isTypeParameterInScope(t), false); 670 expect(d.isTypeParameterInScope(t), false);
641 expect(d.isTypeParameterInScope(u), false); 671 expect(d.isTypeParameterInScope(u), false);
642 } 672 }
643 } 673 }
OLDNEW
« no previous file with comments | « pkg/analyzer/lib/src/summary/link.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698