| 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 // VMOptions=--optimization-counter-threshold=10 --no-use-osr --no-background-co
mpilation | 4 // VMOptions=--optimization-counter-threshold=10 --no-use-osr --no-background-co
mpilation |
| 5 | 5 |
| 6 import "package:expect/expect.dart"; | 6 import "package:expect/expect.dart"; |
| 7 | 7 |
| 8 | |
| 9 class A { | 8 class A { |
| 10 bool _result; | 9 bool _result; |
| 11 A(this._result); | 10 A(this._result); |
| 12 operator ==(x) { return _result; } | 11 operator ==(x) { |
| 12 return _result; |
| 13 } |
| 13 } | 14 } |
| 14 | 15 |
| 15 | 16 opaque(x) => [x, 1, 'y'][0]; // confuse the optimizers. |
| 16 opaque(x) => [x,1,'y'][0]; // confuse the optimizers. | |
| 17 | 17 |
| 18 class Death { | 18 class Death { |
| 19 operator ==(x) { throw 'Dead!'; } | 19 operator ==(x) { |
| 20 throw 'Dead!'; |
| 21 } |
| 20 } | 22 } |
| 21 | 23 |
| 22 death() => opaque(new Death()); | 24 death() => opaque(new Death()); |
| 23 nullFn() => opaque(null); | 25 nullFn() => opaque(null); |
| 24 | 26 |
| 25 tests() { | 27 tests() { |
| 26 var alwaysTrue = new A(true); | 28 var alwaysTrue = new A(true); |
| 27 var alwaysFalse = new A(false); | 29 var alwaysFalse = new A(false); |
| 28 Expect.isFalse(alwaysFalse == alwaysFalse); | 30 Expect.isFalse(alwaysFalse == alwaysFalse); |
| 29 Expect.isTrue(alwaysFalse != alwaysFalse); | 31 Expect.isTrue(alwaysFalse != alwaysFalse); |
| (...skipping 10 matching lines...) Expand all Loading... |
| 40 Expect.isFalse(death() == nullFn()); | 42 Expect.isFalse(death() == nullFn()); |
| 41 Expect.isFalse(nullFn() == death()); | 43 Expect.isFalse(nullFn() == death()); |
| 42 Expect.isTrue(nullFn() == nullFn()); | 44 Expect.isTrue(nullFn() == nullFn()); |
| 43 Expect.isTrue(death() != nullFn()); | 45 Expect.isTrue(death() != nullFn()); |
| 44 Expect.isTrue(nullFn() != death()); | 46 Expect.isTrue(nullFn() != death()); |
| 45 Expect.isFalse(nullFn() != nullFn()); | 47 Expect.isFalse(nullFn() != nullFn()); |
| 46 | 48 |
| 47 if (death() == nullFn()) { | 49 if (death() == nullFn()) { |
| 48 throw "failed"; | 50 throw "failed"; |
| 49 } | 51 } |
| 50 if (death() != nullFn()) { | 52 if (death() != nullFn()) {} else { |
| 51 } else { | |
| 52 throw "failed"; | 53 throw "failed"; |
| 53 } | 54 } |
| 54 } | 55 } |
| 55 | 56 |
| 56 boolEqualityPositiveA(a) => a == true; | 57 boolEqualityPositiveA(a) => a == true; |
| 57 boolEqualityNegativeA(a) => a != true; | 58 boolEqualityNegativeA(a) => a != true; |
| 58 | 59 |
| 59 boolEqualityPositiveB(a) => true == a; | 60 boolEqualityPositiveB(a) => true == a; |
| 60 boolEqualityNegativeB(a) => true != a; | 61 boolEqualityNegativeB(a) => true != a; |
| 61 | 62 |
| (...skipping 11 matching lines...) Expand all Loading... |
| 73 Expect.isFalse(boolEqualityNegativeB(true)); | 74 Expect.isFalse(boolEqualityNegativeB(true)); |
| 74 Expect.isTrue(boolEqualityNegativeB(false)); | 75 Expect.isTrue(boolEqualityNegativeB(false)); |
| 75 } | 76 } |
| 76 | 77 |
| 77 // Deoptimize. | 78 // Deoptimize. |
| 78 Expect.isFalse(boolEqualityPositiveA(1)); | 79 Expect.isFalse(boolEqualityPositiveA(1)); |
| 79 Expect.isTrue(boolEqualityNegativeA("hi")); | 80 Expect.isTrue(boolEqualityNegativeA("hi")); |
| 80 Expect.isFalse(boolEqualityPositiveB(2.0)); | 81 Expect.isFalse(boolEqualityPositiveB(2.0)); |
| 81 Expect.isTrue(boolEqualityNegativeB([])); | 82 Expect.isTrue(boolEqualityNegativeB([])); |
| 82 } | 83 } |
| OLD | NEW |