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

Side by Side Diff: tests/corelib/errors_test.dart

Issue 953743005: Fix bug in RangeError.value. Add tests. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 5 years, 10 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
« sdk/lib/core/errors.dart ('K') | « sdk/lib/core/errors.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) 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 import "package:expect/expect.dart";
6
7 // Test that error constructors do what they are documented as doing.
8
9 main() {
10 Expect.equals("Invalid argument(s)",
11 new ArgumentError().toString());
12 Expect.equals("Invalid argument(s): message",
13 new ArgumentError("message").toString());
14 Expect.equals("Invalid argument: null",
15 new ArgumentError.value(null).toString());
16 Expect.equals("Invalid argument (foo): null",
17 new ArgumentError.value(null, "foo").toString());
18 Expect.equals("Invalid argument (foo): 42",
19 new ArgumentError.value(42, "foo").toString());
20 Expect.equals("Invalid argument (foo): message: 42",
21 new ArgumentError.value(42, "foo", "message").toString());
22 Expect.equals("Invalid argument: message: 42",
23 new ArgumentError.value(42, null, "message").toString());
24 Expect.equals("Invalid argument: Must not be null: null",
25 new ArgumentError.notNull().toString());
26 Expect.equals("Invalid argument (foo): Must not be null: null",
27 new ArgumentError.notNull("foo").toString());
28
29 Expect.equals("RangeError",
30 new RangeError(null).toString());
31 Expect.equals("RangeError: message",
32 new RangeError("message").toString());
33 Expect.equals("RangeError: Value not in range: 42",
34 new RangeError.value(42).toString());
35 Expect.equals("RangeError (foo): Value not in range: 42",
36 new RangeError.value(42, "foo").toString());
37 Expect.equals("RangeError (foo): message: 42",
38 new RangeError.value(42, "foo", "message").toString());
39 Expect.equals("RangeError: message: 42",
40 new RangeError.value(42, null, "message").toString());
41
42 Expect.equals("RangeError: Invalid value: Not in range 2..9, inclusive: 42",
43 new RangeError.range(42, 2, 9).toString());
44 Expect.equals("RangeError (foo): Invalid value: Not in range 2..9, "
45 "inclusive: 42",
46 new RangeError.range(42, 2, 9, "foo").toString());
47 Expect.equals("RangeError (foo): message: Not in range 2..9, inclusive: 42",
48 new RangeError.range(42, 2, 9, "foo", "message").toString());
49 Expect.equals("RangeError: message: Not in range 2..9, inclusive: 42",
50 new RangeError.range(42, 2, 9, null, "message").toString());
51
52 Expect.equals("RangeError: Index out of range: "
53 "index should be less than 3: 42",
54 new RangeError.index(42, [1, 2, 3]).toString());
55 Expect.equals("RangeError (foo): Index out of range: "
56 "index should be less than 3: 42",
57 new RangeError.index(42, [1, 2, 3], "foo").toString());
58 Expect.equals("RangeError (foo): message: "
59 "index should be less than 3: 42",
60 new RangeError.index(42, [1, 2, 3],
61 "foo", "message").toString());
62 Expect.equals("RangeError: message: "
63 "index should be less than 3: 42",
64 new RangeError.index(42, [1, 2, 3],
65 null, "message").toString());
66 Expect.equals("RangeError (foo): message: "
67 "index should be less than 2: 42",
68 new RangeError.index(42, [1, 2, 3],
69 "foo", "message", 2).toString());
70 Expect.equals("RangeError: Index out of range: "
71 "index must not be negative: -5",
72 new RangeError.index(-5, [1, 2, 3]).toString());
73 }
OLDNEW
« sdk/lib/core/errors.dart ('K') | « sdk/lib/core/errors.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698