mirror of
https://github.com/dart-lang/sdk
synced 2024-09-05 16:41:07 +00:00
![Leaf Petersen](/assets/img/avatar_default.png)
Change-Id: Ib33169c3e0ffc870915c189404074a1dea472546 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/196548 Reviewed-by: Bob Nystrom <rnystrom@google.com> Commit-Queue: Leaf Petersen <leafp@google.com>
51 lines
2.1 KiB
Dart
51 lines
2.1 KiB
Dart
// Copyright (c) 2020, 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 = 2.9
|
|
|
|
import "package:expect/expect.dart";
|
|
|
|
main() {
|
|
// Using withInvocation constructor.
|
|
var receiver = Object();
|
|
{
|
|
var invocationGet = Invocation.getter(#foo);
|
|
var errorGet = NoSuchMethodError.withInvocation(receiver, invocationGet);
|
|
var errorString = errorGet.toString();
|
|
Expect.isTrue(errorString.contains("foo"), "01: $errorString");
|
|
Expect.isTrue(errorString.contains("getter"), "02: $errorString");
|
|
}
|
|
{
|
|
var invocationSet = Invocation.setter(#foo, 42);
|
|
var error = NoSuchMethodError.withInvocation(receiver, invocationSet);
|
|
var errorString = error.toString();
|
|
Expect.isTrue(errorString.contains("foo"), "03: $errorString");
|
|
Expect.isTrue(errorString.contains("setter"), "04: $errorString");
|
|
}
|
|
{
|
|
var invocationCall = Invocation.method(#foo, [42]);
|
|
var error = NoSuchMethodError.withInvocation(receiver, invocationCall);
|
|
var errorString = error.toString();
|
|
Expect.isTrue(errorString.contains("foo"), "05: $errorString");
|
|
Expect.isTrue(errorString.contains("method"), "06: $errorString");
|
|
Expect.isTrue(errorString.contains("(_)"), "07: $errorString");
|
|
}
|
|
{
|
|
var invocationCall = Invocation.method(#foo, [42], {#bar: 37});
|
|
var error = NoSuchMethodError.withInvocation(receiver, invocationCall);
|
|
var errorString = error.toString();
|
|
Expect.isTrue(errorString.contains("foo"), "08: $errorString");
|
|
Expect.isTrue(errorString.contains("method"), "09: $errorString");
|
|
Expect.isTrue(errorString.contains("(_, {bar: _})"), "10: $errorString");
|
|
}
|
|
{
|
|
var invocationCall = Invocation.genericMethod(#foo, [int], [42]);
|
|
var error = NoSuchMethodError.withInvocation(receiver, invocationCall);
|
|
var errorString = error.toString();
|
|
Expect.isTrue(errorString.contains("foo"), "11: $errorString");
|
|
Expect.isTrue(errorString.contains("method"), "12: $errorString");
|
|
Expect.isTrue(errorString.contains("<_>(_)"), "13: $errorString");
|
|
}
|
|
}
|