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

Unified Diff: tests/language/function_subtype_setter0_test.dart

Issue 12334070: Support runtime check of function types. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Fix status files Created 7 years, 6 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 side-by-side diff with in-line comments
Download patch
Index: tests/language/function_subtype_setter0_test.dart
diff --git a/tests/language/checked_setter_test.dart b/tests/language/function_subtype_setter0_test.dart
similarity index 50%
copy from tests/language/checked_setter_test.dart
copy to tests/language/function_subtype_setter0_test.dart
index 608a472f9c8dc27855c6bfa9650b6cfcec970635..9e6170b30a6b9712db3bbbe8de703073158b3007 100644
--- a/tests/language/checked_setter_test.dart
+++ b/tests/language/function_subtype_setter0_test.dart
@@ -1,25 +1,26 @@
// Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+// Dart test program for constructors and initializers.
-// Test that implicit setters in checked mode do a type check.
+// Check function subtyping for implicit setters.
-import "package:expect/expect.dart";
+import 'package:expect/expect.dart';
-class A {
- C c;
-}
-
-class B extends A {
-}
+typedef void Foo();
+class A<T> {}
class C {
+ Foo foo;
+ A<int> bar;
}
-var array = [new B()];
+class D {
+ Foo foo;
+ A<int> bar;
+}
-main() {
- array[0].c = new C();
+test(var c) {
bool inCheckedMode = false;
try {
String a = 42;
karlklose 2013/06/20 13:11:04 Use var x = 42; String a = x; to avoid warnings
Johnni Winther 2013/06/21 12:19:15 Done.
@@ -27,6 +28,12 @@ main() {
inCheckedMode = true;
}
if (inCheckedMode) {
- Expect.throws(() => array[0].c = new B(), (e) => e is TypeError);
+ Expect.throws(() => c.foo = 1, (e) => true);
}
+ c.foo = () {};
+}
+
+void main() {
+ test(new C());
+ test(new D());
}

Powered by Google App Engine
This is Rietveld 408576698