Chromium Code Reviews| 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 1580 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1591 import 'a.dart'; | 1591 import 'a.dart'; |
| 1592 const v = const C<int, String>.named(); | 1592 const v = const C<int, String>.named(); |
| 1593 '''); | 1593 '''); |
| 1594 _assertUnlinkedConst(variable.constExpr, operators: [ | 1594 _assertUnlinkedConst(variable.constExpr, operators: [ |
| 1595 UnlinkedConstOperation.invokeConstructor, | 1595 UnlinkedConstOperation.invokeConstructor, |
| 1596 ], ints: [ | 1596 ], ints: [ |
| 1597 0, | 1597 0, |
| 1598 0 | 1598 0 |
| 1599 ], referenceValidators: [ | 1599 ], referenceValidators: [ |
| 1600 (EntityRef r) { | 1600 (EntityRef r) { |
| 1601 checkTypeRef(r, absUri('/a.dart'), 'a.dart', 'named', | 1601 checkTypeRef(r, null, null, 'named', |
| 1602 expectedKind: ReferenceKind.constructor, | 1602 expectedKind: ReferenceKind.constructor, |
| 1603 prefixExpectations: [ | 1603 prefixExpectations: [ |
| 1604 new _PrefixExpectation(ReferenceKind.classOrEnum, 'C', | 1604 new _PrefixExpectation(ReferenceKind.classOrEnum, 'C', |
| 1605 absoluteUri: absUri('/a.dart'), | |
| 1606 relativeUri: 'a.dart', | |
| 1605 numTypeParameters: 2) | 1607 numTypeParameters: 2) |
| 1606 ], | 1608 ], |
| 1607 allowTypeParameters: true); | 1609 allowTypeParameters: true); |
| 1608 checkTypeRef(r.typeArguments[0], 'dart:core', 'dart:core', 'int'); | 1610 checkTypeRef(r.typeArguments[0], 'dart:core', 'dart:core', 'int'); |
| 1609 checkTypeRef(r.typeArguments[1], 'dart:core', 'dart:core', 'String'); | 1611 checkTypeRef(r.typeArguments[1], 'dart:core', 'dart:core', 'String'); |
| 1610 } | 1612 } |
| 1611 ]); | 1613 ]); |
| 1612 } | 1614 } |
| 1613 | 1615 |
| 1614 test_constExpr_invokeConstructor_generic_named_imported_withPrefix() { | 1616 test_constExpr_invokeConstructor_generic_named_imported_withPrefix() { |
| 1615 addNamedSource( | 1617 addNamedSource( |
| 1616 '/a.dart', | 1618 '/a.dart', |
| 1617 ''' | 1619 ''' |
| 1618 class C<K, V> { | 1620 class C<K, V> { |
| 1619 const C.named(); | 1621 const C.named(); |
| 1620 } | 1622 } |
| 1621 '''); | 1623 '''); |
| 1622 UnlinkedVariable variable = serializeVariableText(''' | 1624 UnlinkedVariable variable = serializeVariableText(''' |
| 1623 import 'a.dart' as p; | 1625 import 'a.dart' as p; |
| 1624 const v = const p.C<int, String>.named(); | 1626 const v = const p.C<int, String>.named(); |
| 1625 '''); | 1627 '''); |
| 1626 _assertUnlinkedConst(variable.constExpr, operators: [ | 1628 _assertUnlinkedConst(variable.constExpr, operators: [ |
| 1627 UnlinkedConstOperation.invokeConstructor, | 1629 UnlinkedConstOperation.invokeConstructor, |
| 1628 ], ints: [ | 1630 ], ints: [ |
| 1629 0, | 1631 0, |
| 1630 0 | 1632 0 |
| 1631 ], referenceValidators: [ | 1633 ], referenceValidators: [ |
| 1632 (EntityRef r) { | 1634 (EntityRef r) { |
| 1633 checkTypeRef(r, absUri('/a.dart'), 'a.dart', 'named', | 1635 checkTypeRef(r, null, null, 'named', |
| 1634 expectedKind: ReferenceKind.constructor, | 1636 expectedKind: ReferenceKind.constructor, |
| 1635 prefixExpectations: [ | 1637 prefixExpectations: [ |
| 1636 new _PrefixExpectation(ReferenceKind.classOrEnum, 'C', | 1638 new _PrefixExpectation(ReferenceKind.classOrEnum, 'C', |
| 1639 absoluteUri: absUri('/a.dart'), | |
| 1640 relativeUri: 'a.dart', | |
| 1637 numTypeParameters: 2), | 1641 numTypeParameters: 2), |
| 1638 new _PrefixExpectation(ReferenceKind.prefix, 'p', | 1642 new _PrefixExpectation(ReferenceKind.prefix, 'p', |
| 1639 inLibraryDefiningUnit: true) | 1643 inLibraryDefiningUnit: true) |
| 1640 ], | 1644 ], |
| 1641 allowTypeParameters: true); | 1645 allowTypeParameters: true); |
| 1642 checkTypeRef(r.typeArguments[0], 'dart:core', 'dart:core', 'int'); | 1646 checkTypeRef(r.typeArguments[0], 'dart:core', 'dart:core', 'int'); |
| 1643 checkTypeRef(r.typeArguments[1], 'dart:core', 'dart:core', 'String'); | 1647 checkTypeRef(r.typeArguments[1], 'dart:core', 'dart:core', 'String'); |
| 1644 } | 1648 } |
| 1645 ]); | 1649 ]); |
| 1646 } | 1650 } |
| (...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1763 UnlinkedVariable variable = serializeVariableText(''' | 1767 UnlinkedVariable variable = serializeVariableText(''' |
| 1764 import 'a.dart'; | 1768 import 'a.dart'; |
| 1765 const v = const C.named(); | 1769 const v = const C.named(); |
| 1766 '''); | 1770 '''); |
| 1767 _assertUnlinkedConst(variable.constExpr, operators: [ | 1771 _assertUnlinkedConst(variable.constExpr, operators: [ |
| 1768 UnlinkedConstOperation.invokeConstructor, | 1772 UnlinkedConstOperation.invokeConstructor, |
| 1769 ], ints: [ | 1773 ], ints: [ |
| 1770 0, | 1774 0, |
| 1771 0 | 1775 0 |
| 1772 ], referenceValidators: [ | 1776 ], referenceValidators: [ |
| 1773 (EntityRef r) => checkTypeRef(r, absUri('/a.dart'), 'a.dart', 'named', | 1777 (EntityRef r) => checkTypeRef(r, null, null, 'named', |
| 1774 expectedKind: ReferenceKind.constructor, | 1778 expectedKind: ReferenceKind.constructor, |
| 1775 prefixExpectations: [ | 1779 prefixExpectations: [ |
| 1776 new _PrefixExpectation(ReferenceKind.classOrEnum, 'C') | 1780 new _PrefixExpectation(ReferenceKind.classOrEnum, 'C', |
| 1781 absoluteUri: absUri('/a.dart'), relativeUri: 'a.dart') | |
| 1777 ]) | 1782 ]) |
| 1778 ]); | 1783 ]); |
| 1779 } | 1784 } |
| 1780 | 1785 |
| 1781 test_constExpr_invokeConstructor_named_imported_withPrefix() { | 1786 test_constExpr_invokeConstructor_named_imported_withPrefix() { |
| 1782 addNamedSource( | 1787 addNamedSource( |
| 1783 '/a.dart', | 1788 '/a.dart', |
| 1784 ''' | 1789 ''' |
| 1785 class C { | 1790 class C { |
| 1786 const C.named(); | 1791 const C.named(); |
| 1787 } | 1792 } |
| 1788 '''); | 1793 '''); |
| 1789 UnlinkedVariable variable = serializeVariableText(''' | 1794 UnlinkedVariable variable = serializeVariableText(''' |
| 1790 import 'a.dart' as p; | 1795 import 'a.dart' as p; |
| 1791 const v = const p.C.named(); | 1796 const v = const p.C.named(); |
| 1792 '''); | 1797 '''); |
| 1793 _assertUnlinkedConst(variable.constExpr, operators: [ | 1798 _assertUnlinkedConst(variable.constExpr, operators: [ |
| 1794 UnlinkedConstOperation.invokeConstructor, | 1799 UnlinkedConstOperation.invokeConstructor, |
| 1795 ], ints: [ | 1800 ], ints: [ |
| 1796 0, | 1801 0, |
| 1797 0 | 1802 0 |
| 1798 ], referenceValidators: [ | 1803 ], referenceValidators: [ |
| 1799 (EntityRef r) => checkTypeRef(r, absUri('/a.dart'), 'a.dart', 'named', | 1804 (EntityRef r) => checkTypeRef(r, null, null, 'named', |
| 1800 expectedKind: ReferenceKind.constructor, | 1805 expectedKind: ReferenceKind.constructor, |
| 1801 prefixExpectations: [ | 1806 prefixExpectations: [ |
| 1802 new _PrefixExpectation(ReferenceKind.classOrEnum, 'C'), | 1807 new _PrefixExpectation(ReferenceKind.classOrEnum, 'C', |
| 1808 absoluteUri: absUri('/a.dart'), relativeUri: 'a.dart'), | |
| 1803 new _PrefixExpectation(ReferenceKind.prefix, 'p', | 1809 new _PrefixExpectation(ReferenceKind.prefix, 'p', |
| 1804 inLibraryDefiningUnit: true) | 1810 inLibraryDefiningUnit: true) |
| 1805 ]) | 1811 ]) |
| 1806 ]); | 1812 ]); |
| 1807 } | 1813 } |
| 1808 | 1814 |
| 1809 test_constExpr_invokeConstructor_unnamed() { | 1815 test_constExpr_invokeConstructor_unnamed() { |
| 1810 UnlinkedVariable variable = serializeVariableText(''' | 1816 UnlinkedVariable variable = serializeVariableText(''' |
| 1811 class C { | 1817 class C { |
| 1812 const C(a, b, c, d, {e, f, g}); | 1818 const C(a, b, c, d, {e, f, g}); |
| (...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1923 static const int length = 0; | 1929 static const int length = 0; |
| 1924 } | 1930 } |
| 1925 '''); | 1931 '''); |
| 1926 UnlinkedVariable variable = serializeVariableText(''' | 1932 UnlinkedVariable variable = serializeVariableText(''' |
| 1927 import 'a.dart' as p; | 1933 import 'a.dart' as p; |
| 1928 const int v = p.C.length; | 1934 const int v = p.C.length; |
| 1929 '''); | 1935 '''); |
| 1930 _assertUnlinkedConst(variable.constExpr, operators: [ | 1936 _assertUnlinkedConst(variable.constExpr, operators: [ |
| 1931 UnlinkedConstOperation.pushReference | 1937 UnlinkedConstOperation.pushReference |
| 1932 ], referenceValidators: [ | 1938 ], referenceValidators: [ |
| 1933 (EntityRef r) => checkTypeRef(r, absUri('/a.dart'), 'a.dart', 'length', | 1939 (EntityRef r) => checkTypeRef(r, null, null, 'length', |
| 1934 expectedKind: ReferenceKind.propertyAccessor, | 1940 expectedKind: ReferenceKind.propertyAccessor, |
| 1935 prefixExpectations: [ | 1941 prefixExpectations: [ |
| 1936 new _PrefixExpectation(ReferenceKind.classOrEnum, 'C', | 1942 new _PrefixExpectation(ReferenceKind.classOrEnum, 'C', |
| 1937 absoluteUri: absUri('/a.dart'), relativeUri: 'a.dart'), | 1943 absoluteUri: absUri('/a.dart'), relativeUri: 'a.dart'), |
| 1938 new _PrefixExpectation(ReferenceKind.prefix, 'p', | 1944 new _PrefixExpectation(ReferenceKind.prefix, 'p', |
| 1939 inLibraryDefiningUnit: true) | 1945 inLibraryDefiningUnit: true) |
| 1940 ]) | 1946 ]) |
| 1941 ]); | 1947 ]); |
| 1942 } | 1948 } |
| 1943 | 1949 |
| (...skipping 409 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2353 static const int F = 1; | 2359 static const int F = 1; |
| 2354 } | 2360 } |
| 2355 '''); | 2361 '''); |
| 2356 UnlinkedVariable variable = serializeVariableText(''' | 2362 UnlinkedVariable variable = serializeVariableText(''' |
| 2357 import 'a.dart'; | 2363 import 'a.dart'; |
| 2358 const v = C.F; | 2364 const v = C.F; |
| 2359 '''); | 2365 '''); |
| 2360 _assertUnlinkedConst(variable.constExpr, operators: [ | 2366 _assertUnlinkedConst(variable.constExpr, operators: [ |
| 2361 UnlinkedConstOperation.pushReference | 2367 UnlinkedConstOperation.pushReference |
| 2362 ], referenceValidators: [ | 2368 ], referenceValidators: [ |
| 2363 (EntityRef r) => checkTypeRef(r, absUri('/a.dart'), 'a.dart', 'F', | 2369 (EntityRef r) => checkTypeRef(r, null, null, 'F', |
| 2364 expectedKind: ReferenceKind.propertyAccessor, | 2370 expectedKind: ReferenceKind.propertyAccessor, |
| 2365 prefixExpectations: [ | 2371 prefixExpectations: [ |
| 2366 new _PrefixExpectation(ReferenceKind.classOrEnum, 'C') | 2372 new _PrefixExpectation(ReferenceKind.classOrEnum, 'C', |
| 2373 absoluteUri: absUri('/a.dart'), relativeUri: 'a.dart') | |
| 2367 ]) | 2374 ]) |
| 2368 ]); | 2375 ]); |
| 2369 } | 2376 } |
| 2370 | 2377 |
| 2371 test_constExpr_pushReference_field_imported_withPrefix() { | 2378 test_constExpr_pushReference_field_imported_withPrefix() { |
| 2372 addNamedSource( | 2379 addNamedSource( |
| 2373 '/a.dart', | 2380 '/a.dart', |
| 2374 ''' | 2381 ''' |
| 2375 class C { | 2382 class C { |
| 2376 static const int F = 1; | 2383 static const int F = 1; |
| 2377 } | 2384 } |
| 2378 '''); | 2385 '''); |
| 2379 UnlinkedVariable variable = serializeVariableText(''' | 2386 UnlinkedVariable variable = serializeVariableText(''' |
| 2380 import 'a.dart' as p; | 2387 import 'a.dart' as p; |
| 2381 const v = p.C.F; | 2388 const v = p.C.F; |
| 2382 '''); | 2389 '''); |
| 2383 _assertUnlinkedConst(variable.constExpr, operators: [ | 2390 _assertUnlinkedConst(variable.constExpr, operators: [ |
| 2384 UnlinkedConstOperation.pushReference | 2391 UnlinkedConstOperation.pushReference |
| 2385 ], referenceValidators: [ | 2392 ], referenceValidators: [ |
| 2386 (EntityRef r) => checkTypeRef(r, absUri('/a.dart'), 'a.dart', 'F', | 2393 (EntityRef r) => checkTypeRef(r, null, null, 'F', |
| 2387 expectedKind: ReferenceKind.propertyAccessor, | 2394 expectedKind: ReferenceKind.propertyAccessor, |
| 2388 prefixExpectations: [ | 2395 prefixExpectations: [ |
| 2389 new _PrefixExpectation(ReferenceKind.classOrEnum, 'C'), | 2396 new _PrefixExpectation(ReferenceKind.classOrEnum, 'C', |
| 2397 absoluteUri: absUri('/a.dart'), relativeUri: 'a.dart'), | |
| 2390 new _PrefixExpectation(ReferenceKind.prefix, 'p', | 2398 new _PrefixExpectation(ReferenceKind.prefix, 'p', |
| 2391 inLibraryDefiningUnit: true), | 2399 inLibraryDefiningUnit: true), |
| 2392 ]) | 2400 ]) |
| 2393 ]); | 2401 ]); |
| 2394 } | 2402 } |
| 2395 | 2403 |
| 2396 test_constExpr_pushReference_staticMethod() { | 2404 test_constExpr_pushReference_staticMethod() { |
| 2397 UnlinkedVariable variable = serializeVariableText(''' | 2405 UnlinkedVariable variable = serializeVariableText(''' |
| 2398 class C { | 2406 class C { |
| 2399 static m() {} | 2407 static m() {} |
| (...skipping 19 matching lines...) Expand all Loading... | |
| 2419 static m() {} | 2427 static m() {} |
| 2420 } | 2428 } |
| 2421 '''); | 2429 '''); |
| 2422 UnlinkedVariable variable = serializeVariableText(''' | 2430 UnlinkedVariable variable = serializeVariableText(''' |
| 2423 import 'a.dart'; | 2431 import 'a.dart'; |
| 2424 const v = C.m; | 2432 const v = C.m; |
| 2425 '''); | 2433 '''); |
| 2426 _assertUnlinkedConst(variable.constExpr, operators: [ | 2434 _assertUnlinkedConst(variable.constExpr, operators: [ |
| 2427 UnlinkedConstOperation.pushReference | 2435 UnlinkedConstOperation.pushReference |
| 2428 ], referenceValidators: [ | 2436 ], referenceValidators: [ |
| 2429 (EntityRef r) => checkTypeRef(r, absUri('/a.dart'), 'a.dart', 'm', | 2437 (EntityRef r) => checkTypeRef(r, null, null, 'm', |
| 2430 expectedKind: ReferenceKind.method, | 2438 expectedKind: ReferenceKind.method, |
| 2431 prefixExpectations: [ | 2439 prefixExpectations: [ |
| 2432 new _PrefixExpectation(ReferenceKind.classOrEnum, 'C') | 2440 new _PrefixExpectation(ReferenceKind.classOrEnum, 'C', |
| 2441 absoluteUri: absUri('/a.dart'), relativeUri: 'a.dart') | |
| 2433 ]) | 2442 ]) |
| 2434 ]); | 2443 ]); |
| 2435 } | 2444 } |
| 2436 | 2445 |
| 2437 test_constExpr_pushReference_staticMethod_imported_withPrefix() { | 2446 test_constExpr_pushReference_staticMethod_imported_withPrefix() { |
| 2438 addNamedSource( | 2447 addNamedSource( |
| 2439 '/a.dart', | 2448 '/a.dart', |
| 2440 ''' | 2449 ''' |
| 2441 class C { | 2450 class C { |
| 2442 static m() {} | 2451 static m() {} |
| 2443 } | 2452 } |
| 2444 '''); | 2453 '''); |
| 2445 UnlinkedVariable variable = serializeVariableText(''' | 2454 UnlinkedVariable variable = serializeVariableText(''' |
| 2446 import 'a.dart' as p; | 2455 import 'a.dart' as p; |
| 2447 const v = p.C.m; | 2456 const v = p.C.m; |
| 2448 '''); | 2457 '''); |
| 2449 _assertUnlinkedConst(variable.constExpr, operators: [ | 2458 _assertUnlinkedConst(variable.constExpr, operators: [ |
| 2450 UnlinkedConstOperation.pushReference | 2459 UnlinkedConstOperation.pushReference |
| 2451 ], referenceValidators: [ | 2460 ], referenceValidators: [ |
| 2452 (EntityRef r) => checkTypeRef(r, absUri('/a.dart'), 'a.dart', 'm', | 2461 (EntityRef r) => checkTypeRef(r, null, null, 'm', |
| 2453 expectedKind: ReferenceKind.method, | 2462 expectedKind: ReferenceKind.method, |
| 2454 prefixExpectations: [ | 2463 prefixExpectations: [ |
| 2455 new _PrefixExpectation(ReferenceKind.classOrEnum, 'C'), | 2464 new _PrefixExpectation(ReferenceKind.classOrEnum, 'C', |
| 2465 absoluteUri: absUri('/a.dart'), relativeUri: 'a.dart'), | |
| 2456 new _PrefixExpectation(ReferenceKind.prefix, 'p', | 2466 new _PrefixExpectation(ReferenceKind.prefix, 'p', |
| 2457 inLibraryDefiningUnit: true) | 2467 inLibraryDefiningUnit: true) |
| 2458 ]) | 2468 ]) |
| 2459 ]); | 2469 ]); |
| 2460 } | 2470 } |
| 2461 | 2471 |
| 2462 test_constExpr_pushReference_topLevelFunction() { | 2472 test_constExpr_pushReference_topLevelFunction() { |
| 2463 UnlinkedVariable variable = serializeVariableText(''' | 2473 UnlinkedVariable variable = serializeVariableText(''' |
| 2464 f() {} | 2474 f() {} |
| 2465 const v = f; | 2475 const v = f; |
| (...skipping 1893 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 4359 getTypeRefForSlot(cls.executables[0].parameters[1].inferredTypeSlot); | 4369 getTypeRefForSlot(cls.executables[0].parameters[1].inferredTypeSlot); |
| 4360 // Check that parameter g's inferred type is the type implied by D.f's 1st | 4370 // Check that parameter g's inferred type is the type implied by D.f's 1st |
| 4361 // (zero-based) parameter. | 4371 // (zero-based) parameter. |
| 4362 expect(type.implicitFunctionTypeIndices, [1]); | 4372 expect(type.implicitFunctionTypeIndices, [1]); |
| 4363 expect(type.paramReference, 0); | 4373 expect(type.paramReference, 0); |
| 4364 expect(type.typeArguments, isEmpty); | 4374 expect(type.typeArguments, isEmpty); |
| 4365 expect(type.reference, | 4375 expect(type.reference, |
| 4366 greaterThanOrEqualTo(unlinkedUnits[0].references.length)); | 4376 greaterThanOrEqualTo(unlinkedUnits[0].references.length)); |
| 4367 LinkedReference linkedReference = | 4377 LinkedReference linkedReference = |
| 4368 linked.units[0].references[type.reference]; | 4378 linked.units[0].references[type.reference]; |
| 4369 int expectedDep = | 4379 expect(linkedReference.dependency, 0); |
| 4370 checkHasDependency(absUri('/b.dart'), 'b.dart', fullyLinked: true); | |
| 4371 expect(linkedReference.dependency, expectedDep); | |
| 4372 expect(linkedReference.kind, ReferenceKind.method); | 4380 expect(linkedReference.kind, ReferenceKind.method); |
| 4373 expect(linkedReference.name, 'f'); | 4381 expect(linkedReference.name, 'f'); |
| 4374 expect(linkedReference.numTypeParameters, 0); | 4382 expect(linkedReference.numTypeParameters, 0); |
| 4375 expect(linkedReference.unit, 0); | 4383 expect(linkedReference.unit, 0); |
| 4376 expect(linkedReference.containingReference, isNot(0)); | 4384 expect(linkedReference.containingReference, isNot(0)); |
| 4377 expect(linkedReference.containingReference, lessThan(type.reference)); | 4385 expect(linkedReference.containingReference, lessThan(type.reference)); |
| 4378 checkReferenceIndex( | 4386 checkReferenceIndex( |
| 4379 linkedReference.containingReference, absUri('/b.dart'), 'b.dart', 'E'); | 4387 linkedReference.containingReference, absUri('/b.dart'), 'b.dart', 'E'); |
| 4380 } | 4388 } |
| 4381 | 4389 |
| (...skipping 987 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 5369 serializeClassText('class C { static int i; }').fields[0]; | 5377 serializeClassText('class C { static int i; }').fields[0]; |
| 5370 expect(variable.isStatic, isTrue); | 5378 expect(variable.isStatic, isTrue); |
| 5371 } | 5379 } |
| 5372 | 5380 |
| 5373 test_variable_type() { | 5381 test_variable_type() { |
| 5374 UnlinkedVariable variable = | 5382 UnlinkedVariable variable = |
| 5375 serializeVariableText('int i;', variableName: 'i'); | 5383 serializeVariableText('int i;', variableName: 'i'); |
| 5376 checkTypeRef(variable.type, 'dart:core', 'dart:core', 'int'); | 5384 checkTypeRef(variable.type, 'dart:core', 'dart:core', 'int'); |
| 5377 } | 5385 } |
| 5378 | 5386 |
| 5387 /** | |
| 5388 * Verify invariants of the given [linkedLibrary]. | |
| 5389 */ | |
| 5390 void validateLinkedLibrary(LinkedLibrary linkedLibrary) { | |
| 5391 for (LinkedUnit unit in linkedLibrary.units) { | |
| 5392 for (LinkedReference reference in unit.references) { | |
| 5393 switch (reference.kind) { | |
| 5394 case ReferenceKind.classOrEnum: | |
| 5395 case ReferenceKind.typedef: | |
|
scheglov
2016/02/05 21:15:13
The list of case(s) is almost sorted.
Maybe worth
Paul Berry
2016/02/05 21:19:16
Done.
| |
| 5396 case ReferenceKind.topLevelPropertyAccessor: | |
| 5397 case ReferenceKind.topLevelFunction: | |
| 5398 // This reference can have either a zero or a nonzero dependency, | |
| 5399 // since it refers to top level element which might or might not be | |
| 5400 // imported from another library. | |
| 5401 break; | |
| 5402 case ReferenceKind.prefix: | |
| 5403 // Prefixes should have a dependency of 0, since they come from the | |
| 5404 // current library. | |
| 5405 expect(reference.dependency, 0, | |
| 5406 reason: 'Nonzero dependency for prefix'); | |
| 5407 break; | |
| 5408 case ReferenceKind.unresolved: | |
| 5409 // Unresolved references always have a dependency of 0. | |
| 5410 expect(reference.dependency, 0, | |
| 5411 reason: 'Nonzero dependency for undefined'); | |
| 5412 break; | |
| 5413 default: | |
| 5414 // This reference should have a dependency of 0, since it refers to | |
| 5415 // an element that is contained within some other element. | |
| 5416 expect(reference.dependency, 0, | |
| 5417 reason: 'Nonzero dependency for ${reference.kind}'); | |
| 5418 } | |
| 5419 } | |
| 5420 } | |
| 5421 } | |
| 5422 | |
| 5379 void _assertUnlinkedConst(UnlinkedConst constExpr, | 5423 void _assertUnlinkedConst(UnlinkedConst constExpr, |
| 5380 {List<UnlinkedConstOperation> operators, | 5424 {List<UnlinkedConstOperation> operators, |
| 5381 List<int> ints: const <int>[], | 5425 List<int> ints: const <int>[], |
| 5382 List<double> doubles: const <double>[], | 5426 List<double> doubles: const <double>[], |
| 5383 List<String> strings: const <String>[], | 5427 List<String> strings: const <String>[], |
| 5384 List<_EntityRefValidator> referenceValidators: | 5428 List<_EntityRefValidator> referenceValidators: |
| 5385 const <_EntityRefValidator>[]}) { | 5429 const <_EntityRefValidator>[]}) { |
| 5386 expect(constExpr, isNotNull); | 5430 expect(constExpr, isNotNull); |
| 5387 expect(constExpr.operations, operators); | 5431 expect(constExpr.operations, operators); |
| 5388 expect(constExpr.ints, ints); | 5432 expect(constExpr.ints, ints); |
| (...skipping 16 matching lines...) Expand all Loading... | |
| 5405 final String absoluteUri; | 5449 final String absoluteUri; |
| 5406 final String relativeUri; | 5450 final String relativeUri; |
| 5407 final int numTypeParameters; | 5451 final int numTypeParameters; |
| 5408 | 5452 |
| 5409 _PrefixExpectation(this.kind, this.name, | 5453 _PrefixExpectation(this.kind, this.name, |
| 5410 {this.inLibraryDefiningUnit: false, | 5454 {this.inLibraryDefiningUnit: false, |
| 5411 this.absoluteUri, | 5455 this.absoluteUri, |
| 5412 this.relativeUri, | 5456 this.relativeUri, |
| 5413 this.numTypeParameters: 0}); | 5457 this.numTypeParameters: 0}); |
| 5414 } | 5458 } |
| OLD | NEW |