OLD | NEW |
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 'dart:io'; | 5 import 'dart:io'; |
6 | 6 |
7 // By convention: | 7 // By convention: |
8 // | 8 // |
9 // T: generic type of typedef. | 9 // T: generic type of typedef. |
10 // A: generic type of returned function. | 10 // A: generic type of returned function. |
(...skipping 523 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
534 // GENERATED - DON'T EDIT. | 534 // GENERATED - DON'T EDIT. |
535 // GENERATED - DON'T EDIT. | 535 // GENERATED - DON'T EDIT. |
536 | 536 |
537 import 'dart:core'; | 537 import 'dart:core'; |
538 import 'dart:core' as core; | 538 import 'dart:core' as core; |
539 import 'package:expect/expect.dart'; | 539 import 'package:expect/expect.dart'; |
540 | 540 |
541 @NoInline() | 541 @NoInline() |
542 @AssumeDynamic() | 542 @AssumeDynamic() |
543 confuse(f) => f; | 543 confuse(f) => f; |
544 | |
545 final bool inCheckedMode = | |
546 (() { bool result = false; assert(result = true); return result; })(); | |
547 """; | 544 """; |
548 | 545 |
549 class Unit { | 546 class Unit { |
550 int typeCounter = 0; | 547 int typeCounter = 0; |
551 final String name; | 548 final String name; |
552 final StringBuffer typedefs = new StringBuffer(); | 549 final StringBuffer typedefs = new StringBuffer(); |
553 final StringBuffer globals = new StringBuffer(); | 550 final StringBuffer globals = new StringBuffer(); |
554 final StringBuffer tests = new StringBuffer(); | 551 final StringBuffer tests = new StringBuffer(); |
555 final StringBuffer fields = new StringBuffer(); | 552 final StringBuffer fields = new StringBuffer(); |
556 final StringBuffer statics = new StringBuffer(); | 553 final StringBuffer statics = new StringBuffer(); |
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
635 // } | 632 // } |
636 final TYPEDEF_T_TESTS_TEMPLATE = """ | 633 final TYPEDEF_T_TESTS_TEMPLATE = """ |
637 if (!tIsBool) { | 634 if (!tIsBool) { |
638 Expect.isTrue(#staticFunName is #typeName<int>); | 635 Expect.isTrue(#staticFunName is #typeName<int>); |
639 Expect.isFalse(#staticFunName is #typeName<bool>); | 636 Expect.isFalse(#staticFunName is #typeName<bool>); |
640 Expect.isTrue(confuse(#staticFunName) is #typeName<int>); | 637 Expect.isTrue(confuse(#staticFunName) is #typeName<int>); |
641 Expect.isFalse(confuse(#staticFunName) is #typeName<bool>); | 638 Expect.isFalse(confuse(#staticFunName) is #typeName<bool>); |
642 Expect.equals(tIsDynamic, #methodFunName is #typeName<bool>); | 639 Expect.equals(tIsDynamic, #methodFunName is #typeName<bool>); |
643 Expect.equals(tIsDynamic, confuse(#methodFunName) is #typeName<bool>); | 640 Expect.equals(tIsDynamic, confuse(#methodFunName) is #typeName<bool>); |
644 } else { | 641 } else { |
645 if (inCheckedMode) { | 642 if (typeAssertionsEnabled) { |
646 Expect.throws(() { #fieldName = (#staticFunName as dynamic); }); | 643 Expect.throws(() { #fieldName = (#staticFunName as dynamic); }); |
647 Expect.throws(() { #fieldName = confuse(#staticFunName); }); | 644 Expect.throws(() { #fieldName = confuse(#staticFunName); }); |
648 #typeCode #localName; | 645 #typeCode #localName; |
649 Expect.throws(() { #localName = (#staticFunName as dynamic); }); | 646 Expect.throws(() { #localName = (#staticFunName as dynamic); }); |
650 Expect.throws(() { #localName = confuse(#staticFunName); }); | 647 Expect.throws(() { #localName = confuse(#staticFunName); }); |
651 } | 648 } |
652 #typeCode #localName = #methodFunName; | 649 #typeCode #localName = #methodFunName; |
653 // In checked mode, verifies the type. | 650 // In checked mode, verifies the type. |
654 #fieldName = #methodFunName; | 651 #fieldName = #methodFunName; |
655 #fieldName = confuse(#methodFunName); | 652 #fieldName = confuse(#methodFunName); |
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
760 """); | 757 """); |
761 } | 758 } |
762 | 759 |
763 void main(List<String> arguments) { | 760 void main(List<String> arguments) { |
764 if (arguments.length != 0) { | 761 if (arguments.length != 0) { |
765 printUsage(); | 762 printUsage(); |
766 return; | 763 return; |
767 } | 764 } |
768 generateTests(); | 765 generateTests(); |
769 } | 766 } |
OLD | NEW |