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

Function TestGoReflectArray

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

Source from the content-addressed store, hash-verified

5)
6
7func TestGoReflectArray(t *testing.T) {
8 vm := New()
9 vm.Set("a", [...]int{1, 2, 3})
10 _, err := vm.RunString(`
11 if (!Array.isArray(a)) {
12 throw new Error("isArray() returned false");
13 }
14 if (a[0] !== 1 || a[1] !== 2 || a[2] !== 3) {
15 throw new Error("Array contents is incorrect");
16 }
17 if (!a.hasOwnProperty("length")) {
18 throw new Error("hasOwnProperty() returned false");
19 }
20 let desc = Object.getOwnPropertyDescriptor(a, "length");
21 if (desc.value !== 3 || desc.writable || desc.enumerable || desc.configurable) {
22 throw new Error("incorrect property descriptor: " + JSON.stringify(desc));
23 }
24 `)
25 if err != nil {
26 t.Fatal(err)
27 }
28}
29
30func TestGoReflectArraySort(t *testing.T) {
31 vm := New()

Callers

nothing calls this directly

Calls 3

NewFunction · 0.85
RunStringMethod · 0.80
SetMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…