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

Side by Side Diff: tests/language_strong/covariant_override/runtime_check_test.dart

Issue 2653493004: Change @checked to covariant in strong tests (Closed)
Patch Set: Created 3 years, 10 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 | « no previous file | tests/language_strong/covariant_override/tear_off_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) 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 "package:expect/expect.dart"; 5 import "package:expect/expect.dart";
6 import 'package:meta/meta.dart' show checked;
7
8 // Test runtime behavior of @checked
9 6
10 class View { 7 class View {
11 addChild(View v) {} 8 addChild(View v) {}
12 transform(View fn(View v)) {} 9 transform(View fn(View v)) {}
13 } 10 }
14 class MyView extends View { 11 class MyView extends View {
15 addChild(@checked MyView v) {} 12 addChild(covariant MyView v) {}
16 transform(@checked MyView fn(Object v)) {} 13 transform(covariant MyView fn(Object v)) {}
17 } 14 }
18 15
19 main() { 16 main() {
20 dynamic mv = new MyView(); 17 dynamic mv = new MyView();
21 dynamic v = new View(); 18 dynamic v = new View();
22 19
23 mv.addChild(mv); 20 mv.addChild(mv);
24 Expect.throws(() => mv.addChild(v)); 21 Expect.throws(() => mv.addChild(v));
25 22
26 mv.transform((_) => new MyView()); 23 mv.transform((_) => new MyView());
27 24
28 // TODO(jmesserly): these *should* be a cast failures, but DDC is currently 25 // TODO(jmesserly): these *should* be cast failures, but DDC is currently
29 // ignoring function type failures w/ a warning at the console... 26 // ignoring function type failures w/ a warning at the console...
30 27
31 // * -> * not a subtype of Object -> MyView 28 // * -> * not a subtype of Object -> MyView
32 // Expect.throws(() => mv.transform((_) => mv)); 29 // Expect.throws(() => mv.transform((_) => mv));
33 30
34 // View -> View not a subtype of Object -> MyView 31 // View -> View not a subtype of Object -> MyView
35 // Expect.throws(() => mv.transform((View x) => x)); 32 // Expect.throws(() => mv.transform((View x) => x));
36 } 33 }
OLDNEW
« no previous file with comments | « no previous file | tests/language_strong/covariant_override/tear_off_type_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698