MCPcopy
hub / github.com/google/mangle / TestGroupBy

Function TestGroupBy

engine/transformer_test.go:108–133  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

106}
107
108func TestGroupBy(t *testing.T) {
109 tests := []testCase{
110 {
111 initialFacts: []ast.Atom{atom("bar(0, 11)"), atom("bar(0, 12)")},
112 clause: clause("foo(Y, X) :- bar(Y, Z) |> do fn:group_by(Y), let X = fn:sum(Z)."),
113 expectedFacts: []ast.Atom{atom("foo(0, 23)")},
114 },
115 {
116 initialFacts: []ast.Atom{
117 atom(`bar("a", 11, 100)`),
118 atom(`bar("a", 11, 150)`),
119 atom(`bar("b", 3, 200))`),
120 },
121 clause: clause(`foo(Y, Count, Sum, Max) :- bar(Y, Z, A)
122 |> do fn:group_by(Y), let Count = fn:count(), let Sum = fn:sum(Z), let Max = fn:max(A).`),
123 expectedFacts: []ast.Atom{
124 atom(`foo("a", 2, 22, 150)`),
125 atom(`foo("b", 1, 3, 200)`),
126 },
127 },
128 }
129
130 for _, test := range tests {
131 runEval(test, t)
132 }
133}

Callers

nothing calls this directly

Calls 3

runEvalFunction · 0.85
atomFunction · 0.70
clauseFunction · 0.70

Tested by

no test coverage detected