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

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

Issue 3004073002: Remove corelib/corelib_strong and migrate last two remaining tests. (Closed)
Patch Set: Created 3 years, 3 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
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)", new ArgumentError().toString());
11 Expect.equals(
12 "Invalid argument(s): message", new ArgumentError("message").toString());
13 Expect.equals(
14 "Invalid argument: null", new ArgumentError.value(null).toString());
15 Expect.equals("Invalid argument: 42", new ArgumentError.value(42).toString());
16 Expect.equals(
17 "Invalid argument: \"bad\"", new ArgumentError.value("bad").toString());
18 Expect.equals("Invalid argument (foo): null",
19 new ArgumentError.value(null, "foo").toString());
20 Expect.equals("Invalid argument (foo): 42",
21 new ArgumentError.value(42, "foo").toString());
22 Expect.equals("Invalid argument (foo): message: 42",
23 new ArgumentError.value(42, "foo", "message").toString());
24 Expect.equals("Invalid argument: message: 42",
25 new ArgumentError.value(42, null, "message").toString());
26 Expect.equals("Invalid argument(s): Must not be null",
27 new ArgumentError.notNull().toString());
28 Expect.equals("Invalid argument(s) (foo): Must not be null",
29 new ArgumentError.notNull("foo").toString());
30
31 Expect.equals("RangeError", new RangeError(null).toString());
32 Expect.equals("RangeError: message", 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(
45 "RangeError (foo): Invalid value: Not in range 2..9, "
46 "inclusive: 42",
47 new RangeError.range(42, 2, 9, "foo").toString());
48 Expect.equals("RangeError (foo): message: Not in range 2..9, inclusive: 42",
49 new RangeError.range(42, 2, 9, "foo", "message").toString());
50 Expect.equals("RangeError: message: Not in range 2..9, inclusive: 42",
51 new RangeError.range(42, 2, 9, null, "message").toString());
52
53 Expect.equals(
54 "RangeError: Index out of range: "
55 "index should be less than 3: 42",
56 new RangeError.index(42, [1, 2, 3]).toString());
57 Expect.equals(
58 "RangeError (foo): Index out of range: "
59 "index should be less than 3: 42",
60 new RangeError.index(42, [1, 2, 3], "foo").toString());
61 Expect.equals(
62 "RangeError (foo): message: "
63 "index should be less than 3: 42",
64 new RangeError.index(42, [1, 2, 3], "foo", "message").toString());
65 Expect.equals(
66 "RangeError: message: "
67 "index should be less than 3: 42",
68 new RangeError.index(42, [1, 2, 3], null, "message").toString());
69 Expect.equals(
70 "RangeError (foo): message: "
71 "index should be less than 2: 42",
72 new RangeError.index(42, [1, 2, 3], "foo", "message", 2).toString());
73 Expect.equals(
74 "RangeError: Index out of range: "
75 "index must not be negative: -5",
76 new RangeError.index(-5, [1, 2, 3]).toString());
77 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698