controllogic: drop sign alias shim + add array node tests (set/remove/pop)
This commit is contained in:
@@ -60,6 +60,54 @@ func TestArrayClearNode(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestArraySetNode(t *testing.T) {
|
||||
g := Graph{
|
||||
ID: "g", Name: "n",
|
||||
StateVars: []StateVar{{Name: "buf", Type: "array", Initial: "[0,0,0]", Sizing: "dynamic"}},
|
||||
Nodes: []Node{
|
||||
{ID: "t", Kind: "trigger.timer", Params: map[string]string{"interval": "1000"}},
|
||||
{ID: "s", Kind: "action.array.set", Params: map[string]string{"array": "buf", "index": "1", "expr": "9"}},
|
||||
},
|
||||
Wires: []Wire{{From: "t", To: "s"}},
|
||||
}
|
||||
cg := runFlowOnce(t, g, "t")
|
||||
if got := cg.getLocal("buf"); !reflect.DeepEqual(got, []Value{0.0, 9.0, 0.0}) {
|
||||
t.Fatalf("after set buf = %#v", got)
|
||||
}
|
||||
}
|
||||
|
||||
func TestArrayRemoveNode(t *testing.T) {
|
||||
g := Graph{
|
||||
ID: "g", Name: "n",
|
||||
StateVars: []StateVar{{Name: "buf", Type: "array", Initial: "[10,20,30]", Sizing: "dynamic"}},
|
||||
Nodes: []Node{
|
||||
{ID: "t", Kind: "trigger.timer", Params: map[string]string{"interval": "1000"}},
|
||||
{ID: "r", Kind: "action.array.remove", Params: map[string]string{"array": "buf", "index": "-1"}},
|
||||
},
|
||||
Wires: []Wire{{From: "t", To: "r"}},
|
||||
}
|
||||
cg := runFlowOnce(t, g, "t")
|
||||
if got := cg.getLocal("buf"); !reflect.DeepEqual(got, []Value{10.0, 20.0}) {
|
||||
t.Fatalf("after remove buf = %#v", got)
|
||||
}
|
||||
}
|
||||
|
||||
func TestArrayPopNode(t *testing.T) {
|
||||
g := Graph{
|
||||
ID: "g", Name: "n",
|
||||
StateVars: []StateVar{{Name: "buf", Type: "array", Initial: "[1,2,3]", Sizing: "dynamic"}},
|
||||
Nodes: []Node{
|
||||
{ID: "t", Kind: "trigger.timer", Params: map[string]string{"interval": "1000"}},
|
||||
{ID: "p", Kind: "action.array.pop", Params: map[string]string{"array": "buf"}},
|
||||
},
|
||||
Wires: []Wire{{From: "t", To: "p"}},
|
||||
}
|
||||
cg := runFlowOnce(t, g, "t")
|
||||
if got := cg.getLocal("buf"); !reflect.DeepEqual(got, []Value{1.0, 2.0}) {
|
||||
t.Fatalf("after pop buf = %#v", got)
|
||||
}
|
||||
}
|
||||
|
||||
func TestCompileInitsLocalsFromDecls(t *testing.T) {
|
||||
g := Graph{
|
||||
ID: "g", Name: "n",
|
||||
|
||||
Reference in New Issue
Block a user