platform/packages/container/angel_container/test/mirrors_test.dart

27 lines
810 B
Dart
Raw Normal View History

2019-04-17 19:31:58 +00:00
import 'dart:async';
import 'package:angel_container/angel_container.dart';
2018-08-11 19:07:35 +00:00
import 'package:angel_container/mirrors.dart';
2019-04-17 19:31:58 +00:00
import 'package:test/test.dart';
2018-08-11 19:07:35 +00:00
import 'common.dart';
void main() {
testReflector(const MirrorsReflector());
2019-04-17 19:31:58 +00:00
test('futureOf', () {
var r = MirrorsReflector();
var fStr = r.reflectFutureOf(String);
expect(fStr.reflectedType.toString(), 'Future<String>');
// expect(fStr.reflectedType, Future<String>.value(null).runtimeType);
});
test('concrete future make', () async {
var c = Container(MirrorsReflector());
c.registerFactory<Future<String>>((_) async => 'hey');
var fStr = c.reflector.reflectFutureOf(String);
var s1 = await c.make(fStr.reflectedType);
var s2 = await c.makeAsync(String);
print([s1, s2]);
expect(s1, s2);
});
2018-08-11 19:07:35 +00:00
}