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)", |
11 new ArgumentError().toString()); | 11 new ArgumentError().toString()); |
12 Expect.equals("Invalid argument(s): message", | 12 Expect.equals("Invalid argument(s): message", |
13 new ArgumentError("message").toString()); | 13 new ArgumentError("message").toString()); |
14 Expect.equals("Invalid argument: null", | 14 Expect.equals("Invalid argument: null", |
15 new ArgumentError.value(null).toString()); | 15 new ArgumentError.value(null).toString()); |
16 Expect.equals("Invalid argument: 42", | 16 Expect.equals("Invalid argument: 42", |
17 new ArgumentError.value(42).toString()); | 17 new ArgumentError.value(42).toString()); |
18 Expect.equals("Invalid argument: \"bad\"", | 18 Expect.equals("Invalid argument: \"bad\"", |
19 new ArgumentError.value("bad").toString()); | 19 new ArgumentError.value("bad").toString()); |
20 Expect.equals("Invalid argument (foo): null", | 20 Expect.equals("Invalid argument (foo): null", |
21 new ArgumentError.value(null, "foo").toString()); | 21 new ArgumentError.value(null, "foo").toString()); |
22 Expect.equals("Invalid argument (foo): 42", | 22 Expect.equals("Invalid argument (foo): 42", |
23 new ArgumentError.value(42, "foo").toString()); | 23 new ArgumentError.value(42, "foo").toString()); |
24 Expect.equals("Invalid argument (foo): message: 42", | 24 Expect.equals("Invalid argument (foo): message: 42", |
25 new ArgumentError.value(42, "foo", "message").toString()); | 25 new ArgumentError.value(42, "foo", "message").toString()); |
26 Expect.equals("Invalid argument: message: 42", | 26 Expect.equals("Invalid argument: message: 42", |
27 new ArgumentError.value(42, null, "message").toString()); | 27 new ArgumentError.value(42, null, "message").toString()); |
28 Expect.equals("Invalid argument: Must not be null: null", | 28 Expect.equals("Invalid argument(s): Must not be null", |
29 new ArgumentError.notNull().toString()); | 29 new ArgumentError.notNull().toString()); |
30 Expect.equals("Invalid argument (foo): Must not be null: null", | 30 Expect.equals("Invalid argument(s) (foo): Must not be null", |
31 new ArgumentError.notNull("foo").toString()); | 31 new ArgumentError.notNull("foo").toString()); |
32 | 32 |
33 Expect.equals("RangeError", | 33 Expect.equals("RangeError", |
34 new RangeError(null).toString()); | 34 new RangeError(null).toString()); |
35 Expect.equals("RangeError: message", | 35 Expect.equals("RangeError: message", |
36 new RangeError("message").toString()); | 36 new RangeError("message").toString()); |
37 Expect.equals("RangeError: Value not in range: 42", | 37 Expect.equals("RangeError: Value not in range: 42", |
38 new RangeError.value(42).toString()); | 38 new RangeError.value(42).toString()); |
39 Expect.equals("RangeError (foo): Value not in range: 42", | 39 Expect.equals("RangeError (foo): Value not in range: 42", |
40 new RangeError.value(42, "foo").toString()); | 40 new RangeError.value(42, "foo").toString()); |
(...skipping 27 matching lines...) Expand all Loading... |
68 new RangeError.index(42, [1, 2, 3], | 68 new RangeError.index(42, [1, 2, 3], |
69 null, "message").toString()); | 69 null, "message").toString()); |
70 Expect.equals("RangeError (foo): message: " | 70 Expect.equals("RangeError (foo): message: " |
71 "index should be less than 2: 42", | 71 "index should be less than 2: 42", |
72 new RangeError.index(42, [1, 2, 3], | 72 new RangeError.index(42, [1, 2, 3], |
73 "foo", "message", 2).toString()); | 73 "foo", "message", 2).toString()); |
74 Expect.equals("RangeError: Index out of range: " | 74 Expect.equals("RangeError: Index out of range: " |
75 "index must not be negative: -5", | 75 "index must not be negative: -5", |
76 new RangeError.index(-5, [1, 2, 3]).toString()); | 76 new RangeError.index(-5, [1, 2, 3]).toString()); |
77 } | 77 } |
OLD | NEW |