A small go library to lazily calculate dependent variables.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

22 lines
606 B

package pixelMenu
import (
"testing"
tools "gitlab.com/Pixdigit/goTestTools"
)
func TestResolverExample(t *testing.T) {
p1 := Invariant(1)
p2 := Invariant(2)
p3 := Invariant(3)
p4 := Invariant(4)
result := Div(Sub(Mul(Add(p1, p2), p3), p4), Invariant(1))
result.Resolve()
tools.Test(result.Value == 5, "invalid result", t)
tools.Test(result.HasDependency(p1), "No dependency detected", t)
tools.Test(result.HasDependency(p2), "No dependency detected", t)
tools.Test(result.HasDependency(p3), "No dependency detected", t)
tools.Test(result.HasDependency(p4), "No dependency detected", t)
}