summaryrefslogtreecommitdiffstats
path: root/llgo/test/execution/structs/compare.go
blob: 20a8ead72f724531076be930289ebb44f66e8970 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
// RUN: llgo -o %t %s
// RUN: %t 2>&1 | FileCheck %s

// CHECK: true
// CHECK-NEXT: false
// CHECK-NEXT: true
// CHECK-NEXT: false
// CHECK-NEXT: false
// CHECK-NEXT: true
// CHECK-NEXT: true
// CHECK-NEXT: false
// CHECK-NEXT: false
// CHECK-NEXT: true

package main

type S0 struct{}

type S1 struct {
	a int
}

type S2 struct {
	a, b int
}

func testS0() {
	println(S0{} == S0{})
	println(S0{} != S0{})
}

func testS1() {
	println(S1{1} == S1{1})
	println(S1{1} != S1{1})
	println(S1{1} == S1{2})
	println(S1{1} != S1{2})
}

func testS2() {
	s1 := S2{1, 2}
	s2 := S2{1, 3}
	println(s1 == s1)
	println(s1 == s2)
	println(s1 != s1)
	println(s1 != s2)
}

func main() {
	testS0()
	testS1()
	testS2()
}
OpenPOWER on IntegriCloud