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

Function TestGoReflectArraySort

object_goarray_reflect_test.go:30–51  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

28}
29
30func TestGoReflectArraySort(t *testing.T) {
31 vm := New()
32 vm.Set("a", [...]int{3, 1, 2})
33 v, err := vm.RunString(`
34 a.sort();
35 if (a[0] !== 1 || a[1] !== 2 || a[2] !== 3) {
36 throw new Error(a.toString());
37 }
38 a;
39 `)
40 if err != nil {
41 t.Fatal(err)
42 }
43 res := v.Export()
44 if a, ok := res.([3]int); ok {
45 if a[0] != 1 || a[1] != 2 || a[2] != 3 {
46 t.Fatal(a)
47 }
48 } else {
49 t.Fatalf("Wrong type: %T", res)
50 }
51}
52
53func TestGoReflectArrayCopyOnChange(t *testing.T) {
54 vm := New()

Callers

nothing calls this directly

Calls 4

NewFunction · 0.85
RunStringMethod · 0.80
SetMethod · 0.65
ExportMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…