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 test.src.serialization.elements_test; | 5 library test.src.serialization.elements_test; |
6 | 6 |
7 import 'package:analyzer/dart/ast/ast.dart'; | 7 import 'package:analyzer/dart/ast/ast.dart'; |
8 import 'package:analyzer/dart/ast/standard_resolution_map.dart'; | 8 import 'package:analyzer/dart/ast/standard_resolution_map.dart'; |
9 import 'package:analyzer/dart/constant/value.dart'; | 9 import 'package:analyzer/dart/constant/value.dart'; |
10 import 'package:analyzer/dart/element/element.dart'; | 10 import 'package:analyzer/dart/element/element.dart'; |
(...skipping 8531 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
8542 checkElementText( | 8542 checkElementText( |
8543 library, | 8543 library, |
8544 r''' | 8544 r''' |
8545 class C<T, U> { | 8545 class C<T, U> { |
8546 static void m<V, W>(V v, W w) {} | 8546 static void m<V, W>(V v, W w) {} |
8547 } | 8547 } |
8548 '''); | 8548 '''); |
8549 } | 8549 } |
8550 } | 8550 } |
8551 | 8551 |
8552 test_genericFunction_asFunctionReturnType() { | |
8553 shouldCompareLibraryElements = false; | |
8554 var library = checkLibrary(r''' | |
8555 int Function(int a, String b) f() => null; | |
8556 '''); | |
8557 checkElementText( | |
8558 library, | |
8559 r''' | |
8560 (int, String) → int f() {} | |
8561 '''); | |
8562 } | |
8563 | |
8564 test_genericFunction_asFunctionTypedParameterReturnType() { | |
8565 shouldCompareLibraryElements = false; | |
8566 var library = checkLibrary(r''' | |
8567 void f(int Function(int a, String b) p(num c)) => null; | |
8568 '''); | |
8569 checkElementText( | |
8570 library, | |
8571 r''' | |
8572 void f((num) → (int, String) → int p) {} | |
8573 '''); | |
8574 } | |
8575 | |
8576 test_genericFunction_asGenericFunctionReturnType() { | |
8577 shouldCompareLibraryElements = false; | |
8578 var library = checkLibrary(r''' | |
8579 typedef F = void Function(String a) Function(int b); | |
8580 '''); | |
8581 checkElementText( | |
8582 library, | |
8583 r''' | |
8584 typedef F = (String) → void Function(int b); | |
8585 '''); | |
8586 } | |
8587 | |
8588 test_genericFunction_asMethodReturnType() { | |
8589 shouldCompareLibraryElements = false; | |
8590 var library = checkLibrary(r''' | |
8591 class C { | |
8592 int Function(int a, String b) m() => null; | |
8593 } | |
8594 '''); | |
8595 checkElementText( | |
8596 library, | |
8597 r''' | |
8598 class C { | |
8599 (int, String) → int m() {} | |
8600 } | |
8601 '''); | |
8602 } | |
8603 | |
8604 test_genericFunction_asParameterType() { | |
8605 shouldCompareLibraryElements = false; | |
8606 var library = checkLibrary(r''' | |
8607 void f(int Function(int a, String b) p) => null; | |
8608 '''); | |
8609 checkElementText( | |
8610 library, | |
8611 r''' | |
8612 void f((int, String) → int p) {} | |
8613 '''); | |
8614 } | |
8615 | |
8616 test_genericFunction_asTopLevelVariableType() { | |
8617 shouldCompareLibraryElements = false; | |
8618 var library = checkLibrary(r''' | |
8619 int Function(int a, String b) v; | |
8620 '''); | |
8621 checkElementText( | |
8622 library, | |
8623 r''' | |
8624 (int, String) → int v; | |
8625 '''); | |
8626 } | |
8627 | |
8628 test_getElement_constructor_named() { | 8552 test_getElement_constructor_named() { |
8629 String text = 'class C { C.named(); }'; | 8553 String text = 'class C { C.named(); }'; |
8630 Source source = addLibrarySource('/test.dart', text); | 8554 Source source = addLibrarySource('/test.dart', text); |
8631 ConstructorElement original = context | 8555 ConstructorElement original = context |
8632 .computeLibraryElement(source) | 8556 .computeLibraryElement(source) |
8633 .getType('C') | 8557 .getType('C') |
8634 .getNamedConstructor('named'); | 8558 .getNamedConstructor('named'); |
8635 expect(original, isNotNull); | 8559 expect(original, isNotNull); |
8636 ConstructorElement resynthesized = validateGetElement(text, original); | 8560 ConstructorElement resynthesized = validateGetElement(text, original); |
8637 compareConstructorElements(resynthesized, original, 'C.constructor named'); | 8561 compareConstructorElements(resynthesized, original, 'C.constructor named'); |
(...skipping 6630 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
15268 fail('Unexpectedly tried to get unlinked summary for $uri'); | 15192 fail('Unexpectedly tried to get unlinked summary for $uri'); |
15269 } | 15193 } |
15270 return serializedUnit; | 15194 return serializedUnit; |
15271 } | 15195 } |
15272 | 15196 |
15273 @override | 15197 @override |
15274 bool hasLibrarySummary(String uri) { | 15198 bool hasLibrarySummary(String uri) { |
15275 return true; | 15199 return true; |
15276 } | 15200 } |
15277 } | 15201 } |
OLD | NEW |