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

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

Issue 1526243002: Introduce code to resynthesize element models from summaries. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 5 years 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
OLDNEW
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_test; 5 library analyzer.test.src.summary.summary_test;
6 6
7 import 'package:analyzer/dart/element/element.dart'; 7 import 'package:analyzer/dart/element/element.dart';
8 import 'package:analyzer/src/generated/engine.dart'; 8 import 'package:analyzer/src/generated/engine.dart';
9 import 'package:analyzer/src/generated/java_engine_io.dart'; 9 import 'package:analyzer/src/generated/java_engine_io.dart';
10 import 'package:analyzer/src/generated/source.dart'; 10 import 'package:analyzer/src/generated/source.dart';
(...skipping 1419 matching lines...) Expand 10 before | Expand all | Expand 10 after
1430 addNamedSource('/a.dart', 'library my.lib;'); 1430 addNamedSource('/a.dart', 'library my.lib;');
1431 String uriString = '"a.dart"'; 1431 String uriString = '"a.dart"';
1432 String libraryText = 'export $uriString;'; 1432 String libraryText = 'export $uriString;';
1433 serializeLibraryText(libraryText); 1433 serializeLibraryText(libraryText);
1434 expect(definingUnit.unlinked.exports, hasLength(1)); 1434 expect(definingUnit.unlinked.exports, hasLength(1));
1435 expect(definingUnit.unlinked.exports[0].uri, 'a.dart'); 1435 expect(definingUnit.unlinked.exports[0].uri, 'a.dart');
1436 } 1436 }
1437 1437
1438 test_field() { 1438 test_field() {
1439 UnlinkedClass cls = serializeClassText('class C { int i; }'); 1439 UnlinkedClass cls = serializeClassText('class C { int i; }');
1440 expect(findVariable('i', variables: cls.fields), isNotNull); 1440 UnlinkedVariable variable = findVariable('i', variables: cls.fields);
1441 expect(variable, isNotNull);
1442 expect(variable.isConst, isFalse);
1443 expect(variable.isStatic, isFalse);
1444 expect(variable.isFinal, isFalse);
1441 expect(findExecutable('i', executables: cls.executables), isNull); 1445 expect(findExecutable('i', executables: cls.executables), isNull);
1442 expect(findExecutable('i=', executables: cls.executables), isNull); 1446 expect(findExecutable('i=', executables: cls.executables), isNull);
1443 } 1447 }
1444 1448
1449 test_field_const() {
1450 UnlinkedVariable variable =
1451 serializeClassText('class C { static const int i = 0; }').fields[0];
1452 expect(variable.isConst, isTrue);
1453 }
1454
1445 test_field_final() { 1455 test_field_final() {
1446 UnlinkedVariable variable = 1456 UnlinkedVariable variable =
1447 serializeClassText('class C { final int i = 0; }').fields[0]; 1457 serializeClassText('class C { final int i = 0; }').fields[0];
1448 expect(variable.isFinal, isTrue); 1458 expect(variable.isFinal, isTrue);
1449 } 1459 }
1450 1460
1451 test_field_non_final() { 1461 test_field_static() {
1452 UnlinkedVariable variable = 1462 UnlinkedVariable variable =
1453 serializeClassText('class C { int i; }').fields[0]; 1463 serializeClassText('class C { static int i; }').fields[0];
1454 expect(variable.isFinal, isFalse); 1464 expect(variable.isStatic, isTrue);
1455 } 1465 }
1456 1466
1457 test_generic_method_in_generic_class() { 1467 test_generic_method_in_generic_class() {
1458 UnlinkedClass cls = serializeClassText( 1468 UnlinkedClass cls = serializeClassText(
1459 'class C<T, U> { void m<V, W>(T t, U u, V v, W w) {} }'); 1469 'class C<T, U> { void m<V, W>(T t, U u, V v, W w) {} }');
1460 List<UnlinkedParam> params = cls.executables[0].parameters; 1470 List<UnlinkedParam> params = cls.executables[0].parameters;
1461 checkParamTypeRef(params[0].type, 4); 1471 checkParamTypeRef(params[0].type, 4);
1462 checkParamTypeRef(params[1].type, 3); 1472 checkParamTypeRef(params[1].type, 3);
1463 checkParamTypeRef(params[2].type, 2); 1473 checkParamTypeRef(params[2].type, 2);
1464 checkParamTypeRef(params[3].type, 1); 1474 checkParamTypeRef(params[3].type, 1);
(...skipping 512 matching lines...) Expand 10 before | Expand all | Expand 10 after
1977 serializeClassText('class C { static int i; }').fields[0]; 1987 serializeClassText('class C { static int i; }').fields[0];
1978 expect(variable.isStatic, isTrue); 1988 expect(variable.isStatic, isTrue);
1979 } 1989 }
1980 1990
1981 test_variable_type() { 1991 test_variable_type() {
1982 UnlinkedVariable variable = 1992 UnlinkedVariable variable =
1983 serializeVariableText('int i;', variableName: 'i'); 1993 serializeVariableText('int i;', variableName: 'i');
1984 checkTypeRef(variable.type, 'dart:core', 'dart:core', 'int'); 1994 checkTypeRef(variable.type, 'dart:core', 'dart:core', 'int');
1985 } 1995 }
1986 } 1996 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698