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

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: Rebase 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
« no previous file with comments | « test_reflectable/test/declarations_test.dart ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test_reflectable/test/invoke_test.dart
diff --git a/test_reflectable/test/invoke_test.dart b/test_reflectable/test/invoke_test.dart
index 7973db12337b699a2e7b9ecc72f6530d190d9dac..16e5dce2346b50bb44cdcd0efd7f4dcb6e8f95a0 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);
+ });
+
}
« no previous file with comments | « test_reflectable/test/declarations_test.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698