OLD | NEW |
1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2011, 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 library ElementTest; | 5 library ElementTest; |
6 import '../../pkg/unittest/lib/unittest.dart'; | 6 import '../../pkg/unittest/lib/unittest.dart'; |
7 import '../../pkg/unittest/lib/html_config.dart'; | 7 import '../../pkg/unittest/lib/html_config.dart'; |
8 import 'dart:html'; | 8 import 'dart:html'; |
9 | 9 |
10 main() { | 10 main() { |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
59 }); | 59 }); |
60 | 60 |
61 test('iterator', () { | 61 test('iterator', () { |
62 final classes = <String>[]; | 62 final classes = <String>[]; |
63 for (var el in makeClassSet()) { | 63 for (var el in makeClassSet()) { |
64 classes.add(el); | 64 classes.add(el); |
65 } | 65 } |
66 expect(classes, unorderedEquals(['foo', 'bar', 'baz'])); | 66 expect(classes, unorderedEquals(['foo', 'bar', 'baz'])); |
67 }); | 67 }); |
68 | 68 |
69 test('map', () { | 69 test('mappedBy', () { |
70 expect(makeClassSet().map((c) => c.toUpperCase()), | 70 expect(makeClassSet().mappedBy((c) => c.toUpperCase()).toList(), |
71 unorderedEquals(['FOO', 'BAR', 'BAZ'])); | 71 unorderedEquals(['FOO', 'BAR', 'BAZ'])); |
72 }); | 72 }); |
73 | 73 |
74 test('filter', () { | 74 test('where', () { |
75 expect(makeClassSet().filter((c) => c.contains('a')), | 75 expect(makeClassSet().where((c) => c.contains('a')).toSet(), |
76 unorderedEquals(['bar', 'baz'])); | 76 unorderedEquals(['bar', 'baz'])); |
77 }); | 77 }); |
78 | 78 |
79 test('every', () { | 79 test('every', () { |
80 expect(makeClassSet().every((c) => c is String), isTrue); | 80 expect(makeClassSet().every((c) => c is String), isTrue); |
81 expect(makeClassSet().every((c) => c.contains('a')), isFalse); | 81 expect(makeClassSet().every((c) => c.contains('a')), isFalse); |
82 }); | 82 }); |
83 | 83 |
84 test('some', () { | 84 test('any', () { |
85 expect(makeClassSet().some((c) => c.contains('a')), isTrue); | 85 expect(makeClassSet().any((c) => c.contains('a')), isTrue); |
86 expect(makeClassSet().some((c) => c is num), isFalse); | 86 expect(makeClassSet().any((c) => c is num), isFalse); |
87 }); | 87 }); |
88 | 88 |
89 test('isEmpty', () { | 89 test('isEmpty', () { |
90 expect(makeClassSet().isEmpty, isFalse); | 90 expect(makeClassSet().isEmpty, isFalse); |
91 expect(makeElement().classes.isEmpty, isTrue); | 91 expect(makeElement().classes.isEmpty, isTrue); |
92 }); | 92 }); |
93 | 93 |
94 test('length', () { | 94 test('length', () { |
95 expect(makeClassSet().length, 3); | 95 expect(makeClassSet().length, 3); |
96 expect(makeElement().classes.length, 0); | 96 expect(makeElement().classes.length, 0); |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
159 expect(classes.intersection(['foo', 'qux', 'baz']), | 159 expect(classes.intersection(['foo', 'qux', 'baz']), |
160 unorderedEquals(['foo', 'baz'])); | 160 unorderedEquals(['foo', 'baz'])); |
161 }); | 161 }); |
162 | 162 |
163 test('clear', () { | 163 test('clear', () { |
164 final classes = makeClassSet(); | 164 final classes = makeClassSet(); |
165 classes.clear(); | 165 classes.clear(); |
166 expect(classes, equals([])); | 166 expect(classes, equals([])); |
167 }); | 167 }); |
168 } | 168 } |
OLD | NEW |