|
17 | 17 |
|
18 | 18 | SCENARIO("modulo interval domain", "[core][analyses][interval][modulo]") |
19 | 19 | { |
| 20 | + GIVEN("Two single element internvals") |
| 21 | + { |
| 22 | + constant_interval_exprt a(CEV(5)); |
| 23 | + constant_interval_exprt b(CEV(10)); |
| 24 | + constant_interval_exprt zero(CEV(0)); |
| 25 | + const auto a_mod_b = a.modulo(b); |
| 26 | + REQUIRE(V(a_mod_b.get_upper()) == 5); |
| 27 | + |
| 28 | + const auto b_mod_a = b.modulo(a); |
| 29 | + // TODO: precision with single element modulo |
| 30 | + REQUIRE(V(b_mod_a.get_upper()) == 4); |
| 31 | + |
| 32 | + const auto zero_mod_a = zero.modulo(a); |
| 33 | + REQUIRE(zero_mod_a == constant_interval_exprt(CEV(0))); |
| 34 | + |
| 35 | + // TODO: this causes an invariant as it is unable to simplify the |
| 36 | + // TODO: simplify(a % 0) == a % 0 |
| 37 | + // REQUIRE(a.modulo(zero).is_top()); |
| 38 | + } |
20 | 39 | GIVEN("Two simple signed intervals") |
21 | 40 | { |
22 | 41 | symbol_tablet symbol_table; |
@@ -52,6 +71,19 @@ SCENARIO("modulo interval domain", "[core][analyses][interval][modulo]") |
52 | 71 | constant_interval_exprt(CEV(-10), CEV(20)), |
53 | 72 | constant_interval_exprt(CEV(0), CEV(5))) == |
54 | 73 | constant_interval_exprt::top(signedbv_typet(32))); |
| 74 | + |
| 75 | + REQUIRE( |
| 76 | + constant_interval_exprt::modulo( |
| 77 | + constant_interval_exprt(CEV(-10), CEV(20)), |
| 78 | + constant_interval_exprt(CEV(1), CEV(5))) == |
| 79 | + constant_interval_exprt(CEV(-10), CEV(20))); |
| 80 | + |
| 81 | + REQUIRE( |
| 82 | + constant_interval_exprt::modulo( |
| 83 | + constant_interval_exprt(CEV(-10), CEV(-1)), |
| 84 | + constant_interval_exprt(CEV(-5), CEV(-1))) == |
| 85 | + constant_interval_exprt(CEV(-5), CEV(0))); |
| 86 | + |
55 | 87 | REQUIRE( |
56 | 88 | constant_interval_exprt::modulo( |
57 | 89 | constant_interval_exprt(CEV(-20), CEV(-10)), |
|
0 commit comments