MCPcopy Index your code
hub / github.com/yuin/gopher-lua / TestMergingLoadNilBug

Function TestMergingLoadNilBug

script_test.go:177–212  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

175}
176
177func TestMergingLoadNilBug(t *testing.T) {
178 // there was a bug where a multiple load nils were being incorrectly merged, and the following code exposed it
179 s := `
180 function test()
181 local a = 0
182 local b = 1
183 local c = 2
184 local d = 3
185 local e = 4 -- reg 4
186 local f = 5
187 local g = 6
188 local h = 7
189
190 if e == 4 then
191 e = nil -- should clear reg 4, but clears regs 4-8 by mistake
192 end
193 if f == nil then
194 error("bad f")
195 end
196 if g == nil then
197 error("bad g")
198 end
199 if h == nil then
200 error("bad h")
201 end
202 end
203
204 test()
205`
206
207 L := NewState()
208 defer L.Close()
209 if err := L.DoString(s); err != nil {
210 t.Error(err)
211 }
212}
213
214// This test is disabled because the LOADNIL merging optimisation has been disabled. See the comment in the
215// AddLoadNil() function for more information.

Callers

nothing calls this directly

Calls 4

DoStringMethod · 0.80
NewStateFunction · 0.70
ErrorMethod · 0.65
CloseMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…