dart-sdk/tests/language/static_const_field_test.dart
Jacob Richman 2dcd56ef43 Format all tests.
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 .
2017-04-17 14:53:02 -07:00

60 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.
// Dart test program for testing static const fields.
import "package:expect/expect.dart";
abstract class Spain {
static const AG = "Antoni Gaudi";
static const SD = "Salvador Dali";
}
abstract class Switzerland {
static const AG = "Alberto Giacometti";
static const LC = "Le Corbusier";
}
class A implements Switzerland {
const A() : n = 5;
final n;
static const a = const A();
static const b = 3 + 5;
static const c = A.b + 7;
static const d = const A();
static const s1 = "hula";
static const s2 = "hula";
static const s3 = "hop";
static const d1 = 1.1;
static const d2 = 0.55 + 0.55;
static const artist2 = Switzerland.AG;
static const architect1 = Spain.AG;
static const array1 = const <int>[1, 2];
static const map1 = const {
"Monday": 1,
"Tuesday": 2,
};
}
class StaticFinalFieldTest {
static testMain() {
Expect.equals(15, A.c);
Expect.equals(8, A.b);
Expect.equals(5, A.a.n);
Expect.equals(true, identical(8, A.b));
Expect.equals(true, identical(A.a, A.d));
Expect.equals(true, identical(A.s1, A.s2));
Expect.equals(false, identical(A.s1, A.s3));
Expect.equals(false, identical(A.s1, A.b));
Expect.equals(true, identical(A.d1, A.d2));
Expect.equals(true, Spain.SD == "Salvador Dali");
Expect.equals(true, A.artist2 == "Alberto Giacometti");
Expect.equals(true, A.architect1 == "Antoni Gaudi");
Expect.equals(2, A.map1["Tuesday"]);
}
}
main() {
StaticFinalFieldTest.testMain();
}