OLD | NEW |
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 // Dart test for testing access to private fields. | 5 // Dart test for testing access to private fields. |
6 | 6 |
7 main() { | 7 main() { |
8 testPrivateTopLevel(); | 8 testPrivateTopLevel(); |
9 testPrivateClasses(); | 9 testPrivateClasses(); |
10 } | 10 } |
11 | 11 |
12 void expectCatch(f) { | 12 void expectCatch(f) { |
13 bool threw = false; | 13 bool threw = false; |
14 try { | 14 try { |
15 f(); | 15 f(); |
16 } catch (var e) { | 16 } catch (var e) { |
17 threw = true; | 17 threw = true; |
18 } | 18 } |
19 Expect.equals(true, threw); | 19 Expect.equals(true, threw); |
20 } | 20 } |
21 | 21 |
22 String _private1() => "private1"; | 22 String _private1() => "private1"; |
23 final String _private1Field = "private1Field"; | 23 const String _private1Field = "private1Field"; |
24 | 24 |
25 void testPrivateTopLevel() { | 25 void testPrivateTopLevel() { |
26 Expect.equals("private1", _private1()); | 26 Expect.equals("private1", _private1()); |
27 Expect.equals("private2", _private2()); | 27 Expect.equals("private2", _private2()); |
28 Expect.equals("private1Field", _private1Field); | 28 Expect.equals("private1Field", _private1Field); |
29 Expect.equals("private2Field", _private2Field); | 29 Expect.equals("private2Field", _private2Field); |
30 } | 30 } |
31 | 31 |
32 class _A { | 32 class _A { |
33 _A() : fieldA = 499; | 33 _A() : fieldA = 499; |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
88 Expect.equals(42, c.field2a()); | 88 Expect.equals(42, c.field2a()); |
89 Expect.equals(99, LibOther3.c_field1b(c)); | 89 Expect.equals(99, LibOther3.c_field1b(c)); |
90 Expect.equals(99, c.field1b()); | 90 Expect.equals(99, c.field1b()); |
91 Expect.equals(1024, LibOther3.c_field2b(c)); | 91 Expect.equals(1024, LibOther3.c_field2b(c)); |
92 Expect.equals(1024, c.field2b()); | 92 Expect.equals(1024, c.field2b()); |
93 Expect.equals(499, c.field1c()); | 93 Expect.equals(499, c.field1c()); |
94 Expect.equals(99, c.field1d()); | 94 Expect.equals(99, c.field1d()); |
95 Expect.equals(499, _field1FromNewC4()); | 95 Expect.equals(499, _field1FromNewC4()); |
96 Expect.equals(42, _field2FromNewC4()); | 96 Expect.equals(42, _field2FromNewC4()); |
97 } | 97 } |
OLD | NEW |