• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1// Copyright 2015 The Go Authors. All rights reserved.
2// Use of this source code is governed by a BSD-style
3// license that can be found in the LICENSE file.
4
5// closure.go tests closure operations.
6package main
7
8import "testing"
9
10//go:noinline
11func testCFunc_ssa() int {
12	a := 0
13	b := func() {
14		switch {
15		}
16		a++
17	}
18	b()
19	b()
20	return a
21}
22
23func testCFunc(t *testing.T) {
24	if want, got := 2, testCFunc_ssa(); got != want {
25		t.Errorf("expected %d, got %d", want, got)
26	}
27}
28
29// TestClosure tests closure related behavior.
30func TestClosure(t *testing.T) {
31	testCFunc(t)
32}
33