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

Side by Side Diff: test/checker/checker_test.dart

Issue 1317933005: Some preliminary support for quasi-generics (Closed) Base URL: https://github.com/dart-lang/dev_compiler.git@master
Patch Set: Regen runtime files Created 5 years, 3 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 | « lib/src/dart_sdk.dart ('k') | test/checker/inferred_type_test.dart » ('j') | 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) 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 /// General type checking tests 5 /// General type checking tests
6 library dev_compiler.test.checker_test; 6 library dev_compiler.test.checker_test;
7 7
8 import 'package:test/test.dart'; 8 import 'package:test/test.dart';
9 9
10 import '../testing.dart'; 10 import '../testing.dart';
(...skipping 2617 matching lines...) Expand 10 before | Expand all | Expand 10 after
2628 Iterable<int> bar3() sync* { yield (/*info:DynamicCast*/x); } 2628 Iterable<int> bar3() sync* { yield (/*info:DynamicCast*/x); }
2629 Iterable<int> bar4() sync* { yield (/*severe:StaticTypeError*/new Iterab le<int>()); } 2629 Iterable<int> bar4() sync* { yield (/*severe:StaticTypeError*/new Iterab le<int>()); }
2630 2630
2631 baz1() sync* { yield* (/*info:DynamicCast*/x); } 2631 baz1() sync* { yield* (/*info:DynamicCast*/x); }
2632 Iterable baz2() sync* { yield* (/*info:DynamicCast*/x); } 2632 Iterable baz2() sync* { yield* (/*info:DynamicCast*/x); }
2633 Iterable<int> baz3() sync* { yield* (/*warning:DownCastComposite*/x); } 2633 Iterable<int> baz3() sync* { yield* (/*warning:DownCastComposite*/x); }
2634 Iterable<int> baz4() sync* { yield* new Iterable<int>(); } 2634 Iterable<int> baz4() sync* { yield* new Iterable<int>(); }
2635 Iterable<int> baz5() sync* { yield* (/*info:InferredTypeAllocation*/new Iterable()); } 2635 Iterable<int> baz5() sync* { yield* (/*info:InferredTypeAllocation*/new Iterable()); }
2636 ''' 2636 '''
2637 }); 2637 });
2638
2639 testChecker('dart:math min/max', {
2640 '/main.dart': '''
2641 import 'dart:math';
2642
2643 void printInt(int x) => print(x);
2644 void printDouble(double x) => print(x);
2645
2646 num myMax(num x, num y) => max(x, y);
2647
2648 main() {
2649 // Okay if static types match.
2650 printInt(max(1, 2));
2651 printInt(min(1, 2));
2652 printDouble(max(1.0, 2.0));
2653 printDouble(min(1.0, 2.0));
2654
2655 // No help for user-defined functions from num->num->num.
2656 printInt(/*info:DownCastImplicit*/myMax(1, 2));
2657 printInt(myMax(1, 2) as int);
2658
2659 // Mixing int and double means return type is num.
2660 printInt(/*info:DownCastImplicit*/max(1, 2.0));
2661 printInt(/*info:DownCastImplicit*/min(1, 2.0));
2662 printDouble(/*info:DownCastImplicit*/max(1, 2.0));
2663 printDouble(/*info:DownCastImplicit*/min(1, 2.0));
2664
2665 // Types other than int and double are not accepted.
2666 printInt(
2667 /*info:DownCastImplicit*/min(
2668 /*severe:StaticTypeError*/"hi",
2669 /*severe:StaticTypeError*/"there"));
2670 }
2671 '''
2672 });
2673 }); 2638 });
2674 } 2639 }
OLDNEW
« no previous file with comments | « lib/src/dart_sdk.dart ('k') | test/checker/inferred_type_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698