| OLD | NEW |
| 1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2015, 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 import 'package:compiler/src/cps_ir/octagon.dart'; | 5 import 'package:compiler/src/cps_ir/octagon.dart'; |
| 6 import 'package:expect/expect.dart'; | 6 import 'package:expect/expect.dart'; |
| 7 | 7 |
| 8 Octagon octagon; | 8 Octagon octagon; |
| 9 SignedVariable v1, v2, v3, v4; | 9 SignedVariable v1, v2, v3, v4; |
| 10 | 10 |
| (...skipping 215 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 226 pushConstraint(v1, v1, 2); | 226 pushConstraint(v1, v1, 2); |
| 227 pushConstraint(v1.negated, v1.negated, -2); | 227 pushConstraint(v1.negated, v1.negated, -2); |
| 228 pushConstraint(v2, v2, 0); | 228 pushConstraint(v2, v2, 0); |
| 229 pushConstraint(v2.negated, v2.negated, 0); | 229 pushConstraint(v2.negated, v2.negated, 0); |
| 230 Expect.isTrue(octagon.isSolvable, 'should be solvable'); | 230 Expect.isTrue(octagon.isSolvable, 'should be solvable'); |
| 231 pushConstraint(v1, v2.negated, 0); | 231 pushConstraint(v1, v2.negated, 0); |
| 232 Expect.isTrue(octagon.isUnsolvable, 'v1 <= v2: should be unsolvable'); | 232 Expect.isTrue(octagon.isUnsolvable, 'v1 <= v2: should be unsolvable'); |
| 233 } | 233 } |
| 234 | 234 |
| 235 lower_bounds_check() { | 235 lower_bounds_check() { |
| 236 setup(); |
| 236 SignedVariable w = octagon.makeVariable(0, 1000); | 237 SignedVariable w = octagon.makeVariable(0, 1000); |
| 237 pushConstraint(w, w, -1); | 238 pushConstraint(w, w, -1); |
| 238 Expect.isTrue(octagon.isUnsolvable, 'Value in range 0..1000 is not <= -1'); | 239 Expect.isTrue(octagon.isUnsolvable, 'Value in range 0..1000 is not <= -1'); |
| 239 } | 240 } |
| 240 | 241 |
| 241 upper_bounds_check() { | 242 upper_bounds_check() { |
| 243 setup(); |
| 242 SignedVariable w = octagon.makeVariable(0, 1000); | 244 SignedVariable w = octagon.makeVariable(0, 1000); |
| 243 pushConstraint(w.negated, w.negated, -5000); | 245 pushConstraint(w.negated, w.negated, -5000); |
| 244 Expect.isTrue(octagon.isUnsolvable, 'Value in range 0..1000 is not >= 5000'); | 246 Expect.isTrue(octagon.isUnsolvable, 'Value in range 0..1000 is not >= 5000'); |
| 245 } | 247 } |
| 246 | 248 |
| 249 diamond_graph() { |
| 250 setup(); |
| 251 pushConstraint(v1, v2.negated, 10); |
| 252 pushConstraint(v1, v3.negated, 1); |
| 253 pushConstraint(v2, v3.negated, 1); |
| 254 pushConstraint(v2, v4.negated, 2); |
| 255 pushConstraint(v3, v2.negated, 0); |
| 256 pushConstraint(v3, v4.negated, 100); |
| 257 Expect.isTrue(octagon.isSolvable, 'v1 <= v4 + 3'); |
| 258 var c = pushConstraint(v4, v1.negated, -4); |
| 259 Expect.isTrue(octagon.isUnsolvable, 'v4 <= v1 - 4 should be a contradiction'); |
| 260 popConstraint(c); |
| 261 pushConstraint(v1.negated, v4, -4); // Check converse constraint. |
| 262 Expect.isTrue(octagon.isUnsolvable, 'v4 <= v1 - 4 should be a contradiction'); |
| 263 } |
| 264 |
| 247 void main() { | 265 void main() { |
| 248 negative_loop1(); | 266 negative_loop1(); |
| 249 negative_loop2(); | 267 negative_loop2(); |
| 250 negative_loop3(); | 268 negative_loop3(); |
| 251 zero_loop1(); | 269 zero_loop1(); |
| 252 zero_loop2(); | 270 zero_loop2(); |
| 253 positive_loop1(); | 271 positive_loop1(); |
| 254 positive_loop2(); | 272 positive_loop2(); |
| 255 positive_and_negative_loops1(); | 273 positive_and_negative_loops1(); |
| 256 positive_and_negative_loops2(); | 274 positive_and_negative_loops2(); |
| 257 positive_and_negative_loops3(); | 275 positive_and_negative_loops3(); |
| 258 plus_minus1(); | 276 plus_minus1(); |
| 259 constant1(); | 277 constant1(); |
| 260 contradict1(); | 278 contradict1(); |
| 261 contradict2(); | 279 contradict2(); |
| 262 lower_bounds_check(); | 280 lower_bounds_check(); |
| 263 upper_bounds_check(); | 281 upper_bounds_check(); |
| 282 diamond_graph(); |
| 264 } | 283 } |
| OLD | NEW |