Skip to content

Instantly share code, notes, and snippets.

@Pajn
Created March 16, 2015 10:01
Show Gist options
  • Save Pajn/73b9d504524fad78ebb5 to your computer and use it in GitHub Desktop.
Save Pajn/73b9d504524fad78ebb5 to your computer and use it in GitHub Desktop.
Test Darts TypeMirror isAssignableTo
import 'dart:mirrors';
import 'package:guinness/guinness.dart';
class Test {
Iterable iterable;
Iterable<int> typedIterable;
}
main() {
describe('Dart', () {
Test test;
beforeEach(() => test = new Test());
it('A list should be assignable to am Iterable', () {
test.iterable = [2,3];
expect(test.iterable).toEqual([2,3]);
});
it('A not typed list should be assignable to a typed Iterable', () {
test.typedIterable = [2,3];
expect(test.typedIterable).toEqual([2,3]);
});
describe('Mirrors', () {
it('A list should be assignable to an Iterable', () {
var iterable = reflectClass(Test).declarations[#iterable].type;
var list = reflectType(List);
expect(list.isAssignableTo(iterable)).toBeTrue();
});
it('A not typed list should be assignable to a typed Iterable', () {
var iterable = reflectClass(Test).declarations[#typedIterable].type;
var list = reflectType(List);
expect(list.isAssignableTo(iterable)).toBeTrue();
});
});
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment