github.com/llvm-mirror/llgo@v0.0.0-20190322182713-bf6f0a60fce1/test/execution/structs/compare.go (about)

     1  // RUN: llgo -o %t %s
     2  // RUN: %t 2>&1 | FileCheck %s
     3  
     4  // CHECK: true
     5  // CHECK-NEXT: false
     6  // CHECK-NEXT: true
     7  // CHECK-NEXT: false
     8  // CHECK-NEXT: false
     9  // CHECK-NEXT: true
    10  // CHECK-NEXT: true
    11  // CHECK-NEXT: false
    12  // CHECK-NEXT: false
    13  // CHECK-NEXT: true
    14  
    15  package main
    16  
    17  type S0 struct{}
    18  
    19  type S1 struct {
    20  	a int
    21  }
    22  
    23  type S2 struct {
    24  	a, b int
    25  }
    26  
    27  func testS0() {
    28  	println(S0{} == S0{})
    29  	println(S0{} != S0{})
    30  }
    31  
    32  func testS1() {
    33  	println(S1{1} == S1{1})
    34  	println(S1{1} != S1{1})
    35  	println(S1{1} == S1{2})
    36  	println(S1{1} != S1{2})
    37  }
    38  
    39  func testS2() {
    40  	s1 := S2{1, 2}
    41  	s2 := S2{1, 3}
    42  	println(s1 == s1)
    43  	println(s1 == s2)
    44  	println(s1 != s1)
    45  	println(s1 != s2)
    46  }
    47  
    48  func main() {
    49  	testS0()
    50  	testS1()
    51  	testS2()
    52  }