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

Side by Side Diff: test/tuple_test.dart

Issue 2939773003: Initialize dart-lang/tuple with the tuple package at v1.0.1. (Closed)
Patch Set: Created 3 years, 6 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 | « test/all_tests.dart ('k') | tool/travis.sh » ('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 tuple project authors. Please see the AUTHORS
2 // file for details. All rights reserved. Use of this source code is governed
3 // by a BSD-style license that can be found in the LICENSE file.
4
5 library tuple.test;
6
7 import 'package:test/test.dart';
8 import 'package:tuple/tuple.dart';
9
10 main() {
11 group("Tuple tests", () {
12 final t = new Tuple2<int, bool>(1, true);
13
14 test('items', () {
15 expect(t.item1, equals(1));
16 expect(t.item2, equals(true));
17 });
18
19 test('withItems', () {
20 expect(t.withItem1(2), equals(new Tuple2<int, bool>(2, true)));
21 expect(t.withItem2(false), equals(new Tuple2<int, bool>(1, false)));
22 });
23
24 test('create a tuple from a list of items', () {
25 final t1 = new Tuple2.fromList([1, true]);
26 expect(t1.item1, equals(1));
27 expect(t1.item2, equals(true));
28
29 expect(() => new Tuple2.fromList([1]), throwsA(new isInstanceOf<ArgumentEr ror>()));
30 expect(() => new Tuple2.fromList([1, true, 'a']), throwsA(new isInstanceOf <ArgumentError>()));
31 });
32
33 test('equality', () {
34 final otherT = new Tuple2<int, bool>(1, true);
35 expect(t, equals(otherT));
36 });
37
38 test('nested equality', () {
39 final t1 = new Tuple2<Tuple2<int, String>, bool>(
40 new Tuple2<int, String>(3, 'a'), false);
41 final t2 = new Tuple2<Tuple2<int, String>, bool>(
42 new Tuple2<int, String>(3, 'a'), false);
43 expect(t1, equals(t2));
44 });
45
46 test('can be used as keys in maps', () {
47 final map = {t: 'a'};
48 final key = new Tuple2<int, bool>(1, true);
49 expect(map[key], equals('a'));
50 });
51
52 test('toList() should return a listing containing the items of the tuple',
53 () {
54 expect(t.toList(), orderedEquals([1, true]));
55 });
56
57 test('toList() should return a fixed list by default', () {
58 expect(() => t.toList().add(3),
59 throwsA(new isInstanceOf<UnsupportedError>()));
60 });
61
62 test('toList(growable: true) should return a growable list', () {
63 expect(t.toList(growable: true)..add('a'), orderedEquals([1, true, 'a']));
64 });
65 });
66 }
OLDNEW
« no previous file with comments | « test/all_tests.dart ('k') | tool/travis.sh » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698