MCPcopy Index your code
hub / github.com/dop251/goja / TestSparseArrayExportToSlice

Function TestSparseArrayExportToSlice

array_sparse_test.go:234–264  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

232}
233
234func TestSparseArrayExportToSlice(t *testing.T) {
235 vm := New()
236 arr := vm.NewArray()
237 err := arr.Set("20470", 120470)
238 if err != nil {
239 t.Fatal(err)
240 }
241 err = arr.DefineDataProperty("20471", vm.ToValue(220471), FLAG_TRUE, FLAG_FALSE, FLAG_TRUE)
242 if err != nil {
243 t.Fatal(err)
244 }
245 var exp []int
246 err = vm.ExportTo(arr, &exp)
247 if err != nil {
248 t.Fatal(err)
249 }
250 if len(exp) != 20472 {
251 t.Fatalf("len: %d", len(exp))
252 }
253 if e := exp[20470]; e != 120470 {
254 t.Fatalf("20470: %d", e)
255 }
256 if e := exp[20471]; e != 220471 {
257 t.Fatalf("20471: %d", e)
258 }
259 for i := 0; i < 20470; i++ {
260 if exp[i] != 0 {
261 t.Fatalf("at %d: %d", i, exp[i])
262 }
263 }
264}

Callers

nothing calls this directly

Calls 6

NewFunction · 0.85
NewArrayMethod · 0.80
DefineDataPropertyMethod · 0.80
ToValueMethod · 0.80
ExportToMethod · 0.80
SetMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…