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

Side by Side Diff: pkg/barback/test/mutliset_test.dart

Issue 26598002: Track the original assets more efficiently in Phase. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Code review changes. Created 7 years, 2 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 | Annotate | Revision Log
« no previous file with comments | « pkg/barback/lib/src/phase.dart ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
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.
4
5 library barback.test.multiset_test;
6
7 import 'dart:async';
8
9 import 'package:barback/src/multiset.dart';
10 import 'package:unittest/unittest.dart';
11
12 import 'utils.dart';
13
14 main() {
15 initConfig();
16
17 test("new Multiset() creates an empty set", () {
18 var multiSet = new Multiset();
19 expect(multiSet, isEmpty);
20 expect(multiSet.contains(1), isFalse);
21 expect(multiSet.count(1), equals(0));
22 });
23
24 test("new Multiset.from(...) constructs a set from the argument", () {
25 var multiSet = new Multiset.from([1, 2, 3, 2, 4]);
26 expect(multiSet.toList(), equals([1, 2, 2, 3, 4]));
27 expect(multiSet.contains(1), isTrue);
28 expect(multiSet.contains(5), isFalse);
29 expect(multiSet.count(1), equals(1));
30 expect(multiSet.count(2), equals(2));
31 expect(multiSet.count(5), equals(0));
32 });
33
34 test("an element can be added and removed once", () {
35 var multiSet = new Multiset();
36 expect(multiSet.contains(1), isFalse);
37 multiSet.add(1);
38 expect(multiSet.contains(1), isTrue);
39 multiSet.remove(1);
40 expect(multiSet.contains(1), isFalse);
41 });
42
43 test("a set can contain multiple copies of an element", () {
44 var multiSet = new Multiset();
45 expect(multiSet.count(1), equals(0));
46 multiSet.add(1);
47 expect(multiSet.count(1), equals(1));
48 multiSet.add(1);
49 expect(multiSet.count(1), equals(2));
50 multiSet.remove(1);
51 expect(multiSet.count(1), equals(1));
52 multiSet.remove(1);
53 expect(multiSet.count(1), equals(0));
54 });
55
56 test("remove returns false if the element wasn't in the set", () {
57 var multiSet = new Multiset();
58 expect(multiSet.remove(1), isFalse);
59 });
60
61 test("remove returns true if the element was in the set", () {
62 var multiSet = new Multiset.from([1]);
63 expect(multiSet.remove(1), isTrue);
64 });
65
66 test("remove returns true if the element was in the set even if more copies "
67 "remain", () {
68 var multiSet = new Multiset.from([1, 1, 1]);
69 expect(multiSet.remove(1), isTrue);
70 });
71
72 test("iterator orders distinct elements in insertion order", () {
73 var multiSet = new Multiset()..add(1)..add(2)..add(3)..add(4)..add(5);
74 expect(multiSet.toList(), equals([1, 2, 3, 4, 5]));
75 });
76
77 test("iterator groups multiple copies of an element together", () {
78 var multiSet = new Multiset()..add(1)..add(2)..add(1)..add(2)..add(1);
79 expect(multiSet.toList(), equals([1, 1, 1, 2, 2]));
80 });
81 }
OLDNEW
« no previous file with comments | « pkg/barback/lib/src/phase.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698