summaryrefslogtreecommitdiffstats
path: root/llgo/test/execution/interfaces/basic.go
blob: 6c754dae1c9bff9645d69800326704d182b96584 (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
// RUN: llgo -o %t %s
// RUN: %t 2>&1 | FileCheck %s

// CHECK: expected: y != z

package main

type any interface{}

type Stringer interface {
	String() string
}

type lessThanAWord struct {
	a byte
}

func (l lessThanAWord) String() string {
	return "!"
}

func makeAStringer() Stringer {
	return lessThanAWord{}
}

func main() {
	var x1, x2 int = 1, 2
	var y any = x1
	var z any = x2
	if y != z {
		println("expected: y != z")
	} else {
		println("unexpected: y == z")
	}
	/*
		if y == x1 {
			println("expected: y == x1")
		} else {
			println("unexpected: y == x1")
		}
	*/
	//println(y.(int))
}
OpenPOWER on IntegriCloud