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

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

Issue 1994673003: Fix generation of variable initializer synthetic functions in summary AST linker. (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/dart/element/element.dart'; 6 import 'package:analyzer/src/dart/element/element.dart';
7 import 'package:analyzer/src/summary/format.dart'; 7 import 'package:analyzer/src/summary/format.dart';
8 import 'package:analyzer/src/summary/link.dart'; 8 import 'package:analyzer/src/summary/link.dart';
9 import 'package:unittest/unittest.dart'; 9 import 'package:unittest/unittest.dart';
10 10
(...skipping 705 matching lines...) Expand 10 before | Expand all | Expand 10 after
716 ClassElementForLink_Class d = testLibrary.getContainedName('D'); 716 ClassElementForLink_Class d = testLibrary.getContainedName('D');
717 TypeParameterElementImpl t = c.typeParameters[0]; 717 TypeParameterElementImpl t = c.typeParameters[0];
718 TypeParameterElementImpl u = c.typeParameters[1]; 718 TypeParameterElementImpl u = c.typeParameters[1];
719 TypeParameterElementImpl v = d.typeParameters[0]; 719 TypeParameterElementImpl v = d.typeParameters[0];
720 TypeParameterElementImpl w = d.typeParameters[1]; 720 TypeParameterElementImpl w = d.typeParameters[1];
721 expect(c.isTypeParameterInScope(v), false); 721 expect(c.isTypeParameterInScope(v), false);
722 expect(c.isTypeParameterInScope(w), false); 722 expect(c.isTypeParameterInScope(w), false);
723 expect(d.isTypeParameterInScope(t), false); 723 expect(d.isTypeParameterInScope(t), false);
724 expect(d.isTypeParameterInScope(u), false); 724 expect(d.isTypeParameterInScope(u), false);
725 } 725 }
726
727 void test_variable_initializer_presence() {
728 // Any variable declaration with an initializer should have a non-null value
729 // for `initializer`, regardless of whether it is constant and regardless of
730 // whether it has an explicit type.
731 createLinker('''
732 const int c = 0;
733 int i = 0;
734 int j;
735 var v = 0;
736 ''');
737 LibraryElementForLink library = linker.getLibrary(linkerInputs.testDartUri);
738 PropertyAccessorElementForLink_Variable c = library.getContainedName('c');
739 expect(c.variable.initializer, isNotNull);
740 PropertyAccessorElementForLink_Variable i = library.getContainedName('i');
741 expect(i.variable.initializer, isNotNull);
742 PropertyAccessorElementForLink_Variable j = library.getContainedName('j');
743 expect(j.variable.initializer, isNull);
744 PropertyAccessorElementForLink_Variable v = library.getContainedName('v');
745 expect(v.variable.initializer, isNotNull);
746 }
726 } 747 }
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