(t *testing.T)
| 338 | } |
| 339 | |
| 340 | func TestAttributePattern_LocallyBound(t *testing.T) { |
| 341 | reg := newTestRegistry(t) |
| 342 | fac := NewPartialAttributeFactory(containers.DefaultContainer, reg, reg) |
| 343 | |
| 344 | // Create a partial activation that designates "x" and "y" as unknown. |
| 345 | partAct, err := NewPartialActivation(EmptyActivation(), NewAttributePattern("x"), NewAttributePattern("y")) |
| 346 | if err != nil { |
| 347 | t.Fatal(err) |
| 348 | } |
| 349 | |
| 350 | frame := mustNewExecutionFrame(t, partAct) |
| 351 | defer frame.Close() |
| 352 | |
| 353 | // Create folder (representing a local scope for variable "x" only) |
| 354 | fold := &evalFold{ |
| 355 | iterVar: "x", |
| 356 | adapter: types.DefaultTypeAdapter, |
| 357 | } |
| 358 | fld := newFolder(fold, frame) |
| 359 | defer releaseFolder(fld) |
| 360 | |
| 361 | // Push onto the frame stack to simulate local variable scope |
| 362 | frame1 := frame.Push(fld) |
| 363 | defer frame1.Pop() |
| 364 | |
| 365 | // 1. Resolve attribute matching "x". |
| 366 | // Because "x" is locally bound in fld, it should not resolve to types.Unknown. |
| 367 | attrX := fac.AbsoluteAttribute(1, "x") |
| 368 | valX, err := attrX.Resolve(frame1) |
| 369 | if err != nil { |
| 370 | t.Fatal(err) |
| 371 | } |
| 372 | if _, isUnk := valX.(*types.Unknown); isUnk { |
| 373 | t.Errorf("Resolve(x) got unknown, wanted value (since x is locally bound)") |
| 374 | } |
| 375 | |
| 376 | // 2. Resolve attribute matching "y". |
| 377 | // Because "y" is NOT locally bound in any local scope layer, it should resolve to types.Unknown. |
| 378 | attrY := fac.AbsoluteAttribute(2, "y") |
| 379 | valY, err := attrY.Resolve(frame1) |
| 380 | if err != nil { |
| 381 | t.Fatal(err) |
| 382 | } |
| 383 | if _, isUnk := valY.(*types.Unknown); !isUnk { |
| 384 | t.Errorf("Resolve(y) got %v, wanted types.Unknown (since y is not locally bound)", valY) |
| 385 | } |
| 386 | } |
| 387 | |
| 388 | func TestQualifierValueEquals(t *testing.T) { |
| 389 | tests := []struct { |
nothing calls this directly
no test coverage detected