string_test.go 495 B

123456789101112131415161718192021222324252627282930
  1. package goja
  2. import "testing"
  3. func TestStringOOBProperties(t *testing.T) {
  4. const SCRIPT = `
  5. var string = new String("str");
  6. string[4] = 1;
  7. string[4];
  8. `
  9. testScript1(SCRIPT, valueInt(1), t)
  10. }
  11. func BenchmarkASCIIConcat(b *testing.B) {
  12. vm := New()
  13. b.ResetTimer()
  14. b.ReportAllocs()
  15. for i := 0; i < b.N; i++ {
  16. _, err := vm.RunString(`{let result = "ab";
  17. for (let i = 0 ; i < 10;i++) {
  18. result += result;
  19. }}`)
  20. if err != nil {
  21. b.Fatalf("Unexpected errors %s", err)
  22. }
  23. }
  24. }