mirror of
https://github.com/dart-lang/sdk
synced 2024-09-18 22:21:18 +00:00
74e4ccdeb8
Change-Id: Ia5a433e70ab3bdf953a116a0b65de42138125d2b Reviewed-on: https://dart-review.googlesource.com/6347 Reviewed-by: Bob Nystrom <rnystrom@google.com>
67 lines
1.8 KiB
Dart
67 lines
1.8 KiB
Dart
// Copyright (c) 2015, 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";
|
|
|
|
// Validates that positional arguments are an empty immutable list.
|
|
void expectEmptyPositionalArguments(Invocation invocation) {
|
|
Expect.isTrue(invocation.positionalArguments.isEmpty);
|
|
Expect.throwsUnsupportedError(() => invocation.positionalArguments.clear());
|
|
}
|
|
|
|
// Validates that positional arguments are an empty immutable map.
|
|
void expectEmptyNamedArguments(Invocation invocation) {
|
|
Expect.isTrue(invocation.namedArguments.isEmpty);
|
|
Expect.throwsUnsupportedError(() => invocation.namedArguments.clear());
|
|
}
|
|
|
|
class Getter {
|
|
get getterThatDoesNotExist;
|
|
|
|
noSuchMethod(invocation) {
|
|
Expect.isTrue(invocation.isGetter);
|
|
expectEmptyPositionalArguments(invocation);
|
|
expectEmptyNamedArguments(invocation);
|
|
}
|
|
}
|
|
|
|
class Setter {
|
|
set setterThatDoesNotExist(value);
|
|
|
|
noSuchMethod(invocation) {
|
|
Expect.isTrue(invocation.isSetter);
|
|
expectEmptyNamedArguments(invocation);
|
|
}
|
|
}
|
|
|
|
class Method {
|
|
methodThatDoesNotExist();
|
|
|
|
noSuchMethod(invocation) {
|
|
Expect.isTrue(invocation.isMethod);
|
|
expectEmptyPositionalArguments(invocation);
|
|
expectEmptyNamedArguments(invocation);
|
|
}
|
|
}
|
|
|
|
class Operator {
|
|
operator +(other);
|
|
|
|
noSuchMethod(invocation) {
|
|
Expect.isTrue(invocation.isMethod);
|
|
expectEmptyNamedArguments(invocation);
|
|
}
|
|
}
|
|
|
|
main() {
|
|
var g = new Getter();
|
|
print(g.getterThatDoesNotExist);
|
|
var s = new Setter();
|
|
print(s.setterThatDoesNotExist = 42);
|
|
var m = new Method();
|
|
print(m.methodThatDoesNotExist());
|
|
var o = new Operator();
|
|
print(o + 42); // Operator that does not exist.
|
|
}
|