...

Source file src/cmd/compile/internal/test/testdata/cmp_test.go

Documentation: cmd/compile/internal/test/testdata

     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  }
    38  

View as plain text