Files
sdk/tests/language/src/InstanceCompoundAssignmentOperatorTest.dart
T
dgrove@google.com ebe439410d Initial checkin.
git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@22 260f80e4-7a28-3924-810f-c04153c831b5
2011-10-05 06:22:36 +00:00

40 lines
823 B
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 correct instance compound assignment operator.
class A {
A() : f = 2 {}
var f;
}
class B {
B() : _a = new A(), count = 0 {}
get a() {
count++;
return _a;
}
var _a;
var count;
}
class InstanceCompoundAssignmentOperatorTest {
static void testMain() {
B b = new B();
Expect.equals(0, b.count);
Expect.equals(2, b.a.f);
Expect.equals(1, b.count);
var o = b.a;
Expect.equals(2, b.count);
b.a.f = 1;
Expect.equals(3, b.count);
b.a.f += 1;
Expect.equals(4, b.count);
}
}
main() {
InstanceCompoundAssignmentOperatorTest.testMain();
}