| 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 // Dart test for testing super operator calls | 4 // Dart test for testing super operator calls |
| 5 | 5 |
| 6 | 6 |
| 7 class A { | 7 class A { |
| 8 String val = ""; | 8 String val = ""; |
| 9 List things; | 9 List things; |
| 10 | 10 |
| (...skipping 29 matching lines...) Expand all Loading... |
| 40 } | 40 } |
| 41 | 41 |
| 42 operator []= (i, val) { | 42 operator []= (i, val) { |
| 43 // Make sure the index expression is only evaluated | 43 // Make sure the index expression is only evaluated |
| 44 // once in the presence of a compound assignment. | 44 // once in the presence of a compound assignment. |
| 45 return super[i++] += val; | 45 return super[i++] += val; |
| 46 } | 46 } |
| 47 | 47 |
| 48 } | 48 } |
| 49 | 49 |
| 50 |
| 51 class Autobianchi { |
| 52 g() => super[0]; |
| 53 } |
| 54 |
| 55 |
| 56 testRegression6403() { |
| 57 // Do not crash, throw exception instead |
| 58 new Autobianchi().g(); |
| 59 } |
| 60 |
| 61 |
| 50 main () { | 62 main () { |
| 51 var a = new A(); | 63 var a = new A(); |
| 52 a = a + "William"; // operator + of class A. | 64 a = a + "William"; // operator + of class A. |
| 53 Expect.equals("William", a.val); | 65 Expect.equals("William", a.val); |
| 54 Expect.equals("r", a[2]); // operator [] of class A. | 66 Expect.equals("r", a[2]); // operator [] of class A. |
| 55 | 67 |
| 56 a = new B(); | 68 a = new B(); |
| 57 a += "Tell"; // operator + of class B. | 69 a += "Tell"; // operator + of class B. |
| 58 Expect.equals("TellTell", a.val); | 70 Expect.equals("TellTell", a.val); |
| 59 Expect.equals("rr", a[2]); // operator [] of class B. | 71 Expect.equals("rr", a[2]); // operator [] of class B. |
| 60 | 72 |
| 61 a[4] = 1; // operator []= of class B. | 73 a[4] = 1; // operator []= of class B. |
| 62 Expect.equals(43, a.things[4]); | 74 Expect.equals(43, a.things[4]); |
| 63 Expect.equals(86, a[4]); | 75 Expect.equals(86, a[4]); |
| 64 | 76 |
| 77 Expect.throws(testRegression6403); |
| 65 } | 78 } |
| OLD | NEW |