Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(178)

Side by Side Diff: pkg/lookup_map/test/lookup_map_test.dart

Issue 2743423009: Run dartfmt on remaining unformated pkg packages (Closed)
Patch Set: Run dartfmt on remaining unformated pkg packages Created 3 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « pkg/lookup_map/lib/lookup_map.dart ('k') | pkg/testing/lib/src/analyze.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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;
11 const Key(this.id); 11 const Key(this.id);
12 } 12 }
13 13
14 class A{} 14 class A {}
15
15 const B = const Key(1); 16 const B = const Key(1);
16 class C{} 17
18 class C {}
17 19
18 main() { 20 main() {
19 test('entries constructor', () { 21 test('entries constructor', () {
20 var m = const LookupMap(const [ 22 var m = const LookupMap(const [
21 A, "the-text-for-A", 23 A,
22 B, "the-text-for-B", 24 "the-text-for-A",
23 1.2, "the-text-for-1.2"]); 25 B,
26 "the-text-for-B",
27 1.2,
28 "the-text-for-1.2"
29 ]);
24 expect(m[A], 'the-text-for-A'); 30 expect(m[A], 'the-text-for-A');
25 expect(m[B], 'the-text-for-B'); 31 expect(m[B], 'the-text-for-B');
26 expect(m[1.2], 'the-text-for-1.2'); 32 expect(m[1.2], 'the-text-for-1.2');
27 expect(m[C], null); 33 expect(m[C], null);
28 expect(m[1.3], null); 34 expect(m[1.3], null);
29 }); 35 });
30 36
31 test('pair constructor', () { 37 test('pair constructor', () {
32 var m = const LookupMap<dynamic, String>.pair(A, "the-text-for-A"); 38 var m = const LookupMap<dynamic, String>.pair(A, "the-text-for-A");
33 expect(m[A], 'the-text-for-A'); 39 expect(m[A], 'the-text-for-A');
34 expect(m[B], null); 40 expect(m[B], null);
35 }); 41 });
36 42
37 test('nested lookup', () { 43 test('nested lookup', () {
38 var m = const LookupMap(const [], 44 var m = const LookupMap(const [],
39 const [const LookupMap<dynamic, String>.pair(A, "the-text-for-A")]); 45 const [const LookupMap<dynamic, String>.pair(A, "the-text-for-A")]);
40 expect(m[A], 'the-text-for-A'); 46 expect(m[A], 'the-text-for-A');
41 expect(m[B], null); 47 expect(m[B], null);
42 }); 48 });
43 49
44 test('entry shadows nested maps', () { 50 test('entry shadows nested maps', () {
45 var m = const LookupMap(const [ 51 var m = const LookupMap(const [
46 A, "the-text-for-A2", 52 A,
53 "the-text-for-A2",
47 ], const [ 54 ], const [
48 const LookupMap.pair(A, "the-text-for-A1"), 55 const LookupMap.pair(A, "the-text-for-A1"),
49 ]); 56 ]);
50 expect(m[A], 'the-text-for-A2'); 57 expect(m[A], 'the-text-for-A2');
51 }); 58 });
52 59
53 test('nested maps shadow in order', () { 60 test('nested maps shadow in order', () {
54 var m = const LookupMap(const [ ], const [ 61 var m = const LookupMap(const [], const [
55 const LookupMap.pair(A, "the-text-for-A1"), 62 const LookupMap.pair(A, "the-text-for-A1"),
56 const LookupMap.pair(B, "the-text-for-B2"), 63 const LookupMap.pair(B, "the-text-for-B2"),
57 const LookupMap.pair(A, "the-text-for-A2"), 64 const LookupMap.pair(A, "the-text-for-A2"),
58 const LookupMap.pair(B, "the-text-for-B1"), 65 const LookupMap.pair(B, "the-text-for-B1"),
59 ]); 66 ]);
60 expect(m[A], 'the-text-for-A2'); 67 expect(m[A], 'the-text-for-A2');
61 expect(m[B], 'the-text-for-B1'); 68 expect(m[B], 'the-text-for-B1');
62 }); 69 });
63 70
64 // This test would fail if dart2js has a bug, but we keep it here for our 71 // This test would fail if dart2js has a bug, but we keep it here for our
65 // sanity. 72 // sanity.
66 test('reachable lookups are not tree-shaken', () { 73 test('reachable lookups are not tree-shaken', () {
67 var m = const LookupMap(const [ 74 var m = const LookupMap(const [
68 A, B, 75 A,
69 B, C, 76 B,
70 C, 3.4, 77 B,
78 C,
79 C,
80 3.4,
71 ]); 81 ]);
72 expect(m[m[m[A]]], 3.4); 82 expect(m[m[m[A]]], 3.4);
73 }); 83 });
74 } 84 }
OLDNEW
« no previous file with comments | « pkg/lookup_map/lib/lookup_map.dart ('k') | pkg/testing/lib/src/analyze.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698