Created
March 16, 2015 10:01
-
-
Save Pajn/73b9d504524fad78ebb5 to your computer and use it in GitHub Desktop.
Test Darts TypeMirror isAssignableTo
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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