fn main() {
	test_eq_ne()
	test_lt_gt()
	test_ref_deref()
	test_nil()
	println("ok")
}

fn test_eq_ne() {
	unsafe {
		mut a := voidptr(0)
		mut b := voidptr(0)
		assert a == a
		assert !(a != a)
		assert a == b
		assert !(a != b)

		a = voidptr(0xdeadbeef)
		assert a != b
		assert !(a == b)

		b = voidptr(0xdeadbeef)
		assert a == b
		assert !(a != b)
	}
}

fn test_lt_gt() {
	unsafe {
		mut a := voidptr(0)
		mut b := voidptr(1)

		assert !(a < a)
		assert !(a > a)
		assert a >= a
		assert a <= a

		assert a < b
		assert !(a > b)
		assert a <= b
		assert !(a >= b)

		a = voidptr(0x42)
		assert a > b
		assert a >= b
		assert !(a < b)
		assert !(a <= b)

		b = voidptr(0x42)
		assert a >= b
		assert a <= b
		assert !(a > b)
		assert !(a < b) 
	}	
}

fn test_ref_deref() {
	mut a := 42
	b := &a
	c := &b

	assert *b == 42

	a = 50
	assert *b == 50

	assert *c == b
	assert **c == *b
}

fn test_nil() {
	unsafe {
		a := voidptr(nil)
		b := voidptr(0)

		assert a == b
		assert a == 0
		assert b == nil

		println(nil) // currently outputs '0x0' -> should this be 'nil'?
	}
}
