(i int)
| 369 | } |
| 370 | |
| 371 | func (t *testSharedDynArray) SetLen(i int) bool { |
| 372 | t.Lock() |
| 373 | defer t.Unlock() |
| 374 | if i > len(t.a) { |
| 375 | t.expand(i) |
| 376 | return true |
| 377 | } |
| 378 | if i < 0 { |
| 379 | return false |
| 380 | } |
| 381 | if i < len(t.a) { |
| 382 | tail := t.a[i:len(t.a)] |
| 383 | for j := range tail { |
| 384 | tail[j] = nil |
| 385 | } |
| 386 | t.a = t.a[:i] |
| 387 | } |
| 388 | return true |
| 389 | } |
| 390 | |
| 391 | func TestSharedDynamicArray(t *testing.T) { |
| 392 | dynObj := &testSharedDynArray{a: make([]Value, 10000)} |