mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
tests: update for stricter type checks
This commit is contained in:
@@ -89,12 +89,12 @@ fn test_bits(){
|
||||
|
||||
// 8 bit
|
||||
i = 0
|
||||
for x in 0..9 {
|
||||
for _ in 0..9 {
|
||||
mut rv := byte(0)
|
||||
mut bc := 0
|
||||
mut n := i
|
||||
for bc < 8 {
|
||||
rv = (rv << 1) | (n & 0x01)
|
||||
rv = (rv << 1) | (byte(n) & 0x01)
|
||||
bc++
|
||||
n = n >> 1
|
||||
}
|
||||
@@ -105,12 +105,12 @@ fn test_bits(){
|
||||
|
||||
// 16 bit
|
||||
i = 0
|
||||
for x in 0..17 {
|
||||
for _ in 0..17 {
|
||||
mut rv := u16(0)
|
||||
mut bc := 0
|
||||
mut n := i
|
||||
for bc < 16 {
|
||||
rv = (rv << 1) | (n & 0x01)
|
||||
rv = (rv << 1) | (u16(n) & 0x01)
|
||||
bc++
|
||||
n = n >> 1
|
||||
}
|
||||
@@ -121,12 +121,12 @@ fn test_bits(){
|
||||
|
||||
// 32 bit
|
||||
i = 0
|
||||
for x in 0..33 {
|
||||
for _ in 0..33 {
|
||||
mut rv := u32(0)
|
||||
mut bc := 0
|
||||
mut n := i
|
||||
for bc < 32 {
|
||||
rv = (rv << 1) | (n & 0x01)
|
||||
rv = (rv << 1) | (u32(n) & 0x01)
|
||||
bc++
|
||||
n = n >> 1
|
||||
}
|
||||
@@ -137,7 +137,7 @@ fn test_bits(){
|
||||
|
||||
// 64 bit
|
||||
i1 = 0
|
||||
for x in 0..64 {
|
||||
for _ in 0..64 {
|
||||
mut rv := u64(0)
|
||||
mut bc := 0
|
||||
mut n := i1
|
||||
|
@@ -56,7 +56,7 @@ fn eval_cf(whole i64, den []i64) Fraction {
|
||||
}
|
||||
else {
|
||||
last := count - 1
|
||||
mut n := 1
|
||||
mut n := i64(1)
|
||||
mut d := den[last]
|
||||
// The calculations are done from back to front
|
||||
for index := count - 2; index >= 0; index-- {
|
||||
@@ -90,7 +90,7 @@ pub fn approximate_with_eps(val, eps f64) Fraction {
|
||||
// The integer part is separated first. Then we process the fractional
|
||||
// part to generate numerators and denominators in tandem.
|
||||
whole := i64(val)
|
||||
mut frac := val - whole
|
||||
mut frac := val - f64(whole)
|
||||
// Quick exit for integers
|
||||
if frac == 0.0 {
|
||||
return fraction(whole, 1)
|
||||
@@ -113,7 +113,7 @@ pub fn approximate_with_eps(val, eps f64) Fraction {
|
||||
if math.fabs(val - partial.f64()) < eps {
|
||||
return partial
|
||||
}
|
||||
frac -= den
|
||||
frac -= f64(den)
|
||||
}
|
||||
panic("Couldn\'t converge. Please create an issue on https://github.com/vlang/v")
|
||||
}
|
||||
|
@@ -56,7 +56,7 @@ fn test_gamma() {
|
||||
|
||||
fn test_mod() {
|
||||
assert 4 % 2 == 0
|
||||
x := 2
|
||||
x := u64(2)
|
||||
assert u64(5) % x == 1
|
||||
mut a := 10
|
||||
a %= 2
|
||||
|
Reference in New Issue
Block a user