| Index: tests/lib/mirrors/invoke_test.dart
|
| diff --git a/tests/lib/mirrors/invoke_test.dart b/tests/lib/mirrors/invoke_test.dart
|
| index 2d225d18499e52590536bd2887b7d83491db123a..ec5056f38790113b40d5a2f534fd1329a8d9e703 100644
|
| --- a/tests/lib/mirrors/invoke_test.dart
|
| +++ b/tests/lib/mirrors/invoke_test.dart
|
| @@ -9,7 +9,6 @@ import 'dart:mirrors';
|
| import 'dart:async' show Future;
|
|
|
| import 'package:expect/expect.dart';
|
| -import "package:async_helper/async_helper.dart";
|
|
|
| class C {
|
| var field;
|
| @@ -34,33 +33,6 @@ get libraryGetter => 'lget $libraryField';
|
| set librarySetter(v) => libraryField = 'lset $v';
|
| libraryFunction(x,y) => '$x$y';
|
|
|
| -Future expectValueThen(Future future, Function onValue) {
|
| - asyncStart();
|
| - wrappedOnValue(resultIn) {
|
| - var resultOut = onValue(resultIn);
|
| - asyncEnd();
|
| - return resultOut;
|
| - }
|
| - onError(e) {
|
| - Expect.fail("Value expected. ($e)");
|
| - }
|
| - return future.then(wrappedOnValue, onError: onError);
|
| -}
|
| -
|
| -Future expectError(Future future, Function errorPredicate, String reason) {
|
| - asyncStart();
|
| - onValue(result) {
|
| - Expect.fail("Error expected ($reason)");
|
| - }
|
| - onError(e) {
|
| - asyncEnd();
|
| - if (!errorPredicate(e)) {
|
| - Expect.fail("Unexpected error ($reason)");
|
| - }
|
| - }
|
| - return future.then(onValue, onError: onError);
|
| -}
|
| -
|
| bool isNoSuchMethodError(e) {
|
| return e is NoSuchMethodError;
|
| }
|
| @@ -181,177 +153,6 @@ testSync() {
|
| 'Not defined');
|
| }
|
|
|
| -testAsync() {
|
| - var future;
|
| -
|
| - // InstanceMirror invoke
|
| - C c = new C();
|
| - InstanceMirror im = reflect(c);
|
| - future = im.invokeAsync(const Symbol('method'), [2,4,8]);
|
| - expectValueThen(future, (result) {
|
| - Expect.equals('2+4+8', result.reflectee);
|
| - });
|
| - future = im.invokeAsync(const Symbol('method'), [im,im,im]);
|
| - expectValueThen(future, (result) {
|
| - Expect.equals('a C+a C+a C', result.reflectee);
|
| - });
|
| - future = im.invokeAsync(const Symbol('doesntExist'), [2,4,8]);
|
| - expectValueThen(future, (result) {
|
| - Expect.equals('DNU', result.reflectee);
|
| - });
|
| - future = im.invokeAsync(const Symbol('method'), [2, 4]); // Wrong arity.
|
| - expectValueThen(future, (result) {
|
| - Expect.equals('DNU', result.reflectee);
|
| - });
|
| -
|
| - // InstanceMirror invokeGetter
|
| - future = im.getFieldAsync(const Symbol('getter'));
|
| - expectValueThen(future, (result) {
|
| - Expect.equals('get default', result.reflectee);
|
| - });
|
| - future = im.getFieldAsync(const Symbol('field'));
|
| - expectValueThen(future, (result) {
|
| - Expect.equals('default', result.reflectee);
|
| - });
|
| - future = im.getFieldAsync(const Symbol('doesntExist'));
|
| - expectValueThen(future, (result) {
|
| - Expect.equals('DNU', result.reflectee);
|
| - });
|
| -
|
| - // InstanceMirror invokeSetter
|
| - future = im.setFieldAsync(const Symbol('setter'), 'foo');
|
| - expectValueThen(future, (result) {
|
| - Expect.equals('foo', result.reflectee);
|
| - Expect.equals('set foo', c.field);
|
| - return im.setFieldAsync(const Symbol('field'), 'bar');
|
| - }).then((result) {
|
| - Expect.equals('bar', result.reflectee);
|
| - Expect.equals('bar', c.field);
|
| - return im.setFieldAsync(const Symbol('field'), im);
|
| - }).then((result) {
|
| - Expect.equals(im.reflectee, result.reflectee);
|
| - Expect.equals(c, c.field);
|
| - });
|
| - future = im.setFieldAsync(const Symbol('doesntExist'), 'bar');
|
| - expectValueThen(future, (result) {
|
| - Expect.equals('bar', result.reflectee);
|
| - });
|
| -
|
| -
|
| - // ClassMirror invoke
|
| - ClassMirror cm = reflectClass(C);
|
| - future = cm.invokeAsync(const Symbol('staticFunction'),[3,4]);
|
| - expectValueThen(future, (result) {
|
| - Expect.equals('(3,4)', result.reflectee);
|
| - });
|
| - future = cm.invokeAsync(const Symbol('staticFunction'),[im,im]);
|
| - expectValueThen(future, (result) {
|
| - Expect.equals('(a C,a C)', result.reflectee);
|
| - });
|
| - future = cm.invokeAsync(const Symbol('doesntExist'),[im,im]);
|
| - expectError(future, isNoSuchMethodError, 'Not defined');
|
| - future = cm.invokeAsync(const Symbol('staticFunction'),[3]);
|
| - expectError(future, isNoSuchMethodError, 'Wrong arity');
|
| -
|
| - // ClassMirror invokeGetter
|
| - C.staticField = 'initial'; // Reset from synchronous test.
|
| - future = cm.getFieldAsync(const Symbol('staticGetter'));
|
| - expectValueThen(future, (result) {
|
| - Expect.equals('sget initial', result.reflectee);
|
| - });
|
| - future = cm.getFieldAsync(const Symbol('staticField'));
|
| - expectValueThen(future, (result) {
|
| - Expect.equals('initial', result.reflectee);
|
| - });
|
| - future = cm.getFieldAsync(const Symbol('doesntExist'));
|
| - expectError(future, isNoSuchMethodError, 'Not defined');
|
| -
|
| - // ClassMirror invokeSetter
|
| - future = cm.setFieldAsync(const Symbol('staticSetter'), 'sfoo');
|
| - expectValueThen(future, (result) {
|
| - Expect.equals('sfoo', result.reflectee);
|
| - Expect.equals('sset sfoo', C.staticField);
|
| - return cm.setFieldAsync(const Symbol('staticField'), 'sbar');
|
| - }).then((result) {
|
| - Expect.equals('sbar', result.reflectee);
|
| - Expect.equals('sbar', C.staticField);
|
| - return cm.setFieldAsync(const Symbol('staticField'), im);
|
| - }).then((result) {
|
| - Expect.equals(im.reflectee, result.reflectee);
|
| - Expect.equals(c, C.staticField);
|
| - });
|
| - future = cm.setFieldAsync(const Symbol('doesntExist'), 'sbar');
|
| - expectError(future, isNoSuchMethodError, 'Not defined');
|
| -
|
| - // ClassMirror invokeConstructor
|
| - future = cm.newInstanceAsync(const Symbol(''), []);
|
| - expectValueThen(future, (result) {
|
| - Expect.isTrue(result.reflectee is C);
|
| - Expect.equals('default', result.reflectee.field);
|
| - });
|
| - future = cm.newInstanceAsync(const Symbol('named'), ['my value']);
|
| - expectValueThen(future, (result) {
|
| - Expect.isTrue(result.reflectee is C);
|
| - Expect.equals('my value', result.reflectee.field);
|
| - });
|
| - future = cm.newInstanceAsync(const Symbol('named'), [im]);
|
| - expectValueThen(future, (result) {
|
| - Expect.isTrue(result.reflectee is C);
|
| - Expect.equals(c, result.reflectee.field);
|
| - });
|
| - future = cm.newInstanceAsync(const Symbol('doesntExist'), ['my value']);
|
| - expectError(future, isNoSuchMethodError, 'Not defined');
|
| - future = cm.newInstanceAsync(const Symbol('named'), []);
|
| - expectError(future, isNoSuchMethodError, 'Wrong arity');
|
| -
|
| -
|
| - // LibraryMirror invoke
|
| - LibraryMirror lm = cm.owner;
|
| - future = lm.invokeAsync(const Symbol('libraryFunction'),[':',')']);
|
| - expectValueThen(future, (result) {
|
| - Expect.equals(':)', result.reflectee);
|
| - });
|
| - future = lm.invokeAsync(const Symbol('libraryFunction'),[im,im]);
|
| - expectValueThen(future, (result) {
|
| - Expect.equals('a Ca C', result.reflectee);
|
| - });
|
| - future = lm.invokeAsync(const Symbol('doesntExist'),[im,im]);
|
| - expectError(future, isNoSuchMethodError, 'Not defined');
|
| - future = lm.invokeAsync(const Symbol('libraryFunction'),[':']);
|
| - expectError(future, isNoSuchMethodError, 'Wrong arity');
|
| -
|
| - // LibraryMirror invokeGetter
|
| - libraryField = 'a priori'; // Reset from synchronous test.
|
| - future = lm.getFieldAsync(const Symbol('libraryGetter'));
|
| - expectValueThen(future, (result) {
|
| - Expect.equals('lget a priori', result.reflectee);
|
| - });
|
| - future = lm.getFieldAsync(const Symbol('libraryField'));
|
| - expectValueThen(future, (result) {
|
| - Expect.equals('a priori', result.reflectee);
|
| - });
|
| - future = lm.getFieldAsync(const Symbol('doesntExist'));
|
| - expectError(future, isNoSuchMethodError, 'Not defined');
|
| -
|
| - // LibraryMirror invokeSetter
|
| - future = lm.setFieldAsync(const Symbol('librarySetter'), 'lfoo');
|
| - expectValueThen(future, (result) {
|
| - Expect.equals('lfoo', result.reflectee);
|
| - Expect.equals('lset lfoo', libraryField);
|
| - return lm.setFieldAsync(const Symbol('libraryField'), 'lbar');
|
| - }).then((result) {
|
| - Expect.equals('lbar', result.reflectee);
|
| - Expect.equals('lbar', libraryField);
|
| - return lm.setFieldAsync(const Symbol('libraryField'), im);
|
| - }).then((result) {
|
| - Expect.equals(im.reflectee, result.reflectee);
|
| - Expect.equals(c, libraryField);
|
| - });
|
| - future = lm.setFieldAsync(const Symbol('doesntExist'), 'lbar');
|
| - expectError(future, isNoSuchMethodError, 'Not defined');
|
| -}
|
| -
|
| main() {
|
| testSync();
|
| - testAsync();
|
| }
|
|
|