diff --git a/cmd/tools/vtest-self.v b/cmd/tools/vtest-self.v index ec88a6cff89307..13f440a9bc52ba 100644 --- a/cmd/tools/vtest-self.v +++ b/cmd/tools/vtest-self.v @@ -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', @@ -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 diff --git a/vlib/gg/m4/m4_test.v b/vlib/gg/m4/m4_test.v index ff8ffdf6bc2981..ae32beb22fb3ea 100644 --- a/vlib/gg/m4/m4_test.v +++ b/vlib/gg/m4/m4_test.v @@ -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 diff --git a/vlib/gg/m4/vector.v b/vlib/gg/m4/vector.v index 94c395dabc4881..b760158cf785e8 100644 --- a/vlib/gg/m4/vector.v +++ b/vlib/gg/m4/vector.v @@ -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 { diff --git a/vlib/v/checker/comptime.v b/vlib/v/checker/comptime.v index 80b0290f4b505e..46acbff90afa25 100644 --- a/vlib/v/checker/comptime.v +++ b/vlib/v/checker/comptime.v @@ -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' { diff --git a/vlib/v/tests/generics_fn_variable_2_test.v b/vlib/v/tests/generics_fn_variable_2_test.v index c92cd6b96789a7..e63e07711b3318 100644 --- a/vlib/v/tests/generics_fn_variable_2_test.v +++ b/vlib/v/tests/generics_fn_variable_2_test.v @@ -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) diff --git a/vlib/v/tests/sizeof_test.v b/vlib/v/tests/sizeof_test.v index 8087f15d00c7ee..98f2d9b33052aa 100644 --- a/vlib/v/tests/sizeof_test.v +++ b/vlib/v/tests/sizeof_test.v @@ -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 + } } diff --git a/vlib/v/tests/type_alias_test.v b/vlib/v/tests/type_alias_test.v index e5601d215a020e..b7e35525bebf4f 100644 --- a/vlib/v/tests/type_alias_test.v +++ b/vlib/v/tests/type_alias_test.v @@ -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 } @@ -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