| 1 | interface Interface { |
| 2 | a ?int |
| 3 | } |
| 4 | |
| 5 | struct Test2 { |
| 6 | a ?int |
| 7 | } |
| 8 | |
| 9 | type Alias = int |
| 10 | type AliasStruct = Test2 |
| 11 | type AliasStruct2 = fn () |
| 12 | |
| 13 | type AliasStruct3 = []int |
| 14 | |
| 15 | type SumType = Alias | AliasStruct2 | f64 | int |
| 16 | |
| 17 | struct Test { |
| 18 | mut: |
| 19 | a ?int |
| 20 | b ?f64 |
| 21 | c ?string |
| 22 | d ?[]int |
| 23 | e ?[]string |
| 24 | f ?[]f64 |
| 25 | g ?fn () |
| 26 | h ?Alias |
| 27 | i ?Interface = Test2{ |
| 28 | a: -1 |
| 29 | } |
| 30 | j ?AliasStruct |
| 31 | k ?AliasStruct2 |
| 32 | l ?AliasStruct3 |
| 33 | m ?SumType |
| 34 | n SumType |
| 35 | } |
| 36 | |
| 37 | fn test_simple_compare() { |
| 38 | mut a := Test{} |
| 39 | mut b := Test{} |
| 40 | assert a == b |
| 41 | } |
| 42 | |
| 43 | fn test_anon_compare() { |
| 44 | z := fn () {} |
| 45 | d := fn () {} |
| 46 | mut a := Test{} |
| 47 | mut b := Test{} |
| 48 | |
| 49 | assert a == b |
| 50 | |
| 51 | a.g = z |
| 52 | b.g = d |
| 53 | assert a != b |
| 54 | } |
| 55 | |
| 56 | fn test_alias_compare() { |
| 57 | z := 1 |
| 58 | d := 2 |
| 59 | mut a := Test{} |
| 60 | mut b := Test{} |
| 61 | |
| 62 | assert a == b |
| 63 | |
| 64 | a.h = z |
| 65 | b.h = d |
| 66 | assert a != b |
| 67 | } |
| 68 | |
| 69 | fn test_iface_compare() { |
| 70 | z := Test2{ |
| 71 | a: -1 |
| 72 | } |
| 73 | d := Test2{ |
| 74 | a: 0 |
| 75 | } |
| 76 | mut a := Test{ |
| 77 | a: 0 |
| 78 | } |
| 79 | mut b := Test{ |
| 80 | a: 0 |
| 81 | } |
| 82 | |
| 83 | assert a == b |
| 84 | |
| 85 | a.i = z |
| 86 | b.i = d |
| 87 | assert a != b |
| 88 | } |
| 89 | |