mirror of
https://github.com/dart-lang/sdk
synced 2024-09-16 00:09:49 +00:00
415cab79d3
Change-Id: Ibe4be604f5002c125aba64c051793b750f31638a Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/147819 Commit-Queue: Bob Nystrom <rnystrom@google.com> Auto-Submit: Bob Nystrom <rnystrom@google.com> Reviewed-by: Erik Ernst <eernst@google.com>
39 lines
739 B
Dart
39 lines
739 B
Dart
// Copyright (c) 2012, 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.
|
|
|
|
import "package:expect/expect.dart";
|
|
|
|
class A {
|
|
int length = 0;
|
|
}
|
|
|
|
class B {
|
|
int length = 0;
|
|
foo(receiver) {
|
|
length++;
|
|
return receiver.length++;
|
|
}
|
|
|
|
bar(receiver) {
|
|
++length;
|
|
return ++receiver.length;
|
|
}
|
|
}
|
|
|
|
main() {
|
|
var a = new A();
|
|
var b = new B();
|
|
var c = <int?>[1, 2, 3];
|
|
|
|
Expect.equals(3, b.foo(c));
|
|
Expect.equals(5, b.bar(c));
|
|
Expect.equals(5, c.length);
|
|
|
|
Expect.equals(0, b.foo(a));
|
|
Expect.equals(2, b.bar(a));
|
|
Expect.equals(2, a.length);
|
|
|
|
Expect.equals(4, b.length);
|
|
}
|