MCPcopy Index your code
hub / github.com/Shopify/go-lua / TestPairsSplit

Function TestPairsSplit

vm_test.go:354–376  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

352}
353
354func TestPairsSplit(t *testing.T) {
355 testString(t, `
356 local t = {}
357 -- first two keys go into array
358 t[1] = true
359 t[2] = true
360 -- next key forced into map instead of array since it's non-sequential
361 t[16] = true
362 -- next key inserted into array
363 t[3] = true
364
365 local keys = {}
366 for k, v in pairs(t) do
367 keys[#keys + 1] = k
368 end
369
370 table.sort(keys)
371 assert(keys[1] == 1, 'got ' .. tostring(keys[1]) .. '; want 1')
372 assert(keys[2] == 2, 'got ' .. tostring(keys[2]) .. '; want 2')
373 assert(keys[3] == 3, 'got ' .. tostring(keys[3]) .. '; want 3')
374 assert(keys[4] == 16, 'got ' .. tostring(keys[4]) .. '; want 16')
375 `)
376}
377
378func TestConcurrentNext(t *testing.T) {
379 testString(t, `

Callers

nothing calls this directly

Calls 1

testStringFunction · 0.85

Tested by

no test coverage detected