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

Side by Side Diff: tests/language/src/FieldTest.dart

Issue 10248007: test rename overhaul: step 8 - language tests (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years, 8 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
(Empty)
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
3 // BSD-style license that can be found in the LICENSE file.
4 // Dart test program for testing setting/getting of instance fields.
5
6 class First {
7 First() {}
8 var a;
9 var b;
10
11 addFields() {
12 return a + b;
13 }
14
15 setValues() {
16 a = 24;
17 b = 10;
18 return a + b;
19 }
20 }
21
22 class Second extends First {
23 // TODO: consider removing once http://b/4254120 is fixed.
24 Second() : super() {}
25 var c;
26 get a() { return -12; }
27 set b(a) { a.c = 12; }
28 }
29
30 class FieldTest {
31 static one() {
32 var f = new First();
33 f.a = 3;
34 f.b = f.a;
35 Expect.equals(3, f.a);
36 Expect.equals(f.a, f.b);
37 f.b = (f.a = 10);
38 Expect.equals(10, f.a);
39 Expect.equals(10, f.b);
40 f.b = f.a = 15;
41 Expect.equals(15, f.a);
42 Expect.equals(15, f.b);
43 Expect.equals(30, f.addFields());
44 Expect.equals(34, f.setValues());
45 Expect.equals(24, f.a);
46 Expect.equals(10, f.b);
47 }
48
49 static two() {
50 // The tests below are a little cumbersome because not
51 // everything is implemented yet.
52 var o = new Second();
53 // 'a' getter is overriden, always returns -12.
54 Expect.equals(-12, o.a);
55 o.a = 2;
56 Expect.equals(-12, o.a);
57 // 'b' setter is overriden to write 12 to field 'c'.
58 o.b = o;
59 Expect.equals(12, o.c);
60 }
61
62 static testMain() {
63 // FieldTest.one();
64 FieldTest.two();
65 }
66 }
67
68
69 main() {
70 FieldTest.testMain();
71 }
OLDNEW
« no previous file with comments | « tests/language/src/FieldParameterTest.dart ('k') | tests/language/src/FinalForInVariableTest.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698