MCPcopy Create free account
hub / github.com/dop251/goja / TestExportArrayLikeToArrayMismatchedLengths

Function TestExportArrayLikeToArrayMismatchedLengths

object_test.go:429–450  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

427}
428
429func TestExportArrayLikeToArrayMismatchedLengths(t *testing.T) {
430 vm := New()
431 a, err := vm.RunString(`
432 ({
433 length: 2,
434 0: true,
435 1: true
436 });
437 `)
438 if err != nil {
439 t.Fatal(err)
440 }
441
442 var a1 [3]interface{}
443 err = vm.ExportTo(a, &a1)
444 if err == nil {
445 t.Fatal("expected error")
446 }
447 if msg := err.Error(); !strings.Contains(msg, "lengths mismatch") {
448 t.Fatalf("unexpected error: %v", err)
449 }
450}
451
452func TestSetForeignReturnValue(t *testing.T) {
453 const SCRIPT = `

Callers

nothing calls this directly

Calls 4

NewFunction · 0.85
RunStringMethod · 0.80
ExportToMethod · 0.80
ErrorMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…