github.com/gagliardetto/golang-go@v0.0.0-20201020153340-53909ea70814/cmd/compile/internal/gc/testdata/cmp_test.go (about)

     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  // cmp_ssa.go tests compare simplification operations.
     6  package main
     7  
     8  import "testing"
     9  
    10  //go:noinline
    11  func eq_ssa(a int64) bool {
    12  	return 4+a == 10
    13  }
    14  
    15  //go:noinline
    16  func neq_ssa(a int64) bool {
    17  	return 10 != a+4
    18  }
    19  
    20  func testCmp(t *testing.T) {
    21  	if wanted, got := true, eq_ssa(6); wanted != got {
    22  		t.Errorf("eq_ssa: expected %v, got %v\n", wanted, got)
    23  	}
    24  	if wanted, got := false, eq_ssa(7); wanted != got {
    25  		t.Errorf("eq_ssa: expected %v, got %v\n", wanted, got)
    26  	}
    27  	if wanted, got := false, neq_ssa(6); wanted != got {
    28  		t.Errorf("neq_ssa: expected %v, got %v\n", wanted, got)
    29  	}
    30  	if wanted, got := true, neq_ssa(7); wanted != got {
    31  		t.Errorf("neq_ssa: expected %v, got %v\n", wanted, got)
    32  	}
    33  }
    34  
    35  func TestCmp(t *testing.T) {
    36  	testCmp(t)
    37  }