1
0

array_test.go 409 B

123456789101112131415161718
  1. package jsc_test
  2. import (
  3. "testing"
  4. "github.com/sagernet/sing-box/script/jsc"
  5. "github.com/dop251/goja"
  6. "github.com/stretchr/testify/require"
  7. )
  8. func TestNewUInt8Array(t *testing.T) {
  9. runtime := goja.New()
  10. runtime.Set("hello", jsc.NewUint8Array(runtime, []byte("world")))
  11. result, err := runtime.RunString("hello instanceof Uint8Array")
  12. require.NoError(t, err)
  13. require.True(t, result.ToBoolean())
  14. }