2019-08-04 10:16:44 +03:00
|
|
|
const (
|
|
|
|
a = 3
|
2019-09-01 22:37:22 +03:00
|
|
|
u = u64(1)
|
|
|
|
)
|
2019-08-04 10:16:44 +03:00
|
|
|
|
|
|
|
fn test_const() {
|
2019-09-01 22:37:22 +03:00
|
|
|
b := (true && true) || false
|
|
|
|
assert b == true
|
|
|
|
assert a == 3
|
|
|
|
assert u == u64(1)
|
2019-09-23 02:14:10 +03:00
|
|
|
assert u == 1 // make sure this works without the cast
|
2019-09-01 22:37:22 +03:00
|
|
|
}
|
2019-08-05 17:57:54 +03:00
|
|
|
|
2019-09-29 18:27:53 +03:00
|
|
|
fn test_float_equal_operator() {
|
|
|
|
mut a := f32(1)
|
|
|
|
a += 0.000001
|
|
|
|
a -= 0.000001
|
|
|
|
assert a == 1
|
|
|
|
assert !a.eqbit(1)
|
2019-10-01 22:38:36 +03:00
|
|
|
assert !(a != 1)
|
|
|
|
assert a.nebit(1)
|
|
|
|
a += 0.000001
|
|
|
|
assert !(a < 1)
|
|
|
|
assert !a.ltbit(1)
|
|
|
|
assert !(a <= 1)
|
|
|
|
assert !a.lebit(1)
|
|
|
|
assert a > 1
|
|
|
|
assert a.gtbit(1)
|
|
|
|
assert a >= 1
|
|
|
|
assert a.gebit(1)
|
2019-09-29 18:27:53 +03:00
|
|
|
|
|
|
|
a = f64(1)
|
|
|
|
a += 0.000001
|
|
|
|
a -= 0.000001
|
|
|
|
assert a == 1
|
|
|
|
assert !a.eqbit(1)
|
2019-10-01 22:38:36 +03:00
|
|
|
assert !(a != 1)
|
|
|
|
a += 0.000001
|
|
|
|
assert !(a < 1)
|
|
|
|
assert !a.ltbit(1)
|
|
|
|
assert !(a <= 1)
|
|
|
|
assert !a.lebit(1)
|
|
|
|
assert a > 1
|
|
|
|
assert a.gtbit(1)
|
|
|
|
assert a >= 1
|
|
|
|
assert a.gebit(1)
|
2019-09-29 18:27:53 +03:00
|
|
|
}
|
|
|
|
|
2019-08-12 02:58:08 +03:00
|
|
|
fn test_str_methods() {
|
|
|
|
assert i8(1).str() == '1'
|
|
|
|
assert i8(-1).str() == '-1'
|
|
|
|
assert i16(1).str() == '1'
|
|
|
|
assert i16(-1).str() == '-1'
|
2019-09-01 22:37:22 +03:00
|
|
|
assert int(1).str() == '1'
|
|
|
|
assert int(-1).str() == '-1'
|
2019-08-12 02:58:08 +03:00
|
|
|
assert i64(1).str() == '1'
|
|
|
|
assert i64(-1).str() == '-1'
|
|
|
|
|
2019-09-03 14:57:04 +03:00
|
|
|
// assert byte(1).str() == '1'
|
|
|
|
// assert byte(-1).str() == '255'
|
2019-08-12 02:58:08 +03:00
|
|
|
assert u16(1).str() == '1'
|
|
|
|
assert u16(-1).str() == '65535'
|
|
|
|
assert u32(1).str() == '1'
|
|
|
|
assert u32(-1).str() == '4294967295'
|
|
|
|
assert u64(1).str() == '1'
|
|
|
|
assert u64(-1).str() == '18446744073709551615'
|
|
|
|
}
|
|
|
|
|
2019-11-29 22:42:32 +03:00
|
|
|
fn test_and() {
|
|
|
|
c:=[1,2,3,4,5]
|
|
|
|
assert c[0] & 1 != 0
|
|
|
|
assert c[1] & 1 == 0
|
|
|
|
assert c[2] & 1 != 0
|
|
|
|
assert c[3] & 1 == 0
|
|
|
|
assert c[4] & 1 != 0
|
|
|
|
}
|
|
|
|
|
2019-08-09 11:21:21 +03:00
|
|
|
/*
|
2019-08-05 17:57:54 +03:00
|
|
|
fn test_cmp() {
|
|
|
|
assert 1 ≠ 2
|
|
|
|
assert 1 ⩽ 2
|
|
|
|
assert 1 ⩾ 0
|
2019-09-01 22:37:22 +03:00
|
|
|
}
|
2019-08-09 11:21:21 +03:00
|
|
|
*/
|