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

Side by Side Diff: tests/language/src/InstFieldInitializerTest.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
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 // Test for instance field initializer expressions.
5
6 class Cheese {
7 static final mild = 1;
8 static final stinky = 2;
9
10 // Instance fields with initializer expression.
11 String name = "";
12 var smell = mild;
13
14 Cheese() {
15 Expect.equals("", this.name);
16 Expect.equals(Cheese.mild, this.smell);
17 }
18
19 Cheese.initInBlock(String s) {
20 Expect.equals("", this.name);
21 Expect.equals(Cheese.mild, this.smell);
22 this.name = s;
23 }
24
25 Cheese.initFieldParam(this.name, this.smell) {
26 }
27
28 // Test that static final field Cheese.mild is not shadowed
29 // by the parameter mild when compiling the field initializer
30 // for instance field smell.
31 Cheese.hideAndSeek(var mild) : name = mild {
32 Expect.equals(mild, this.name);
33 Expect.equals(Cheese.mild, this.smell);
34 }
35 }
36
37 class HasNoExplicitConstructor {
38 String s = "Tilsiter";
39 }
40
41 main() {
42 var generic = new Cheese();
43 Expect.equals("", generic.name);
44 Expect.equals(Cheese.mild, generic.smell);
45
46 var gruyere = new Cheese.initInBlock("Gruyere");
47 Expect.equals("Gruyere", gruyere.name);
48 Expect.equals(Cheese.mild, gruyere.smell);
49
50 var munster = new Cheese.initFieldParam("Munster", Cheese.stinky);
51 Expect.equals("Munster", munster.name);
52 Expect.equals(Cheese.stinky, munster.smell);
53
54 var brie = new Cheese.hideAndSeek("Brie");
55 Expect.equals("Brie", brie.name);
56 Expect.equals(Cheese.mild, brie.smell);
57
58 var t = new HasNoExplicitConstructor();
59 Expect.equals("Tilsiter", t.s);
60 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698