OLD | NEW |
---|---|
1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2011, 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 // Testing the Expect class. | 4 // Testing the Expect class. |
5 | 5 |
6 import "package:expect/expect.dart"; | 6 import "package:expect/expect.dart"; |
7 | 7 |
8 class C { | |
9 operator==(other) => true; | |
10 int get hashCode => 0; | |
11 } | |
12 | |
8 class ExpectTest { | 13 class ExpectTest { |
9 | 14 |
10 static testEquals(a) { | 15 static testEquals(a) { |
11 try { | 16 try { |
12 Expect.equals("AB", a, "within testEquals"); | 17 Expect.equals("AB", a, "within testEquals"); |
13 } on Exception catch (msg) { | 18 } on Exception catch (msg) { |
14 print(msg); | 19 print(msg); |
15 return; | 20 return; |
16 } | 21 } |
17 Expect.equals("AB", "${a}B"); | 22 Expect.equals("AB", "${a}B"); |
(...skipping 16 matching lines...) Expand all Loading... | |
34 Expect.isFalse(t); | 39 Expect.isFalse(t); |
35 } on Exception catch (msg) { | 40 } on Exception catch (msg) { |
36 print(msg); | 41 print(msg); |
37 return; | 42 return; |
38 } | 43 } |
39 Expect.isTrue(t); | 44 Expect.isTrue(t); |
40 throw "Expect.isFalse did not fail"; | 45 throw "Expect.isFalse did not fail"; |
41 } | 46 } |
42 | 47 |
43 static testIdentical(a) { | 48 static testIdentical(a) { |
44 var ab = "${a}B"; | 49 var ab = new C(); |
45 try { | 50 try { |
46 Expect.identical("AB", ab); | 51 Expect.identical(new C(), ab); |
kustermann
2013/09/05 11:09:51
I don't understand your changes in this file.
* T
Søren Gjesse
2013/09/05 12:23:38
Well spotted! I reverted this, and opened a bug in
| |
47 } on Exception catch (msg) { | 52 } on Exception catch (msg) { |
48 print(msg); | 53 print(msg); |
49 return; | 54 return; |
50 } | 55 } |
51 Expect.equals("AB", ab); | 56 Expect.equals(new C(), ab); |
52 throw "Expect.identical did not fail"; | 57 throw "Expect.identical did not fail"; |
kustermann
2013/09/05 11:09:51
These last two statements will always result in an
Søren Gjesse
2013/09/05 12:23:38
That was just to keep the same structure in the te
| |
53 } | 58 } |
54 | 59 |
55 static testFail() { | 60 static testFail() { |
56 try { | 61 try { |
57 Expect.fail("fail now"); | 62 Expect.fail("fail now"); |
58 } on Exception catch (msg) { | 63 } on Exception catch (msg) { |
59 print(msg); | 64 print(msg); |
60 return; | 65 return; |
61 } | 66 } |
62 throw "Expect.fail did not fail"; | 67 throw "Expect.fail did not fail"; |
63 } | 68 } |
64 | 69 |
65 static void testMain() { | 70 static void testMain() { |
66 testEquals("A"); | 71 testEquals("A"); |
67 testIsTrue(false); | 72 testIsTrue(false); |
68 testIsTrue(1); | 73 testIsTrue(1); |
69 testIsFalse(true); | 74 testIsFalse(true); |
70 testIsFalse(0); | 75 testIsFalse(0); |
71 testIdentical("A"); | 76 testIdentical("A"); |
72 testFail(); | 77 testFail(); |
73 } | 78 } |
74 | 79 |
75 } | 80 } |
76 | 81 |
77 main() { | 82 main() { |
78 ExpectTest.testMain(); | 83 ExpectTest.testMain(); |
79 } | 84 } |
OLD | NEW |