File tree Expand file tree Collapse file tree 1 file changed +18
-10
lines changed Expand file tree Collapse file tree 1 file changed +18
-10
lines changed Original file line number Diff line number Diff line change @@ -3503,16 +3503,24 @@ func TestAllocations(t *testing.T) {
3503
3503
var i any
3504
3504
var v Value
3505
3505
3506
- // We can uncomment this when compiler escape analysis
3507
- // is good enough to see that the integer assigned to i
3508
- // does not escape and therefore need not be allocated.
3509
- //
3510
- // i = 42 + j
3511
- // v = ValueOf(i)
3512
- // if int(v.Int()) != 42+j {
3513
- // panic("wrong int")
3514
- // }
3515
-
3506
+ i = 42 + j
3507
+ v = ValueOf (i )
3508
+ if int (v .Int ()) != 42 + j {
3509
+ panic ("wrong int" )
3510
+ }
3511
+ })
3512
+ noAlloc (t , 100 , func (j int ) {
3513
+ var i any
3514
+ var v Value
3515
+ i = [3 ]int {j , j , j }
3516
+ v = ValueOf (i )
3517
+ if v .Len () != 3 {
3518
+ panic ("wrong length" )
3519
+ }
3520
+ })
3521
+ noAlloc (t , 100 , func (j int ) {
3522
+ var i any
3523
+ var v Value
3516
3524
i = func (j int ) int { return j }
3517
3525
v = ValueOf (i )
3518
3526
if v .Interface ().(func (int ) int )(j ) != j {
You can’t perform that action at this time.
0 commit comments