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

Unified Diff: dart/tests/language/abstract_runtime_error_test.dart

Issue 11017052: Test of AbstractClassInstantiationError. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge
Patch Set: Address Kasper's review comments Created 8 years, 2 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
« no previous file with comments | « no previous file | dart/tests/language/language_dart2js.status » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: dart/tests/language/abstract_runtime_error_test.dart
diff --git a/dart/tests/language/abstract_runtime_error_test.dart b/dart/tests/language/abstract_runtime_error_test.dart
new file mode 100644
index 0000000000000000000000000000000000000000..ceb973c597b8d15de9ca9edeee4744ebe074cde8
--- /dev/null
+++ b/dart/tests/language/abstract_runtime_error_test.dart
@@ -0,0 +1,43 @@
+// Copyright (c) 2012, 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.
+
+// Test various conditions around instantiating an abstract class.
+
+// From The Dart Programming Langauge Specification, 11.11.1 "New":
+// If q is a constructor of an abstract class then an
+// AbstractClassInstantiation- Error is thrown.
+
+
+abstract class Interface {
+ void foo();
+}
+
+abstract class AbstractClass {
+ toString() => 'AbstractClass';
+}
+
+class ConcreteSubclass extends AbstractClass {
+ toString() => 'ConcreteSubclass';
+}
+
+class NonAbstractClass implements Interface {
+ toString() => 'NonAbstractClass';
+}
+
+Interface interface() => new Interface();
+
+AbstractClass abstractClass() => new AbstractClass();
+
+bool isAbstractClassInstantiationError(e) {
+ return e is AbstractClassInstantiationError;
+}
+
+void main() {
+ Expect.throws(interface, isAbstractClassInstantiationError,
+ "expected AbstractClassInstantiationError");
+ Expect.throws(abstractClass, isAbstractClassInstantiationError,
+ "expected AbstractClassInstantiationError");
+ Expect.stringEquals('ConcreteSubclass', '${new ConcreteSubclass()}');
bakster 2012/10/10 13:56:17 I prefer: Expect.equals(new ConcreteSubclass() i
+ Expect.stringEquals('NonAbstractClass', '${new NonAbstractClass()}');
+}
« no previous file with comments | « no previous file | dart/tests/language/language_dart2js.status » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698