TestFunctionActivationNestingRejected covers hierarchies which supply late-bound functions from more than one activation. Such a hierarchy has no obvious resolution order, so it is reported rather than resolved by proximity.
(t *testing.T)
| 361 | // more than one activation. Such a hierarchy has no obvious resolution order, so it is reported |
| 362 | // rather than resolved by proximity. |
| 363 | func TestFunctionActivationNestingRejected(t *testing.T) { |
| 364 | fnA := map[string]functions.LateBoundOp{"f": funcOf("a")} |
| 365 | fnB := map[string]functions.LateBoundOp{"f": funcOf("b")} |
| 366 | |
| 367 | t.Run("function activation over a function activation", func(t *testing.T) { |
| 368 | inner := mustFunctionVars(t, map[string]any{"a": 1}, fnA) |
| 369 | if _, err := NewFunctionActivation(inner, fnB); err == nil { |
| 370 | t.Error("NewFunctionActivation() over an existing binding wanted error, got nil") |
| 371 | } |
| 372 | }) |
| 373 | t.Run("function activation over a partial wrapping one", func(t *testing.T) { |
| 374 | inner := mustFunctionVars(t, map[string]any{"a": 1}, fnA) |
| 375 | partial := mustPartialVars(t, inner, NewAttributePattern("b")) |
| 376 | if _, err := NewFunctionActivation(partial, fnB); err == nil { |
| 377 | t.Error("NewFunctionActivation() over a wrapped binding wanted error, got nil") |
| 378 | } |
| 379 | }) |
| 380 | t.Run("function activation over a hierarchy containing one", func(t *testing.T) { |
| 381 | inner := NewHierarchicalActivation( |
| 382 | mustActivation(t, map[string]any{"a": 1}), |
| 383 | mustFunctionVars(t, map[string]any{"b": 2}, fnA)) |
| 384 | if _, err := NewFunctionActivation(inner, fnB); err == nil { |
| 385 | t.Error("NewFunctionActivation() over a hierarchy wanted error, got nil") |
| 386 | } |
| 387 | }) |
| 388 | t.Run("both sides of a hierarchical activation", func(t *testing.T) { |
| 389 | vars := NewHierarchicalActivation( |
| 390 | mustFunctionVars(t, map[string]any{"a": 1}, fnA), |
| 391 | mustFunctionVars(t, map[string]any{"b": 2}, fnB)) |
| 392 | if _, err := FindFunctionActivation(vars); err == nil { |
| 393 | t.Error("FindFunctionActivation() over two bindings wanted error, got nil") |
| 394 | } |
| 395 | }) |
| 396 | } |
| 397 | |
| 398 | func TestNewFunctionActivationErrors(t *testing.T) { |
| 399 | if _, err := NewFunctionActivation(nil, map[string]functions.LateBoundOp{"f": funcOf("f")}); err == nil { |
nothing calls this directly
no test coverage detected