(t *testing.T)
| 227 | } |
| 228 | |
| 229 | func TestFunctionActivationComposition(t *testing.T) { |
| 230 | tests := []struct { |
| 231 | name string |
| 232 | // vars builds the activation under test. |
| 233 | vars func(t *testing.T) Activation |
| 234 | // wantFuncs maps a function name to the tag of the binding which should be resolved, |
| 235 | // where an empty tag indicates that the name should not resolve. |
| 236 | wantFuncs map[string]string |
| 237 | // wantVars maps a variable name to the value which should be resolved. |
| 238 | wantVars map[string]any |
| 239 | // wantPartial indicates whether the activation exposes unknown attribute patterns. |
| 240 | wantPartial bool |
| 241 | }{ |
| 242 | { |
| 243 | name: "functions over a map input", |
| 244 | vars: func(t *testing.T) Activation { |
| 245 | return mustFunctionVars(t, map[string]any{"a": 1}, map[string]functions.LateBoundOp{"f": funcOf("f")}) |
| 246 | }, |
| 247 | wantFuncs: map[string]string{"f": "f", "g": ""}, |
| 248 | wantVars: map[string]any{"a": 1}, |
| 249 | }, |
| 250 | { |
| 251 | name: "functions over an activation input", |
| 252 | vars: func(t *testing.T) Activation { |
| 253 | base := mustActivation(t, map[string]any{"a": 1}) |
| 254 | return mustFunctionVars(t, base, map[string]functions.LateBoundOp{"f": funcOf("f")}) |
| 255 | }, |
| 256 | wantFuncs: map[string]string{"f": "f"}, |
| 257 | wantVars: map[string]any{"a": 1}, |
| 258 | }, |
| 259 | { |
| 260 | name: "no functions supplied", |
| 261 | vars: func(t *testing.T) Activation { |
| 262 | return mustActivation(t, map[string]any{"a": 1}) |
| 263 | }, |
| 264 | wantFuncs: map[string]string{"f": ""}, |
| 265 | wantVars: map[string]any{"a": 1}, |
| 266 | }, |
| 267 | { |
| 268 | name: "empty activation", |
| 269 | vars: func(t *testing.T) Activation { |
| 270 | return EmptyActivation() |
| 271 | }, |
| 272 | wantFuncs: map[string]string{"f": ""}, |
| 273 | }, |
| 274 | { |
| 275 | name: "partial over functions", |
| 276 | vars: func(t *testing.T) Activation { |
| 277 | fnVars := mustFunctionVars(t, map[string]any{"a": 1}, map[string]functions.LateBoundOp{"f": funcOf("f")}) |
| 278 | return mustPartialVars(t, fnVars, NewAttributePattern("b")) |
| 279 | }, |
| 280 | wantFuncs: map[string]string{"f": "f"}, |
| 281 | wantVars: map[string]any{"a": 1}, |
| 282 | wantPartial: true, |
| 283 | }, |
| 284 | { |
| 285 | name: "functions over partial", |
| 286 | vars: func(t *testing.T) Activation { |
nothing calls this directly
no test coverage detected