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

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

Issue 10572031: Update fauxverride_test to Draft Version 0.10 of the spec. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge
Patch Set: Update status file Created 8 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
« no previous file with comments | « no previous file | dart/tests/language/language.status » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: dart/tests/language/fauxverride_test.dart
diff --git a/dart/tests/language/fauxverride_test.dart b/dart/tests/language/fauxverride_test.dart
index 4e7b7cc4c5f467f46b22d86ce9bf11f0b0715701..0ed12a9ceccb2cb3750a93e150dcb4a1b950f63c 100644
--- a/dart/tests/language/fauxverride_test.dart
+++ b/dart/tests/language/fauxverride_test.dart
@@ -2,35 +2,97 @@
// 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 that static members cannot be overridden (static type warning only).
+// Test the semantics of static members mixed with instance members.
-m() {}
+// Following are relevant quotes from Dart Programming Language
+// Specification, Draft Version 0.10, June 7, 2012.
+
+// 7 Classes:
+
+// "It is a compile-time error if a class has an instance method and a
+// static member method with the same name."
+
+// 7.1 Instance Methods:
+
+// "Instance methods are functions (6) whose declarations are
+// immediately contained within a class declaration and that are not
+// declared static. The instance methods of a class C are those
+// instance methods declared by C and the instance methods inherited
+// by C from its superclass."
+
+
+// 7.6 Static Methods
+
+// "Static methods are functions whose declarations are immediately
+// contained within a class declaration and that are declared
+// static. The static methods of a class C are those static methods
+// declared by C."
+
+// 7.7 Static Variables
+
+// "Static variables are variables whose declarations are immediately
+// contained within a class declaration and that are declared
+// static. The static variables of a class C are those static
+// variables declared by C."
+
+// "A static variable declaration of one of the forms static T v;,
+// static T v = e; , static const T v = e; or static final T v = e;
+// always induces an implicit static getter function (7.2) with
+// signature static T get v() whose invocation evaluates as described
+// below (7.7.1)."
+
+m() => 'top level';
class Super {
- Super() {}
// No error from hiding.
- static m() {}
+ static m() => 'super';
+
+ static var i = 'super';
+
+ static var i2 = 'super';
- static var i;
+ instanceMethod() => m();
- instanceMethod() {}
+ instanceMethod2() => m();
}
class Sub extends Super {
- Sub() : super();
- static m() {} /// 01: static type warning
+ // According to 7.6, static methods are not inherited.
+ static m() => 'sub';
- static var i; /// 02: static type warning
+ // According to 7.7, static variables are not inherited.
+ static var i = 'sub';
- static instanceMethod() {} /// 03: compile-time error
+ // According to 7.1, instance methods include those of the
+ // superclass, and according to 7, it is a compile-time to have an
+ // instance method and static method with the same name.
+ static /// 03: compile-time error
+ instanceMethod() => m();
- static i() {} /// 04: static type warning
+ // According to 7.7, static variables are not inherited.
+ static i2() => m();
- static var instanceMethod; /// 05: compile-time error
+ // According to 7.1, instance methods include those of the
+ // superclass, and according to 7, it is a compile-time to have an
+ // instance method and static method with the same
+ // name. Furthermore, according to 7.7 a static variable induces an
+ // implicit getter function (a static method).
+ static var instanceMethod2; /// 05: compile-time error
- foo() {}
+ foo() => 'foo';
}
main() {
- new Sub().foo();
+ Expect.equals('foo', new Sub().foo());
+ Expect.equals('top level', m());
+ Expect.equals('super', Super.m());
+ Expect.equals('sub', Sub.m());
+ Expect.equals('super', Super.i);
+ Expect.equals('sub', Sub.i);
+ Expect.equals('super', Super.i2);
+ Expect.equals('sub', Sub.i2());
+ Expect.equals('super', new Super().instanceMethod());
+ Expect.equals('sub', new Sub().instanceMethod());
+ Expect.equals('super', new Super().instanceMethod2());
+ Expect.equals('super', new Sub().instanceMethod2());
}
« no previous file with comments | « no previous file | dart/tests/language/language.status » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698