package js import ( "context" "testing" ) func TestPoolVersioning(t *testing.T) { // 1. Define initial function Define(`function hello(name) { return "Hello " + name; }`) res, err := Call(context.Background(), "hello", []any{"World"}) if err != nil { t.Fatal(err) } if res != "Hello World" { t.Errorf("expected 'Hello World', got %v", res) } // 2. Define new function (incremental update) Define(`function add(a, b) { return a + b; }`) res, err = Call(context.Background(), "add", []any{1, 2}) if err != nil { t.Fatal(err) } if res.(int64) != 3 { t.Errorf("expected 3, got %v", res) } // 3. Ensure old function still works res, err = Call(context.Background(), "hello", []any{"Again"}) if err != nil { t.Fatal(err) } if res != "Hello Again" { t.Errorf("expected 'Hello Again', got %v", res) } } func TestPoolConcurrent(t *testing.T) { Define(`function heavy(n) { let s = 0; for(let i=0; i