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

Side by Side 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: 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | dart/tests/language/language.status » ('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) 2011, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2011, 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 // Test that static members cannot be overridden (static type warning only). 5 // Test the semantics of static members mixed with instance members.
6 6
7 m() {} 7 // Following are relevant quotes from Dart Programming Language
8 // Specification, Draft Version 0.10, June 7, 2012.
9
10 // 7 Classes:
11
12 // "It is a compile-time error if a class has an instance method and a
13 // static member method with the same name."
14
15 // 7.1 Instance Methods:
16
17 // "Instance methods are functions (6) whose declarations are
18 // immediately contained within a class declaration and that are not
19 // declared static. The instance methods of a class C are those
20 // instance methods declared by C and the instance methods inherited
21 // by C from its superclass."
22
23
24 // 7.6 Static Methods
25
26 // "Static methods are functions whose declarations are immediately
27 // contained within a class declaration and that are declared
28 // static. The static methods of a class C are those static methods
29 // declared by C."
30
31 // 7.7 Static Variables
32
33 // "Static variables are variables whose declarations are immediately
34 // contained within a class declaration and that are declared
35 // static. The static variables of a class C are those static
36 // variables declared by C."
37
38 // "A static variable declaration of one of the forms static T v;,
39 // static T v = e; , static const T v = e; or static final T v = e;
40 // always induces an implicit static getter function (7.2) with
41 // signature static T get v() whose invocation evaluates as described
42 // below (7.7.1)."
43
44 m() => 'top level';
8 45
9 class Super { 46 class Super {
10 Super() {}
11 // No error from hiding. 47 // No error from hiding.
12 static m() {} 48 static m() => 'super';
13 49
14 static var i; 50 static var i = 'super';
15 51
16 instanceMethod() {} 52 instanceMethod() => m();
53
54 instanceMethod2() => m();
17 } 55 }
18 56
19 class Sub extends Super { 57 class Sub extends Super {
20 Sub() : super(); 58 // According to 7.6, static methods are not inherited.
21 static m() {} /// 01: static type warning 59 static m() => 'sub';
22 60
23 static var i; /// 02: static type warning 61 // According to 7.7, static variables are not inherited.
62 static var i = 'sub';
24 63
25 static instanceMethod() {} /// 03: compile-time error 64 // According to 7.1, instance methods include those of the
65 // superclass, and according to 7, it is a compile-time to have an
66 // instance method and static method with the same name.
67 static /// 03: compile-time error
68 instanceMethod() => m();
26 69
27 static i() {} /// 04: static type warning 70 // According to 7.7, static variables are not inherited.
71 static i() => m();
kasperl 2012/06/20 08:58:32 So you can have a static method called i and a sta
ahe 2012/06/20 09:04:40 No. Static members are not inherited.
zundel 2012/06/20 09:08:57 Its the lesser of evils maybe. Unqualified access
ahe 2012/06/20 11:00:18 Actually, after removing the "compile-time error"
28 72
29 static var instanceMethod; /// 05: compile-time error 73 // According to 7.1, instance methods include those of the
74 // superclass, and according to 7, it is a compile-time to have an
75 // instance method and static method with the same
76 // name. Furthermore, according to 7.7 a static variable induces an
77 // implicit getter function (a static method).
78 static var instanceMethod2; /// 05: compile-time error
30 79
31 foo() {} 80 foo() => 'foo';
32 } 81 }
33 82
34 main() { 83 main() {
35 new Sub().foo(); 84 Expect.equals('foo', new Sub().foo());
85 Expect.equals('top level', m());
86 Expect.equals('super', Super.m());
87 Expect.equals('sub', Sub.m());
88 Expect.equals('super', Super.i);
89 Expect.equals('sub', Sub.i());
90 Expect.equals('super', new Super().instanceMethod());
91 Expect.equals('sub', new Sub().instanceMethod());
92 Expect.equals('super', new Super().instanceMethod2());
93 Expect.equals('super', new Sub().instanceMethod2());
36 } 94 }
OLDNEW
« 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