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

Side by Side Diff: tests/corelib_strong/hash_set_type_check_test.dart

Issue 2990623002: Migrate test block 9 to Dart 2.0 (Closed)
Patch Set: nits Created 3 years, 4 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 | « tests/corelib_strong/hash_map_test.dart ('k') | tests/corelib_strong/hashcode_boxed_test.dart » ('j') | 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) 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
3 // BSD-style license that can be found in the LICENSE file.
4
5 // Tests of hash set type checking.
6
7 library hash_set_type_check_test;
8
9 import "package:expect/expect.dart";
10 import 'dart:collection';
11
12 testSet(Set<String> newSet()) {
13 Set<String> s = newSet();
14 Expect.throws(() => s.add(1), (e) => e is Error);
15 Expect.isNull(s.lookup(1));
16 }
17
18 void testIdentitySet(Set create()) {
19 Set<String> s = create();
20 Expect.throws(() => s.add(1), (e) => e is Error);
21 Expect.isNull(s.lookup(1));
22 }
23
24 bool get inCheckedMode {
25 try {
26 var i = 1;
27 String j = i;
28 } catch (_) {
29 return true;
30 }
31 return false;
32 }
33
34 void main() {
35 if (!inCheckedMode) return;
36
37 testSet(() => new Set<String>());
38 testSet(() => new HashSet<String>());
39 testSet(() => new LinkedHashSet<String>());
40 testIdentitySet(() => new Set<String>.identity());
41 testIdentitySet(() => new HashSet<String>.identity());
42 testIdentitySet(() => new LinkedHashSet<String>.identity());
43 testIdentitySet(() => new HashSet<String>(
44 equals: (x, y) => identical(x, y), hashCode: (x) => identityHashCode(x)));
45 testIdentitySet(() => new LinkedHashSet<String>(
46 equals: (x, y) => identical(x, y), hashCode: (x) => identityHashCode(x)));
47 }
OLDNEW
« no previous file with comments | « tests/corelib_strong/hash_map_test.dart ('k') | tests/corelib_strong/hashcode_boxed_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698