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

Side by Side Diff: dart/tests/language/getters_setters2_test.dart

Issue 10829416: Update language tests to new getter syntax. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 8 years, 4 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
OLDNEW
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, 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 // Tests classes with getters and setters that do not have the same type. 5 // Tests classes with getters and setters that do not have the same type.
6 6
7 class A { 7 class A {
8 int a() { return 37;} 8 int a() { return 37;}
9 } 9 }
10 10
11 class B extends A{ 11 class B extends A{
12 int b() { return 38; } 12 int b() { return 38; }
13 } 13 }
14 14
15 class C {} 15 class C {}
16 16
17 class T1 { 17 class T1 {
18 A getterField; 18 A getterField;
19 A get field() { return getterField; } 19 A get field { return getterField; }
20 // OK, B is assignable to A 20 // OK, B is assignable to A
21 void set field(B arg) { getterField = arg; } 21 void set field(B arg) { getterField = arg; }
22 } 22 }
23 23
24 class T2 { 24 class T2 {
25 A getterField; 25 A getterField;
26 C setterField; 26 C setterField;
27 A get field() { return getterField; } 27 A get field { return getterField; }
28 28
29 // Type C is not assignable to A 29 // Type C is not assignable to A
30 void set field(C arg) { setterField = arg; } /// 01: static type warning 30 void set field(C arg) { setterField = arg; } /// 01: static type warning
31 } 31 }
32 32
33 class T3 { 33 class T3 {
34 B getterField; 34 B getterField;
35 B get field() { return getterField; } 35 B get field { return getterField; }
36 // OK, A is assignable to B 36 // OK, A is assignable to B
37 void set field(A arg) { getterField = arg; } 37 void set field(A arg) { getterField = arg; }
38 } 38 }
39 39
40 40
41 main() { 41 main() {
42 T1 instance1 = new T1(); 42 T1 instance1 = new T1();
43 T2 instance2 = new T2(); /// 01: continued 43 T2 instance2 = new T2(); /// 01: continued
44 T3 instance3 = new T3(); 44 T3 instance3 = new T3();
45 45
46 instance1.field = new B(); 46 instance1.field = new B();
47 A resultA = instance1.field; 47 A resultA = instance1.field;
48 instance1.field = new A(); /// 03: dynamic type error 48 instance1.field = new A(); /// 03: dynamic type error
49 B resultB = instance1.field; 49 B resultB = instance1.field;
50 50
51 int result; 51 int result;
52 result = instance1.field.a(); 52 result = instance1.field.a();
53 Expect.equals(37, result); 53 Expect.equals(37, result);
54 54
55 // Type 'A' has no method named 'b' 55 // Type 'A' has no method named 'b'
56 instance1.field.b(); /// 02: static type warning 56 instance1.field.b(); /// 02: static type warning
57 57
58 instance3.field = new B(); 58 instance3.field = new B();
59 result = instance3.field.a(); 59 result = instance3.field.a();
60 Expect.equals(37, result); 60 Expect.equals(37, result);
61 result = instance3.field.b(); 61 result = instance3.field.b();
62 Expect.equals(38, result); 62 Expect.equals(38, result);
63 } 63 }
OLDNEW
« no previous file with comments | « dart/tests/language/getter_setter_in_lib.dart ('k') | dart/tests/language/getters_setters_type2_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698