enum Color {
	red
	blue
	green
}

fn enum_test() {
	assert Color.red == .red
	assert Color.blue == .blue
	assert Color.green == .green
	assert Color.red != .blue
	assert Color.red != .green
	assert Color.blue != .green
	mut color := Color.red
	assert color == .red
	color = .green
	assert color == .green
}

fn match_test() {
	color := Color.green
	num := 3
	match color {
		.red {
			assert false
		}
		.green {
			assert true
		}
		else {
			assert false
		}
	}
	//	println(color)
	assert num == 3
}

enum Bar {
	baz
}

fn (_ Bar) baz() {}

fn test_enum_variant_and_method_name_clash() {
	x := Bar.baz
	//	println(x)
	x.baz()
}

enum Value {
	a
	b
	c = 5 * 3
	d
	e = 3
}

fn value_test() {
	assert int(Value.a) == 0
	assert int(Value.b) == 1
	assert int(Value.c) == 15
	assert int(Value.d) == 16
	assert int(Value.e) == 3
	assert Value.a == unsafe { Value(0) }
	assert Value.b == unsafe { Value(1) }
	assert Value.c == unsafe { Value(15) }
	assert Value.d == unsafe { Value(16) }
	assert Value.e == unsafe { Value(3) }
}

enum BigI as i64 {
        first = -3_000_000_000
        sec
}

enum BigU as u64 {
	first = 3_000_000_000
	sec
}

enum SmallI as i8 {
	first = -3
	sec
}

enum SmallU as u8 {
	first = 3
	sec
}

enum MediumI as i16 {
	first = -300
	sec
}

enum MediumU as u16 {
	first = 300
	sec
}

enum NormalI as i32 {
	first = -3_000_000
	sec
}

enum NormalU as u32 {
	first = 3_000_000
	sec
}

struct DiffSizes {
mut:
	a BigI
	b BigU
	c SmallI
	d SmallU
	e MediumI
	f MediumU
	g NormalI
	h NormalU
}

fn size_enum() {
	a := BigI.sec
	assert i64(a) == -2_999_999_999

	b := BigU.sec
	assert u64(b) == 3_000_000_001

	c := SmallI.sec
	assert i8(c) == -2

	d := SmallU.sec
	assert u8(d) == 4
	
	e := MediumI.sec
	assert i16(e) == -299

	f := MediumU.sec
	assert u16(f) == 301
	
	g := NormalI.sec
	assert i32(g) == -2_999_999

	h := NormalU.sec
	assert u32(h) == 3_000_001

	mut diff := DiffSizes{}
	diff.a = .sec
	diff.b = .sec
	diff.c = .sec
	diff.d = .sec
	diff.e = .sec
	diff.f = .sec
	diff.g = .sec
	diff.h = .sec
	assert i64(diff.a) == -2_999_999_999
	assert u64(diff.b) == 3_000_000_001
	assert i8(diff.c) == -2
	assert u8(diff.d) == 4
	assert i16(diff.e) == -299
	assert u16(diff.f) == 301
	assert i32(diff.g) == -2_999_999
	assert u32(diff.h) == 3_000_001
}

fn main() {
	enum_test()
	match_test()
	test_enum_variant_and_method_name_clash()
	value_test()
	size_enum()
	println('OK')
}
