OLD | NEW |
1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file |
2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
4 | 4 |
5 import 'package:lookup_map/lookup_map.dart'; | 5 import 'package:lookup_map/lookup_map.dart'; |
6 | 6 |
7 import 'package:test/test.dart'; | 7 import 'package:test/test.dart'; |
8 | 8 |
9 class Key { | 9 class Key { |
10 final int id; | 10 final int id; |
(...skipping 11 matching lines...) Expand all Loading... |
22 B, "the-text-for-B", | 22 B, "the-text-for-B", |
23 1.2, "the-text-for-1.2"]); | 23 1.2, "the-text-for-1.2"]); |
24 expect(m[A], 'the-text-for-A'); | 24 expect(m[A], 'the-text-for-A'); |
25 expect(m[B], 'the-text-for-B'); | 25 expect(m[B], 'the-text-for-B'); |
26 expect(m[1.2], 'the-text-for-1.2'); | 26 expect(m[1.2], 'the-text-for-1.2'); |
27 expect(m[C], null); | 27 expect(m[C], null); |
28 expect(m[1.3], null); | 28 expect(m[1.3], null); |
29 }); | 29 }); |
30 | 30 |
31 test('pair constructor', () { | 31 test('pair constructor', () { |
32 var m = const LookupMap.pair(A, "the-text-for-A"); | 32 var m = const LookupMap<dynamic, String>.pair(A, "the-text-for-A"); |
33 expect(m[A], 'the-text-for-A'); | 33 expect(m[A], 'the-text-for-A'); |
34 expect(m[B], null); | 34 expect(m[B], null); |
35 }); | 35 }); |
36 | 36 |
37 test('nested lookup', () { | 37 test('nested lookup', () { |
38 var m = const LookupMap(const [], | 38 var m = const LookupMap(const [], |
39 const [const LookupMap.pair(A, "the-text-for-A")]); | 39 const [const LookupMap<dynamic, String>.pair(A, "the-text-for-A")]); |
40 expect(m[A], 'the-text-for-A'); | 40 expect(m[A], 'the-text-for-A'); |
41 expect(m[B], null); | 41 expect(m[B], null); |
42 }); | 42 }); |
43 | 43 |
44 test('entry shadows nested maps', () { | 44 test('entry shadows nested maps', () { |
45 var m = const LookupMap(const [ | 45 var m = const LookupMap(const [ |
46 A, "the-text-for-A2", | 46 A, "the-text-for-A2", |
47 ], const [ | 47 ], const [ |
48 const LookupMap.pair(A, "the-text-for-A1"), | 48 const LookupMap.pair(A, "the-text-for-A1"), |
49 ]); | 49 ]); |
(...skipping 15 matching lines...) Expand all Loading... |
65 // sanity. | 65 // sanity. |
66 test('reachable lookups are not tree-shaken', () { | 66 test('reachable lookups are not tree-shaken', () { |
67 var m = const LookupMap(const [ | 67 var m = const LookupMap(const [ |
68 A, B, | 68 A, B, |
69 B, C, | 69 B, C, |
70 C, 3.4, | 70 C, 3.4, |
71 ]); | 71 ]); |
72 expect(m[m[m[A]]], 3.4); | 72 expect(m[m[m[A]]], 3.4); |
73 }); | 73 }); |
74 } | 74 } |
OLD | NEW |