Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(431)

Unified Diff: test_reflectable/test/invoke_test.dart

Issue 1182083002: Implement `.instanceMembers`. (Closed) Base URL: https://github.com/dart-lang/reflectable.git@master
Patch Set: Fix return type in test Created 5 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: test_reflectable/test/invoke_test.dart
diff --git a/test_reflectable/test/invoke_test.dart b/test_reflectable/test/invoke_test.dart
index 97b819f30b91e6478eb20fda1e56e056e0dce13e..713c6669684fbcc07d0ef711f8b46ad20d76f275 100644
--- a/test_reflectable/test/invoke_test.dart
+++ b/test_reflectable/test/invoke_test.dart
@@ -21,11 +21,17 @@ class A {
int arg0() => 42;
int arg1(int x) => x - 42;
int arg1to3(int x, int y, [int z = 0, w]) => x + y + z * 42;
- int argNamed(int x, int y, {int z: 42}) => x + y - z;
+ int argNamed(int x, int y,
+ {int z: 42}) => x + y - z;
+ int operator+(x) => 42 + x;
+ int operator[](x) => 42 + x;
+ void operator[]=(x, v) => f = x + v;
+ int f = 0;
}
main() {
- InstanceMirror instanceMirror = myReflectable.reflect(new A());
+ A instance = new A();
+ InstanceMirror instanceMirror = myReflectable.reflect(instance);
test('invoke with no arguments', () {
expect(instanceMirror.invoke("arg0", []), 42);
});
@@ -47,4 +53,15 @@ main() {
test('invoke with mandatory arguments, plus named ones', () {
expect(instanceMirror.invoke("argNamed", [21, 21], {#z: 0}), 42);
});
+ test('invoke operator +', () {
+ expect(instanceMirror.invoke("+", [42]), 84);
+ });
+ test('invoke operator []', () {
+ expect(instanceMirror.invoke("[]", [42]), 84);
+ });
+ test('invoke operator []=', () {
+ instanceMirror.invoke("[]=", [1, 2]);
+ expect(instance.f, 3);
+ });
+
}

Powered by Google App Engine
This is Rietveld 408576698