Chromium Code Reviews| 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 | 4 |
| 5 // Tests that we can call functions through getters. | 5 // Tests that we can call functions through getters. |
| 6 | 6 |
| 7 final TOP_LEVEL_CONST = 1; | 7 final TOP_LEVEL_CONST = 1; |
| 8 final TOP_LEVEL_CONST_REF = TOP_LEVEL_CONST; | 8 final TOP_LEVEL_CONST_REF = TOP_LEVEL_CONST; |
| 9 final TOP_LEVEL_NULL = null; | 9 final TOP_LEVEL_NULL = null; |
| 10 | 10 |
| (...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 104 b = new B(); | 104 b = new B(); |
| 105 Expect.equals("yzxgf", b.g3(b.y, b.z, b.x)); | 105 Expect.equals("yzxgf", b.g3(b.y, b.z, b.x)); |
| 106 b = new B(); | 106 b = new B(); |
| 107 Expect.equals("gyzxf", (b.g3)(b.y, b.z, b.x)); | 107 Expect.equals("gyzxf", (b.g3)(b.y, b.z, b.x)); |
| 108 } | 108 } |
| 109 | 109 |
| 110 static void expectThrowsNotClosure(fn) { | 110 static void expectThrowsNotClosure(fn) { |
| 111 var exception = catchException(fn); | 111 var exception = catchException(fn); |
| 112 if (!(exception is ObjectNotClosureException)) { | 112 if (!(exception is ObjectNotClosureException)) { |
| 113 Expect.fail("Wrong exception. Expected: ObjectNotClosureException" | 113 Expect.fail("Wrong exception. Expected: ObjectNotClosureException" |
| 114 + " got: ${exception}"); | 114 " got: ${exception}"); |
| 115 } | 115 } |
| 116 } | 116 } |
| 117 | 117 |
| 118 static catchException(fn) { | 118 static catchException(fn) { |
| 119 bool caught = false; | 119 bool caught = false; |
| 120 var result = null; | 120 var result = null; |
| 121 try { | 121 try { |
| 122 fn(); | 122 fn(); |
| 123 Expect.equals(true, false); // Shouldn't reach this. | 123 Expect.equals(true, false); // Shouldn't reach this. |
| 124 } catch (var e) { | 124 } catch (var e) { |
| (...skipping 23 matching lines...) Expand all Loading... | |
| 148 | 148 |
| 149 get g0() { _mark('g'); return f0() { return _mark('f'); }; } | 149 get g0() { _mark('g'); return f0() { return _mark('f'); }; } |
| 150 get g1() { _mark('g'); return f1(x) { return _mark('f'); }; } | 150 get g1() { _mark('g'); return f1(x) { return _mark('f'); }; } |
| 151 get g2() { _mark('g'); return f2(x, y) { return _mark('f'); }; } | 151 get g2() { _mark('g'); return f2(x, y) { return _mark('f'); }; } |
| 152 get g3() { _mark('g'); return f3(x, y, z) { return _mark('f'); }; } | 152 get g3() { _mark('g'); return f3(x, y, z) { return _mark('f'); }; } |
| 153 | 153 |
| 154 get x() { _mark('x'); return 0; } | 154 get x() { _mark('x'); return 0; } |
| 155 get y() { _mark('y'); return 1; } | 155 get y() { _mark('y'); return 1; } |
| 156 get z() { _mark('z'); return 2; } | 156 get z() { _mark('z'); return 2; } |
| 157 | 157 |
| 158 _mark(m) { _order += m; return _order; } | 158 _mark(m) { _order = _order.concat(m); return _order; } |
|
kasperl
2012/03/12 06:55:42
This would be cleaner with a string buffer, but I
Ivan Posva
2012/04/11 14:26:00
Done.
| |
| 159 String _order; | 159 String _order; |
| 160 | 160 |
| 161 } | 161 } |
| 162 | 162 |
| 163 main() { | 163 main() { |
| 164 CallThroughGetterTest.testMain(); | 164 CallThroughGetterTest.testMain(); |
| 165 } | 165 } |
| OLD | NEW |