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

Side by Side Diff: tests/language/src/Private1.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, 7 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 | « tests/language/src/PrefixTest2.dart ('k') | tests/language/src/Private2.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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
5 // Dart test for testing access to private fields.
6
7 main() {
8 testPrivateTopLevel();
9 testPrivateClasses();
10 }
11
12 void expectCatch(f) {
13 bool threw = false;
14 try {
15 f();
16 } catch (var e) {
17 threw = true;
18 }
19 Expect.equals(true, threw);
20 }
21
22 String _private1() => "private1";
23 final String _private1Field = "private1Field";
24
25 void testPrivateTopLevel() {
26 Expect.equals("private1", _private1());
27 Expect.equals("private2", _private2());
28 Expect.equals("private1Field", _private1Field);
29 Expect.equals("private2Field", _private2Field);
30 }
31
32 class _A {
33 _A() : fieldA = 499;
34
35 int fieldA;
36 }
37
38 class AExposed extends _A {
39 AExposed() : super();
40 }
41
42 class B {
43 int _fieldB;
44 B() : _fieldB = 42;
45 }
46
47 class C1 {
48 int _field1;
49 C1() : _field1 = 499;
50
51 field1a() => _field1;
52 }
53
54 class C3 extends C2 {
55 int _field2;
56 C3() : super(), _field2 = 42;
57
58 field2a() => _field2;
59 field1c() => _field1;
60 }
61
62 int c_field1a(c) => c._field1;
63 int c_field2a(c) => c._field2;
64
65 void testPrivateClasses() {
66 _A a = new _A();
67 Expect.equals(499, a.fieldA);
68 Expect.equals(499, accessFieldA2(a));
69 Expect.equals(499, LibOther3.accessFieldA3(a));
70
71 var a2 = new AImported();
72 Expect.equals(499, a2.getFieldA());
73
74 B b = new B();
75 Expect.equals(42, b._fieldB);
76 Expect.equals(42, accessFieldB2(b));
77 expectCatch(() => LibOther3.accessFieldB3(b));
78
79 C4 c = new C4();
80 Expect.equals(499, c_field1a(c));
81 Expect.equals(499, c.field1a());
82 Expect.equals(42, c_field2a(c));
83 Expect.equals(42, c.field2a());
84 Expect.equals(99, LibOther3.c_field1b(c));
85 Expect.equals(99, c.field1b());
86 Expect.equals(1024, LibOther3.c_field2b(c));
87 Expect.equals(1024, c.field2b());
88 Expect.equals(499, c.field1c());
89 Expect.equals(99, c.field1d());
90 }
OLDNEW
« no previous file with comments | « tests/language/src/PrefixTest2.dart ('k') | tests/language/src/Private2.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698