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

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

Issue 1021273004: Allow arity checks on dynamic function types (Closed) Base URL: https://github.com/dart-lang/dev_compiler.git@master
Patch Set: Address jacobr's comments Created 5 years, 9 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/checker/rules.dart ('k') | test/dart_codegen/expect/async/async_error.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:unittest/unittest.dart'; 8 import 'package:unittest/unittest.dart';
9 9
10 import 'package:dev_compiler/src/testing.dart'; 10 import 'package:dev_compiler/src/testing.dart';
(...skipping 2735 matching lines...) Expand 10 before | Expand all | Expand 10 after
2746 testChecker({ 2746 testChecker({
2747 '/main.dart': ''' 2747 '/main.dart': '''
2748 class A {} 2748 class A {}
2749 class T1 implements A { 2749 class T1 implements A {
2750 /*severe:InferableOverride*/toString() {} 2750 /*severe:InferableOverride*/toString() {}
2751 } 2751 }
2752 ''' 2752 '''
2753 }, inferFromOverrides: false); 2753 }, inferFromOverrides: false);
2754 }); 2754 });
2755 }); 2755 });
2756
2757 test('invalid runtime checks', () {
2758 testChecker({
2759 '/main.dart': '''
2760 typedef int I2I(int x);
2761 typedef int D2I(x);
2762 typedef int II2I(int x, int y);
2763 typedef int DI2I(x, int y);
2764 typedef int ID2I(int x, y);
2765 typedef int DD2I(x, y);
2766
2767 typedef I2D(int x);
2768 typedef D2D(x);
2769 typedef II2D(int x, int y);
2770 typedef DI2D(x, int y);
2771 typedef ID2D(int x, y);
2772 typedef DD2D(x, y);
2773
2774 int foo(int x) => x;
2775 int bar(int x, int y) => x + y;
2776
2777 void main() {
2778 bool b;
2779 b = /*severe:InvalidRuntimeCheckError*/foo is I2I;
2780 b = /*severe:InvalidRuntimeCheckError*/foo is D2I;
2781 b = /*severe:InvalidRuntimeCheckError*/foo is I2D;
2782 b = foo is D2D;
2783
2784 b = /*severe:InvalidRuntimeCheckError*/bar is II2I;
2785 b = /*severe:InvalidRuntimeCheckError*/bar is DI2I;
2786 b = /*severe:InvalidRuntimeCheckError*/bar is ID2I;
2787 b = /*severe:InvalidRuntimeCheckError*/bar is II2D;
2788 b = /*severe:InvalidRuntimeCheckError*/bar is DD2I;
2789 b = /*severe:InvalidRuntimeCheckError*/bar is DI2D;
2790 b = /*severe:InvalidRuntimeCheckError*/bar is ID2D;
2791 b = bar is DD2D;
2792
2793 // For as, the validity of checks is deferred to runtime.
2794 Function f;
2795 f = foo as I2I;
2796 f = foo as D2I;
2797 f = foo as I2D;
2798 f = foo as D2D;
2799
2800 f = bar as II2I;
2801 f = bar as DI2I;
2802 f = bar as ID2I;
2803 f = bar as II2D;
2804 f = bar as DD2I;
2805 f = bar as DI2D;
2806 f = bar as ID2D;
2807 f = bar as DD2D;
2808 }
2809 '''
2810 });
2811 });
2756 } 2812 }
OLDNEW
« no previous file with comments | « lib/src/checker/rules.dart ('k') | test/dart_codegen/expect/async/async_error.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698