2dcd56ef43
There are far too many files here to review everyone carefully. Spot checking most of the diffs look good as test code is generally written with less care than application code so lots of ugly formatting get through. If people notice files where the automated formatting bothers them feel free to comment indicating file names and I'll move spaces within comments to make the formatting cleaner and use comments to force block formatting as I have done for other case where formatting looked bad. BUG= R=efortuna@google.com Review-Url: https://codereview.chromium.org/2771453003 .
62 lines
1.7 KiB
Dart
62 lines
1.7 KiB
Dart
// Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file
|
|
// for details. All rights reserved. Use of this source code is governed by a
|
|
// BSD-style license that can be found in the LICENSE file.
|
|
// Test for instance field initializer expressions.
|
|
|
|
import "package:expect/expect.dart";
|
|
|
|
class Cheese {
|
|
static const mild = 1;
|
|
static const stinky = 2;
|
|
|
|
// Instance fields with initializer expression.
|
|
String name = "";
|
|
var smell = mild;
|
|
|
|
Cheese() {
|
|
Expect.equals("", this.name);
|
|
Expect.equals(Cheese.mild, this.smell);
|
|
}
|
|
|
|
Cheese.initInBlock(String s) {
|
|
Expect.equals("", this.name);
|
|
Expect.equals(Cheese.mild, this.smell);
|
|
this.name = s;
|
|
}
|
|
|
|
Cheese.initFieldParam(this.name, this.smell) {}
|
|
|
|
// Test that static const field Cheese.mild is not shadowed
|
|
// by the parameter mild when compiling the field initializer
|
|
// for instance field smell.
|
|
Cheese.hideAndSeek(var mild) : name = mild {
|
|
Expect.equals(mild, this.name);
|
|
Expect.equals(Cheese.mild, this.smell);
|
|
}
|
|
}
|
|
|
|
class HasNoExplicitConstructor {
|
|
String s = "Tilsiter";
|
|
}
|
|
|
|
main() {
|
|
var generic = new Cheese();
|
|
Expect.equals("", generic.name);
|
|
Expect.equals(Cheese.mild, generic.smell);
|
|
|
|
var gruyere = new Cheese.initInBlock("Gruyere");
|
|
Expect.equals("Gruyere", gruyere.name);
|
|
Expect.equals(Cheese.mild, gruyere.smell);
|
|
|
|
var munster = new Cheese.initFieldParam("Munster", Cheese.stinky);
|
|
Expect.equals("Munster", munster.name);
|
|
Expect.equals(Cheese.stinky, munster.smell);
|
|
|
|
var brie = new Cheese.hideAndSeek("Brie");
|
|
Expect.equals("Brie", brie.name);
|
|
Expect.equals(Cheese.mild, brie.smell);
|
|
|
|
var t = new HasNoExplicitConstructor();
|
|
Expect.equals("Tilsiter", t.s);
|
|
}
|