OLD | NEW |
| (Empty) |
1 library angular_spec; | |
2 | |
3 import '_specs.dart'; | |
4 import 'package:angular/utils.dart'; | |
5 | |
6 main() { | |
7 describe('angular.dart unittests', () { | |
8 it('should run in checked moded only', () { | |
9 expect(() { | |
10 dynamic v = 6; | |
11 String s = v; | |
12 }).toThrow(); | |
13 }); | |
14 }); | |
15 | |
16 describe('relaxFnApply', () { | |
17 it('should work with 6 arguments', () { | |
18 var sixArgs = [1, 1, 2, 3, 5, 8]; | |
19 expect(relaxFnApply(() => "none", sixArgs)).toEqual("none"); | |
20 expect(relaxFnApply((a) => a, sixArgs)).toEqual(1); | |
21 expect(relaxFnApply((a, b) => a + b, sixArgs)).toEqual(2); | |
22 expect(relaxFnApply((a, b, c) => a + b + c, sixArgs)).toEqual(4); | |
23 expect(relaxFnApply((a, b, c, d) => a + b + c + d, sixArgs)).toEqual(7); | |
24 expect(relaxFnApply((a, b, c, d, e) => a + b + c + d + e, sixArgs)).toEqua
l(12); | |
25 }); | |
26 | |
27 it('should work with 0 arguments', () { | |
28 var noArgs = []; | |
29 expect(relaxFnApply(() => "none", noArgs)).toEqual("none"); | |
30 expect(relaxFnApply(([a]) => a, noArgs)).toEqual(null); | |
31 expect(relaxFnApply(([a, b]) => b, noArgs)).toEqual(null); | |
32 expect(relaxFnApply(([a, b, c]) => c, noArgs)).toEqual(null); | |
33 expect(relaxFnApply(([a, b, c, d]) => d, noArgs)).toEqual(null); | |
34 expect(relaxFnApply(([a, b, c, d, e]) => e, noArgs)).toEqual(null); | |
35 }); | |
36 | |
37 it('should fail with not enough arguments', () { | |
38 expect(() { | |
39 relaxFnApply((required, alsoRequired) => "happy", [1]); | |
40 }).toThrow('Unknown function type, expecting 0 to 5 args.'); | |
41 }); | |
42 }); | |
43 } | |
OLD | NEW |