(t *testing.T)
| 113 | } |
| 114 | |
| 115 | func TestFrameResolveName(t *testing.T) { |
| 116 | baseAct, err := NewActivation(map[string]any{"x": 1}) |
| 117 | if err != nil { |
| 118 | t.Fatalf("NewActivation(x) failed: %v", err) |
| 119 | } |
| 120 | childAct, err := NewActivation(map[string]any{"y": 2}) |
| 121 | if err != nil { |
| 122 | t.Fatalf("NewActivation(y) failed: %v", err) |
| 123 | } |
| 124 | |
| 125 | tests := []struct { |
| 126 | name string |
| 127 | setup func() *ExecutionFrame |
| 128 | varName string |
| 129 | wantVal any |
| 130 | wantFound bool |
| 131 | }{ |
| 132 | { |
| 133 | name: "resolve in base activation", |
| 134 | setup: func() *ExecutionFrame { |
| 135 | return mustNewExecutionFrame(t, baseAct) |
| 136 | }, |
| 137 | varName: "x", |
| 138 | wantVal: 1, |
| 139 | wantFound: true, |
| 140 | }, |
| 141 | { |
| 142 | name: "missing in base activation", |
| 143 | setup: func() *ExecutionFrame { |
| 144 | return mustNewExecutionFrame(t, baseAct) |
| 145 | }, |
| 146 | varName: "y", |
| 147 | wantVal: nil, |
| 148 | wantFound: false, |
| 149 | }, |
| 150 | { |
| 151 | name: "resolve in child activation", |
| 152 | setup: func() *ExecutionFrame { |
| 153 | f := mustNewExecutionFrame(t, baseAct) |
| 154 | return f.Push(childAct) |
| 155 | }, |
| 156 | varName: "y", |
| 157 | wantVal: 2, |
| 158 | wantFound: true, |
| 159 | }, |
| 160 | { |
| 161 | name: "resolve in parent activation from child", |
| 162 | setup: func() *ExecutionFrame { |
| 163 | f := mustNewExecutionFrame(t, baseAct) |
| 164 | return f.Push(childAct) |
| 165 | }, |
| 166 | varName: "x", |
| 167 | wantVal: 1, |
| 168 | wantFound: true, |
| 169 | }, |
| 170 | { |
| 171 | name: "missing in hierarchical activation", |
| 172 | setup: func() *ExecutionFrame { |
nothing calls this directly
no test coverage detected