Browse Source

expanded tests

formatting
master v1.1.0
Pixdigit 3 years ago
parent
commit
20a313af7e
  1. 2
      Var.go
  2. 10
      var_test.go

2
Var.go

@ -22,7 +22,7 @@ func Invariant(value float64) Var {
v := NewVar(func() float64 {
return value
})
v.IsResolved = true;
v.IsResolved = true
return v
}

10
var_test.go

@ -7,17 +7,25 @@ import (
)
func TestResolving(t *testing.T) {
test := 0.0
p1 := Invariant(1)
p2 := Invariant(2)
p3 := Invariant(3)
p4 := Invariant(4)
p5 := PointerVar(&test)
test = 1
result := Div(Sub(Mul(Add(p1, p2), p3), p4), Invariant(1))
result := Div(Sub(Mul(Add(p1, p2), p3), p4), p5)
result.Resolve()
t.Log("Calculation result:", result.Value)
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)
tools.Test(result.HasDependency(p5), "No dependency detected", t)
tools.Test(!result.HasDependency(Invariant(0)), "Dependency on independed node", t)
}

Loading…
Cancel
Save