ci: fix failing tests

pull/6623/head
Delyan Angelov 2020-10-15 15:42:16 +03:00
parent 8b13f3b53f
commit 5d4cce3e95
5 changed files with 69 additions and 40 deletions

View File

@ -4,52 +4,82 @@
module math
#include <math.h>
$if windows {
$if tinyc {
#flag @VROOT/thirdparty/tcc/lib/openlibm.o
}
}
fn C.acos(x f64) f64
fn C.asin(x f64) f64
fn C.atan(x f64) f64
fn C.atan2(y f64, x f64) f64
fn C.cbrt(x f64) f64
fn C.ceil(x f64) f64
fn C.cos(x f64) f64
fn C.cosf(x f32) f32
fn C.cosh(x f64) f64
fn C.erf(x f64) f64
fn C.erfc(x f64) f64
fn C.exp(x f64) f64
fn C.exp2(x f64) f64
fn C.fabs(x f64) f64
fn C.floor(x f64) f64
fn C.fmod(x f64, y f64) f64
fn C.hypot(x f64, y f64) f64
fn C.log(x f64) f64
fn C.log2(x f64) f64
fn C.log10(x f64) f64
fn C.lgamma(x f64) f64
fn C.pow(x f64, y f64) f64
fn C.powf(x f32, y f32) f32
fn C.round(x f64) f64
fn C.sin(x f64) f64
fn C.sinf(x f32) f32
fn C.sinh(x f64) f64
fn C.sqrt(x f64) f64
fn C.sqrtf(x f32) f32
fn C.tgamma(x f64) f64
fn C.tan(x f64) f64
fn C.tanf(x f32) f32
fn C.tanh(x f64) f64
fn C.trunc(x f64) f64
// NOTE
// When adding a new function, please make sure it's in the right place.
// All functions are sorted alphabetically.
// Returns the absolute value.
[inline]
pub fn abs(a f64) f64 {
@ -76,7 +106,7 @@ pub fn atan(a f64) f64 {
// atan2 calculates inverse tangent with two arguments, returns the angle between the X axis and the point.
[inline]
pub fn atan2(a, b f64) f64 {
pub fn atan2(a f64, b f64) f64 {
return C.atan2(a, b)
}
@ -142,7 +172,7 @@ pub fn floor(a f64) f64 {
// fmod returns the floating-point remainder of number / denom (rounded towards zero):
[inline]
pub fn fmod(a, b f64) f64 {
pub fn fmod(a f64, b f64) f64 {
return C.fmod(a, b)
}
@ -154,7 +184,7 @@ pub fn gamma(a f64) f64 {
// Returns hypotenuse of a right triangle.
[inline]
pub fn hypot(a, b f64) f64 {
pub fn hypot(a f64, b f64) f64 {
return C.hypot(a, b)
}
@ -184,19 +214,19 @@ pub fn log_gamma(a f64) f64 {
// log_n calculates base-N logarithm of the provided value.
[inline]
pub fn log_n(a, b f64) f64 {
pub fn log_n(a f64, b f64) f64 {
return C.log(a) / C.log(b)
}
// pow returns base raised to the provided power.
[inline]
pub fn pow(a, b f64) f64 {
pub fn pow(a f64, b f64) f64 {
return C.pow(a, b)
}
// powf returns base raised to the provided power. (float32)
[inline]
pub fn powf(a, b f32) f32 {
pub fn powf(a f32, b f32) f32 {
return C.powf(a, b)
}

View File

@ -9,10 +9,8 @@ module math
// backend specific functions.
// If using System/Backend dependent functions, put them in their respective
// .c.v or .js.v or other files
// Below are functions that are not wrappers for built-in system functions, but
// native V functions. They are still sorted alphabetically
// Faster approximate sin() and cos() implemented from lolremez
pub fn aprox_sin(a f64) f64 {
a0 := 1.91059300966915117e-31
@ -40,7 +38,7 @@ pub fn aprox_cos(a f64) f64 {
}
// copysign returns a value with the magnitude of x and the sign of y
pub fn copysign(x, y f64) f64 {
pub fn copysign(x f64, y f64) f64 {
return f64_from_bits((f64_bits(x) & ~sign_mask) | (f64_bits(y) & sign_mask))
}
@ -50,7 +48,7 @@ pub fn degrees(radians f64) f64 {
}
// digits returns an array of the digits of n in the given base.
pub fn digits(_n, base int) []int {
pub fn digits(_n int, base int) []int {
if base < 2 {
panic('digits: Cannot find digits of n with base $base')
}
@ -76,7 +74,7 @@ pub fn fabs(x f64) f64 {
}
// gcd calculates greatest common (positive) divisor (or zero if a and b are both zero).
pub fn gcd(a_, b_ i64) i64 {
pub fn gcd(a_ i64, b_ i64) i64 {
mut a := a_
mut b := b_
if a < 0 {
@ -96,7 +94,7 @@ pub fn gcd(a_, b_ i64) i64 {
}
// lcm calculates least common (non-negative) multiple.
pub fn lcm(a, b i64) i64 {
pub fn lcm(a i64, b i64) i64 {
if a == 0 {
return a
}
@ -108,7 +106,7 @@ pub fn lcm(a, b i64) i64 {
}
// max returns the maximum value of the two provided.
pub fn max(a, b f64) f64 {
pub fn max(a f64, b f64) f64 {
if a > b {
return a
}
@ -116,7 +114,7 @@ pub fn max(a, b f64) f64 {
}
// min returns the minimum value of the two provided.
pub fn min(a, b f64) f64 {
pub fn min(a f64, b f64) f64 {
if a < b {
return a
}

View File

@ -13,6 +13,7 @@ pub struct PRNGConfigStruct {
}
__global ( default_rng &wyrand.WyRandRNG )
fn init() {
default_rng = new_default({})
}
@ -50,12 +51,12 @@ pub fn u64n(max u64) u64 {
}
// u32_in_range(min, max) returns a uniformly distributed pseudorandom 32-bit unsigned u32 in _[min, max)_
pub fn u32_in_range(min, max u32) u32 {
pub fn u32_in_range(min u32, max u32) u32 {
return default_rng.u32_in_range(min, max)
}
// u64_in_range(min, max) returns a uniformly distributed pseudorandom 64-bit unsigned u64 in _[min, max)_
pub fn u64_in_range(min, max u64) u64 {
pub fn u64_in_range(min u64, max u64) u64 {
return default_rng.u64_in_range(min, max)
}
@ -71,7 +72,7 @@ pub fn intn(max int) int {
// int_in_range(min, max) returns a uniformly distributed pseudorandom
// 32-bit signed int in [min, max). Both min and max can be negative, but we must have _min < max_.
pub fn int_in_range(min, max int) int {
pub fn int_in_range(min int, max int) int {
return default_rng.int_in_range(min, max)
}
@ -91,7 +92,7 @@ pub fn i64n(max i64) i64 {
}
// i64_in_range(min, max) returns a uniformly distributed pseudorandom 64-bit signed int in _[min, max)_
pub fn i64_in_range(min, max i64) i64 {
pub fn i64_in_range(min i64, max i64) i64 {
return default_rng.i64_in_range(min, max)
}
@ -121,12 +122,12 @@ pub fn f64n(max f64) f64 {
}
// f32_in_range(min, max) returns a uniformly distributed 32-bit floating point in _[min, max)_
pub fn f32_in_range(min, max f32) f32 {
pub fn f32_in_range(min f32, max f32) f32 {
return default_rng.f32_in_range(min, max)
}
// f64_in_range(min, max) returns a uniformly distributed 64-bit floating point in _[min, max)_
pub fn f64_in_range(min, max f64) f64 {
pub fn f64_in_range(min f64, max f64) f64 {
return default_rng.f64_in_range(min, max)
}
@ -141,7 +142,7 @@ pub fn string(len int) string {
buf[i] = chars[intn(chars.len)]
}
}
return unsafe { buf.vstring_with_len(len) }
return unsafe {buf.vstring_with_len(len)}
}
// rand.uuid_v4 generate a completely random UUID (v4)
@ -181,17 +182,17 @@ pub fn uuid_v4() string {
buf[14] = `4`
buf[buflen] = 0
}
return unsafe { buf.vstring_with_len(buflen) }
return unsafe {buf.vstring_with_len(buflen)}
}
const(
ulid_encoding = "0123456789ABCDEFGHJKMNPQRSTVWXYZ"
const (
ulid_encoding = '0123456789ABCDEFGHJKMNPQRSTVWXYZ'
)
// rand.ulid generates an Unique Lexicographically sortable IDentifier.
// See https://github.com/ulid/spec .
// NB: ULIDs can leak timing information, if you make them public, because
// you can infer the rate at which some resource is being created, like
// you can infer the rate at which some resource is being created, like
// users or business transactions.
// (https://news.ycombinator.com/item?id=14526173)
pub fn ulid() string {
@ -204,7 +205,7 @@ pub fn ulid_at_millisecond(unix_time_milli u64) string {
mut t := unix_time_milli
mut i := 9
for i >= 0 {
unsafe{
unsafe {
buf[i] = ulid_encoding[t & 0x1F]
}
t = t >> 5
@ -214,7 +215,7 @@ pub fn ulid_at_millisecond(unix_time_milli u64) string {
mut x := default_rng.u64()
i = 10
for i < 19 {
unsafe{
unsafe {
buf[i] = ulid_encoding[x & 0x1F]
}
x = x >> 5
@ -223,14 +224,14 @@ pub fn ulid_at_millisecond(unix_time_milli u64) string {
// second rand set
x = default_rng.u64()
for i < 26 {
unsafe{
unsafe {
buf[i] = ulid_encoding[x & 0x1F]
}
x = x >> 5
i++
}
unsafe{
unsafe {
buf[26] = 0
}
return unsafe { buf.vstring_with_len(buflen) }
return unsafe {buf.vstring_with_len(buflen)}
}

View File

@ -115,7 +115,7 @@ pub fn (mut rng WyRandRNG) u64n(max u64) u64 {
// rng.u32n(min, max) returns a pseudorandom u32 value that is guaranteed to be in [min, max)
[inline]
pub fn (mut rng WyRandRNG) u32_in_range(min, max u32) u32 {
pub fn (mut rng WyRandRNG) u32_in_range(min u32, max u32) u32 {
if max <= min {
eprintln('max must be greater than min')
exit(1)
@ -125,7 +125,7 @@ pub fn (mut rng WyRandRNG) u32_in_range(min, max u32) u32 {
// rng.u64n(min, max) returns a pseudorandom u64 value that is guaranteed to be in [min, max)
[inline]
pub fn (mut rng WyRandRNG) u64_in_range(min, max u64) u64 {
pub fn (mut rng WyRandRNG) u64_in_range(min u64, max u64) u64 {
if max <= min {
eprintln('max must be greater than min')
exit(1)
@ -179,7 +179,7 @@ pub fn (mut rng WyRandRNG) i64n(max i64) i64 {
// rng.int_in_range(min, max) returns a pseudorandom int that lies in [min, max)
[inline]
pub fn (mut rng WyRandRNG) int_in_range(min, max int) int {
pub fn (mut rng WyRandRNG) int_in_range(min int, max int) int {
if max <= min {
eprintln('max must be greater than min')
exit(1)
@ -190,7 +190,7 @@ pub fn (mut rng WyRandRNG) int_in_range(min, max int) int {
// rng.i64_in_range(min, max) returns a pseudorandom i64 that lies in [min, max)
[inline]
pub fn (mut rng WyRandRNG) i64_in_range(min, max i64) i64 {
pub fn (mut rng WyRandRNG) i64_in_range(min i64, max i64) i64 {
if max <= min {
eprintln('max must be greater than min')
exit(1)
@ -232,7 +232,7 @@ pub fn (mut rng WyRandRNG) f64n(max f64) f64 {
// rng.f32_in_range(min, max) returns a pseudorandom f32 that lies in [min, max)
[inline]
pub fn (mut rng WyRandRNG) f32_in_range(min, max f32) f32 {
pub fn (mut rng WyRandRNG) f32_in_range(min f32, max f32) f32 {
if max <= min {
eprintln('max must be greater than min')
exit(1)
@ -242,7 +242,7 @@ pub fn (mut rng WyRandRNG) f32_in_range(min, max f32) f32 {
// rng.i64_in_range(min, max) returns a pseudorandom i64 that lies in [min, max)
[inline]
pub fn (mut rng WyRandRNG) f64_in_range(min, max f64) f64 {
pub fn (mut rng WyRandRNG) f64_in_range(min f64, max f64) f64 {
if max <= min {
eprintln('max must be greater than min')
exit(1)

View File

@ -9,7 +9,7 @@ fn getint() int {
return 8
}
fn f1(ch1 chan int, ch2 chan St, ch3, ch4, ch5 chan int, sem sync.Semaphore) {
fn f1(ch1 chan int, ch2 chan St, ch3 chan int, ch4 chan int, ch5 chan int, sem sync.Semaphore) {
mut a := 5
select {
// pre comment