OLD | NEW |
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, 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 class A { | 5 class A { |
6 operator ==(other) => 1; | 6 operator ==(other) => 1; |
7 operator <(other) => null; | 7 operator <(other) => null; |
8 operator <=(other) => 499; | 8 operator <=(other) => 499; |
9 operator >(other) => "foo"; | 9 operator >(other) => "foo"; |
10 operator >=(other) => 42; | 10 operator >=(other) => 42; |
11 } | 11 } |
12 | 12 |
13 // This triggered a bug in Dart2Js: equality operator was always boolified. | 13 // This triggered a bug in Dart2Js: equality operator was always boolified. |
14 equals(a) { | 14 equals(a) { |
15 try { | 15 try { |
16 Expect.equals(1, a == a); | 16 Expect.equals(1, a == a); |
17 } catch(TypeError e) { | 17 } on TypeError catch (e) { |
18 // In checked mode the test doesn't do anything. | 18 // In checked mode the test doesn't do anything. |
19 } | 19 } |
20 } | 20 } |
21 | 21 |
22 less(a) { | 22 less(a) { |
23 try { | 23 try { |
24 Expect.equals(null, a < a); | 24 Expect.equals(null, a < a); |
25 } catch(TypeError e) {} | 25 } on TypeError catch (e) {} |
26 } | 26 } |
27 | 27 |
28 lessEqual(a) { | 28 lessEqual(a) { |
29 try { | 29 try { |
30 Expect.equals(499, a <= a); | 30 Expect.equals(499, a <= a); |
31 } catch(TypeError e) {} | 31 } on TypeError catch (e) {} |
32 } | 32 } |
33 | 33 |
34 greater(a) { | 34 greater(a) { |
35 try { | 35 try { |
36 Expect.equals("foo", a > a); | 36 Expect.equals("foo", a > a); |
37 } catch(TypeError e) {} | 37 } on TypeError catch (e) {} |
38 } | 38 } |
39 | 39 |
40 greaterEqual(a) { | 40 greaterEqual(a) { |
41 try { | 41 try { |
42 Expect.equals(42, a >= a); | 42 Expect.equals(42, a >= a); |
43 } catch(TypeError e) {} | 43 } on TypeError catch (e) {} |
44 } | 44 } |
45 | 45 |
46 main() { | 46 main() { |
47 var a = new A(); | 47 var a = new A(); |
48 equals(a); | 48 equals(a); |
49 less(a); | 49 less(a); |
50 lessEqual(a); | 50 lessEqual(a); |
51 greater(a); | 51 greater(a); |
52 greaterEqual(a); | 52 greaterEqual(a); |
53 } | 53 } |
OLD | NEW |