1
0
mirror of https://github.com/vlang/v.git synced 2023-08-10 21:13:21 +03:00

cgen: use standard checks for float comparisons

This commit is contained in:
Uwe Krüger
2020-06-04 19:47:41 +02:00
committed by GitHub
parent 42e314d281
commit cf9498ef6b
7 changed files with 164 additions and 203 deletions

View File

@ -11,46 +11,6 @@ fn test_const() {
assert u == 1 // make sure this works without the cast
}
fn test_float_equal_operator() {
b := f32(1.0)
mut a := f32(1.0)
a += 0.000001
a -= 0.000001
assert a == b
assert !a.eqbit(1.0)
assert !(a != f32(1.0))
assert a.nebit(f32(1.0))
a += 0.000001
assert !(a < 1.0)
assert !a.ltbit(1.0)
assert !(a <= 1)
assert !a.lebit(1)
assert a > 1
assert a.gtbit(1)
assert a >= 1
assert a.gebit(1)
assert -1 == 1 * -1
assert -1.0 == 1.0 * -1.0
a = 1
a += 0.000001
a -= 0.000001
assert a == f32(1.0)
assert !a.eqbit(f32(1.0))
assert !(a != f32(1.0))
a += 0.000001
assert !(a < f32(1))
assert !a.ltbit(f32(1))
assert !(a <= f32(1))
assert !a.lebit(f32(1))
assert a > f32(1)
assert a.gtbit(f32(1))
assert a >= 1
assert a.gebit(1)
f := 1.2
ab := int(f)
assert ab == 1
}
fn test_str_methods() {
assert i8(1).str() == '1'
assert i8(-1).str() == '-1'