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

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

Issue 54493002: Remove implicit_setter_test. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 1 month 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 | 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
(Empty)
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
3 // BSD-style license that can be found in the LICENSE file.
4
5 import "package:expect/expect.dart";
6
7 // Test of final fields generating implicit setters that throw.
8
9 String x = "toplevel"; // Should never be read in this test.
10
11 class B {
12 var x = 37;
13 }
14
15 class C extends B {
16 final x = 42;
17
18 // Local access should work the same as direct access.
19 get cx => x;
20 void set cx(value) {
21 x = value; /// 02: static type warning
22 erase(this).x = value; // but crash even if the direct setting is omitted.
23 }
24
25 // Super access should work.
26 get bx => super.x;
27 void set bx(value) { super.x = value; }
28
29 noSuchMethod(i) => "noSuchMethod"; // Should never be called in this test.
30 }
31
32 // Class with only final field has setter in implicit interface.
33 class A {
34 final int x = 42;
35 }
36
37 // Should get warning because the implicit interface contains the setter,
38 // and this non-abstract class doesn't.
39 class AI
40 implements A /// 01: static type warning
41 {
42 int get x => 37;
43 }
44
45 // Erases static type information. Used to avoid *static* warnings when
46 // using a setter for a final field.
47 erase(x) => x;
48
49 void main() {
50 Expect.equals(42, new C().x);
51 Expect.throws(() { erase(new C()).x = 10; });
52 Expect.equals(42, new C().cx);
53 Expect.throws(() { erase(new C()).cx = 10; });
54 Expect.equals(37, new C().bx);
55 Expect.equals(10, (erase(new C())..bx = 10).bx);
56
57 Expect.equals(42, new A().x);
58 Expect.throws(() { erase(new A()).x = 10; });
59 Expect.equals(37, new AI().x);
60 Expect.throws(() { erase(new AI()).x = 10; });
61
62 Expect.equals("toplevel", x); // Should not have changed.
63 }
OLDNEW
« no previous file with comments | « no previous file | tests/language/language.status » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698