| 5 | ) |
| 6 | |
| 7 | func 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 | |
| 30 | func TestGoReflectArraySort(t *testing.T) { |
| 31 | vm := New() |