|
114 | 114 | @test evaluate(dc.BinaryOperation{dc.Add}(z, d)) == d |
115 | 115 | end |
116 | 116 |
|
| 117 | +@testset "evaluate sum of real and real" begin |
| 118 | + function add(l, r) |
| 119 | + return dc.BinaryOperation{dc.Add}(l, r) |
| 120 | + end |
| 121 | + |
| 122 | + @test evaluate(add(2, 2)) == 4 |
| 123 | +end |
| 124 | + |
117 | 125 | @testset "evaluate sum of addition and addition" begin |
118 | 126 | a = Variable("a", Upper(1)) |
119 | 127 | b = Variable("b", Upper(1)) |
|
196 | 204 | sub = dc.BinaryOperation{dc.Sub}(a, b) |
197 | 205 | add = dc.BinaryOperation{dc.Add}(sub, add_inner) |
198 | 206 | @test evaluate(add) == add |
| 207 | + |
| 208 | + # c + d + a - b |
| 209 | + add_inner = dc.BinaryOperation{dc.Add}(c, d) |
| 210 | + sub = dc.BinaryOperation{dc.Sub}(a, b) |
| 211 | + add = dc.BinaryOperation{dc.Add}(add_inner, sub) |
| 212 | + @test evaluate(add) == add |
| 213 | +end |
| 214 | + |
| 215 | +@testset "evaluate sum of subtraction and zero" begin |
| 216 | + a = Variable("a", Upper(1)) |
| 217 | + b = Variable("b", Upper(1)) |
| 218 | + c = Variable("c", Upper(1)) |
| 219 | + |
| 220 | + # a + b - (c - c) |
| 221 | + add = dc.BinaryOperation{dc.Add}(a, b) |
| 222 | + sub = dc.BinaryOperation{dc.Sub}(c, c) |
| 223 | + add = dc.BinaryOperation{dc.Add}(add, sub) |
| 224 | + @test evaluate(add) == dc.BinaryOperation{dc.Add}(a, b) |
199 | 225 | end |
200 | 226 |
|
201 | 227 | @testset "evaluate sum of subtraction and subtraction" begin |
|
597 | 623 | @test dc.evaluate(sub(Z, prod)) == -prod |
598 | 624 | end |
599 | 625 |
|
| 626 | +@testset "evaluate subtraction with real and real" begin |
| 627 | + function sub(l, r) |
| 628 | + return dc.BinaryOperation{dc.Sub}(l, r) |
| 629 | + end |
| 630 | + |
| 631 | + @test dc.evaluate(sub(3, 2)) == 1 |
| 632 | + @test dc.evaluate(sub(3, 3)) == 0 |
| 633 | + @test dc.evaluate(sub(2, 3)) == -1 |
| 634 | +end |
| 635 | + |
600 | 636 | @testset "evaluate unary operations" begin |
601 | 637 | A = Variable("A", Upper(1), Lower(2)) |
602 | 638 |
|
|
0 commit comments