OLD | NEW |
1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file | 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 | 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 import "package:expect/expect.dart"; | 5 import "package:expect/expect.dart"; |
6 | 6 |
7 // Test that error constructors do what they are documented as doing. | 7 // Test that error constructors do what they are documented as doing. |
8 | 8 |
9 main() { | 9 main() { |
10 Expect.equals("Invalid argument(s)", | 10 Expect.equals("Invalid argument(s)", new ArgumentError().toString()); |
11 new ArgumentError().toString()); | 11 Expect.equals( |
12 Expect.equals("Invalid argument(s): message", | 12 "Invalid argument(s): message", new ArgumentError("message").toString()); |
13 new ArgumentError("message").toString()); | 13 Expect.equals( |
14 Expect.equals("Invalid argument: null", | 14 "Invalid argument: null", new ArgumentError.value(null).toString()); |
15 new ArgumentError.value(null).toString()); | 15 Expect.equals("Invalid argument: 42", new ArgumentError.value(42).toString()); |
16 Expect.equals("Invalid argument: 42", | 16 Expect.equals( |
17 new ArgumentError.value(42).toString()); | 17 "Invalid argument: \"bad\"", new ArgumentError.value("bad").toString()); |
18 Expect.equals("Invalid argument: \"bad\"", | |
19 new ArgumentError.value("bad").toString()); | |
20 Expect.equals("Invalid argument (foo): null", | 18 Expect.equals("Invalid argument (foo): null", |
21 new ArgumentError.value(null, "foo").toString()); | 19 new ArgumentError.value(null, "foo").toString()); |
22 Expect.equals("Invalid argument (foo): 42", | 20 Expect.equals("Invalid argument (foo): 42", |
23 new ArgumentError.value(42, "foo").toString()); | 21 new ArgumentError.value(42, "foo").toString()); |
24 Expect.equals("Invalid argument (foo): message: 42", | 22 Expect.equals("Invalid argument (foo): message: 42", |
25 new ArgumentError.value(42, "foo", "message").toString()); | 23 new ArgumentError.value(42, "foo", "message").toString()); |
26 Expect.equals("Invalid argument: message: 42", | 24 Expect.equals("Invalid argument: message: 42", |
27 new ArgumentError.value(42, null, "message").toString()); | 25 new ArgumentError.value(42, null, "message").toString()); |
28 Expect.equals("Invalid argument(s): Must not be null", | 26 Expect.equals("Invalid argument(s): Must not be null", |
29 new ArgumentError.notNull().toString()); | 27 new ArgumentError.notNull().toString()); |
30 Expect.equals("Invalid argument(s) (foo): Must not be null", | 28 Expect.equals("Invalid argument(s) (foo): Must not be null", |
31 new ArgumentError.notNull("foo").toString()); | 29 new ArgumentError.notNull("foo").toString()); |
32 | 30 |
33 Expect.equals("RangeError", | 31 Expect.equals("RangeError", new RangeError(null).toString()); |
34 new RangeError(null).toString()); | 32 Expect.equals("RangeError: message", new RangeError("message").toString()); |
35 Expect.equals("RangeError: message", | |
36 new RangeError("message").toString()); | |
37 Expect.equals("RangeError: Value not in range: 42", | 33 Expect.equals("RangeError: Value not in range: 42", |
38 new RangeError.value(42).toString()); | 34 new RangeError.value(42).toString()); |
39 Expect.equals("RangeError (foo): Value not in range: 42", | 35 Expect.equals("RangeError (foo): Value not in range: 42", |
40 new RangeError.value(42, "foo").toString()); | 36 new RangeError.value(42, "foo").toString()); |
41 Expect.equals("RangeError (foo): message: 42", | 37 Expect.equals("RangeError (foo): message: 42", |
42 new RangeError.value(42, "foo", "message").toString()); | 38 new RangeError.value(42, "foo", "message").toString()); |
43 Expect.equals("RangeError: message: 42", | 39 Expect.equals("RangeError: message: 42", |
44 new RangeError.value(42, null, "message").toString()); | 40 new RangeError.value(42, null, "message").toString()); |
45 | 41 |
46 Expect.equals("RangeError: Invalid value: Not in range 2..9, inclusive: 42", | 42 Expect.equals("RangeError: Invalid value: Not in range 2..9, inclusive: 42", |
47 new RangeError.range(42, 2, 9).toString()); | 43 new RangeError.range(42, 2, 9).toString()); |
48 Expect.equals("RangeError (foo): Invalid value: Not in range 2..9, " | 44 Expect.equals( |
49 "inclusive: 42", | 45 "RangeError (foo): Invalid value: Not in range 2..9, " |
50 new RangeError.range(42, 2, 9, "foo").toString()); | 46 "inclusive: 42", |
| 47 new RangeError.range(42, 2, 9, "foo").toString()); |
51 Expect.equals("RangeError (foo): message: Not in range 2..9, inclusive: 42", | 48 Expect.equals("RangeError (foo): message: Not in range 2..9, inclusive: 42", |
52 new RangeError.range(42, 2, 9, "foo", "message").toString()); | 49 new RangeError.range(42, 2, 9, "foo", "message").toString()); |
53 Expect.equals("RangeError: message: Not in range 2..9, inclusive: 42", | 50 Expect.equals("RangeError: message: Not in range 2..9, inclusive: 42", |
54 new RangeError.range(42, 2, 9, null, "message").toString()); | 51 new RangeError.range(42, 2, 9, null, "message").toString()); |
55 | 52 |
56 Expect.equals("RangeError: Index out of range: " | 53 Expect.equals( |
57 "index should be less than 3: 42", | 54 "RangeError: Index out of range: " |
58 new RangeError.index(42, [1, 2, 3]).toString()); | 55 "index should be less than 3: 42", |
59 Expect.equals("RangeError (foo): Index out of range: " | 56 new RangeError.index(42, [1, 2, 3]).toString()); |
60 "index should be less than 3: 42", | 57 Expect.equals( |
61 new RangeError.index(42, [1, 2, 3], "foo").toString()); | 58 "RangeError (foo): Index out of range: " |
62 Expect.equals("RangeError (foo): message: " | 59 "index should be less than 3: 42", |
63 "index should be less than 3: 42", | 60 new RangeError.index(42, [1, 2, 3], "foo").toString()); |
64 new RangeError.index(42, [1, 2, 3], | 61 Expect.equals( |
65 "foo", "message").toString()); | 62 "RangeError (foo): message: " |
66 Expect.equals("RangeError: message: " | 63 "index should be less than 3: 42", |
67 "index should be less than 3: 42", | 64 new RangeError.index(42, [1, 2, 3], "foo", "message").toString()); |
68 new RangeError.index(42, [1, 2, 3], | 65 Expect.equals( |
69 null, "message").toString()); | 66 "RangeError: message: " |
70 Expect.equals("RangeError (foo): message: " | 67 "index should be less than 3: 42", |
71 "index should be less than 2: 42", | 68 new RangeError.index(42, [1, 2, 3], null, "message").toString()); |
72 new RangeError.index(42, [1, 2, 3], | 69 Expect.equals( |
73 "foo", "message", 2).toString()); | 70 "RangeError (foo): message: " |
74 Expect.equals("RangeError: Index out of range: " | 71 "index should be less than 2: 42", |
75 "index must not be negative: -5", | 72 new RangeError.index(42, [1, 2, 3], "foo", "message", 2).toString()); |
76 new RangeError.index(-5, [1, 2, 3]).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 } | 77 } |
OLD | NEW |