Skip to content

Commit

Permalink
tests: make 'test-self' pass under msys2/MINGW32 (#20614)
Browse files Browse the repository at this point in the history
  • Loading branch information
smalltalkman committed Jan 21, 2024
1 parent 55287b3 commit bc37c85
Show file tree
Hide file tree
Showing 7 changed files with 41 additions and 10 deletions.
4 changes: 3 additions & 1 deletion cmd/tools/vtest-self.v
Original file line number Diff line number Diff line change
Expand Up @@ -321,6 +321,8 @@ const skip_on_non_amd64_or_arm64 = [
'do_not_remove',
// closures aren't implemented yet:
'vlib/v/tests/closure_test.v',
// native aren't implemented:
'vlib/v/gen/native/tests/native_test.v',
'vlib/context/cancel_test.v',
'vlib/context/deadline_test.v',
'vlib/context/empty_test.v',
Expand Down Expand Up @@ -437,7 +439,7 @@ fn main() {
tsession.skip_files << skip_on_ubuntu_musl
}
$if !amd64 && !arm64 {
tsession.skip_files << skip_on_non_amd64
tsession.skip_files << skip_on_non_amd64_or_arm64
}
$if amd64 {
tsession.skip_files << skip_on_amd64
Expand Down
6 changes: 3 additions & 3 deletions vlib/gg/m4/m4_test.v
Original file line number Diff line number Diff line change
Expand Up @@ -230,8 +230,8 @@ fn test_vec4() {

fn test_proj() {
ort := m4.ortho(0,300,0,200,0,0)
assert m4.mul_vec(ort, m4.Vec4{[ f32(150), 100, 0, 1]!}) == m4.Vec4{[ f32(0), 0, 0, 1]!}
assert m4.mul_vec(ort, m4.Vec4{[ f32(0), 0, 0, 1]!}) == m4.Vec4{[ f32(-1), -1, 0, 1]!}
assert m4.mul_vec(ort, m4.Vec4{[ f32(300), 200, 0, 1]!}) == m4.Vec4{[ f32(1), 1, 0, 1]!}
assert m4.mul_vec(ort, m4.Vec4{[ f32(150), 100, 0, 1]!}).is_equal(m4.Vec4{[ f32(0), 0, 0, 1]!})
assert m4.mul_vec(ort, m4.Vec4{[ f32(0), 0, 0, 1]!}).is_equal(m4.Vec4{[ f32(-1), -1, 0, 1]!})
assert m4.mul_vec(ort, m4.Vec4{[ f32(300), 200, 0, 1]!}).is_equal(m4.Vec4{[ f32(1), 1, 0, 1]!})
}
// vfmt on
13 changes: 13 additions & 0 deletions vlib/gg/m4/vector.v
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,19 @@ pub fn vec3(x f32, y f32, z f32) Vec4 {
}
}

// Check if two vector are equal using module precision
@[direct_array_access]
pub fn (x Vec4) is_equal(y Vec4) bool {
unsafe {
for c, value in x.e {
if f32_abs(value - y.e[c]) > precision {
return false
}
}
return true
}
}

// Remove all the raw zeros
@[direct_array_access]
pub fn (a Vec4) clean() Vec4 {
Expand Down
6 changes: 5 additions & 1 deletion vlib/v/checker/comptime.v
Original file line number Diff line number Diff line change
Expand Up @@ -878,7 +878,11 @@ fn (mut c Checker) comptime_if_branch(mut cond ast.Expr, pos token.Pos) Comptime
else { return .unknown }
}
} else if cname in ast.valid_comptime_if_cpu_features {
return .unknown
match cname {
'x64' { return if c.pref.m64 { .eval } else { .skip } }
'x32' { return if !c.pref.m64 { .eval } else { .skip } }
else { return .unknown }
}
} else if cname in ast.valid_comptime_if_other {
match cname {
'apk' {
Expand Down
6 changes: 5 additions & 1 deletion vlib/v/tests/generics_fn_variable_2_test.v
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,11 @@ fn test_generic_fn_variable() {

r2 := f[string]()
println(r2)
assert r2 == 16
assert r2 == $if x64 {
16
} $else {
12
}

r3 := f[f64]()
println(r3)
Expand Down
12 changes: 10 additions & 2 deletions vlib/v/tests/sizeof_test.v
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,14 @@ fn test_sizeof() {
assert sizeof(flag.Flag) > 4

assert sizeof(c'hello') == 6
assert sizeof(r'hello') == 16
assert sizeof('hello') == 16
assert sizeof(r'hello') == $if x64 {
16
} $else {
12
}
assert sizeof('hello') == $if x64 {
16
} $else {
12
}
}
4 changes: 2 additions & 2 deletions vlib/v/tests/type_alias_test.v
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ fn test_type_alias() {
i := Myint(10)
assert i + 100 == 110
f := Myf32(7.4)
assert f + f32(0.6) == f32(8.0)
assert (f + f32(0.6)).eq_epsilon(f32(8.0))
g := Myf64(10.4)
assert g + 0.5 == 10.9
}
Expand All @@ -19,7 +19,7 @@ fn test_type_alias_v2() {
i := Myint_2(10)
assert i + 100 == 110
f := Myf32_2(7.4)
assert f + f32(0.6) == f32(8.0)
assert (f + f32(0.6)).eq_epsilon(f32(8.0))
g := Myf64_2(10.4)
assert g + 0.5 == 10.9
// test ++ on an alias
Expand Down

0 comments on commit bc37c85

Please sign in to comment.