tests: update for stricter type checks
parent
4e66c12557
commit
fd4d28b7b6
|
@ -31,7 +31,7 @@ fn test_float_equal_operator() {
|
||||||
assert a.gebit(1)
|
assert a.gebit(1)
|
||||||
assert -1 == 1 * -1
|
assert -1 == 1 * -1
|
||||||
assert -1.0 == 1.0 * -1.0
|
assert -1.0 == 1.0 * -1.0
|
||||||
a = f64(1)
|
a = 1
|
||||||
a += 0.000001
|
a += 0.000001
|
||||||
a -= 0.000001
|
a -= 0.000001
|
||||||
assert a == f32(1.0)
|
assert a == f32(1.0)
|
||||||
|
|
|
@ -128,7 +128,7 @@ pub struct Clipboard {
|
||||||
struct Property{
|
struct Property{
|
||||||
actual_type C.Atom
|
actual_type C.Atom
|
||||||
actual_format int
|
actual_format int
|
||||||
nitems int
|
nitems u64
|
||||||
data byteptr
|
data byteptr
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -61,7 +61,7 @@ fn encrypt_block_generic(xk []u32, dst, src []byte) {
|
||||||
mut t1 := u32(0)
|
mut t1 := u32(0)
|
||||||
mut t2 := u32(0)
|
mut t2 := u32(0)
|
||||||
mut t3 := u32(0)
|
mut t3 := u32(0)
|
||||||
for r in 0..nr {
|
for _ in 0..nr {
|
||||||
t0 = xk[k+0] ^ te0[byte(s0>>24)] ^ te1[byte(s1>>16)] ^ te2[byte(s2>>8)] ^ u32(te3[byte(s3)])
|
t0 = xk[k+0] ^ te0[byte(s0>>24)] ^ te1[byte(s1>>16)] ^ te2[byte(s2>>8)] ^ u32(te3[byte(s3)])
|
||||||
t1 = xk[k+1] ^ te0[byte(s1>>24)] ^ te1[byte(s2>>16)] ^ te2[byte(s3>>8)] ^ u32(te3[byte(s0)])
|
t1 = xk[k+1] ^ te0[byte(s1>>24)] ^ te1[byte(s2>>16)] ^ te2[byte(s3>>8)] ^ u32(te3[byte(s0)])
|
||||||
t2 = xk[k+2] ^ te0[byte(s2>>24)] ^ te1[byte(s3>>16)] ^ te2[byte(s0>>8)] ^ u32(te3[byte(s1)])
|
t2 = xk[k+2] ^ te0[byte(s2>>24)] ^ te1[byte(s3>>16)] ^ te2[byte(s0>>8)] ^ u32(te3[byte(s1)])
|
||||||
|
@ -113,7 +113,7 @@ fn decrypt_block_generic(xk []u32, dst, src []byte) {
|
||||||
mut t1 := u32(0)
|
mut t1 := u32(0)
|
||||||
mut t2 := u32(0)
|
mut t2 := u32(0)
|
||||||
mut t3 := u32(0)
|
mut t3 := u32(0)
|
||||||
for r in 0..nr {
|
for _ in 0..nr {
|
||||||
t0 = xk[k+0] ^ td0[byte(s0>>24)] ^ td1[byte(s3>>16)] ^ td2[byte(s2>>8)] ^ u32(td3[byte(s1)])
|
t0 = xk[k+0] ^ td0[byte(s0>>24)] ^ td1[byte(s3>>16)] ^ td2[byte(s2>>8)] ^ u32(td3[byte(s1)])
|
||||||
t1 = xk[k+1] ^ td0[byte(s1>>24)] ^ td1[byte(s0>>16)] ^ td2[byte(s3>>8)] ^ u32(td3[byte(s2)])
|
t1 = xk[k+1] ^ td0[byte(s1>>24)] ^ td1[byte(s0>>16)] ^ td2[byte(s3>>8)] ^ u32(td3[byte(s2)])
|
||||||
t2 = xk[k+2] ^ td0[byte(s2>>24)] ^ td1[byte(s1>>16)] ^ td2[byte(s0>>8)] ^ u32(td3[byte(s3)])
|
t2 = xk[k+2] ^ td0[byte(s2>>24)] ^ td1[byte(s1>>16)] ^ td2[byte(s0>>8)] ^ u32(td3[byte(s3)])
|
||||||
|
|
|
@ -96,7 +96,7 @@ const (
|
||||||
|
|
||||||
const (
|
const (
|
||||||
te0 = [
|
te0 = [
|
||||||
0xc66363a5, 0xf87c7c84, 0xee777799, 0xf67b7b8d, 0xfff2f20d, 0xd66b6bbd, 0xde6f6fb1, 0x91c5c554,
|
u32(0xc66363a5), 0xf87c7c84, 0xee777799, 0xf67b7b8d, 0xfff2f20d, 0xd66b6bbd, 0xde6f6fb1, 0x91c5c554,
|
||||||
0x60303050, 0x02010103, 0xce6767a9, 0x562b2b7d, 0xe7fefe19, 0xb5d7d762, 0x4dababe6, 0xec76769a,
|
0x60303050, 0x02010103, 0xce6767a9, 0x562b2b7d, 0xe7fefe19, 0xb5d7d762, 0x4dababe6, 0xec76769a,
|
||||||
0x8fcaca45, 0x1f82829d, 0x89c9c940, 0xfa7d7d87, 0xeffafa15, 0xb25959eb, 0x8e4747c9, 0xfbf0f00b,
|
0x8fcaca45, 0x1f82829d, 0x89c9c940, 0xfa7d7d87, 0xeffafa15, 0xb25959eb, 0x8e4747c9, 0xfbf0f00b,
|
||||||
0x41adadec, 0xb3d4d467, 0x5fa2a2fd, 0x45afafea, 0x239c9cbf, 0x53a4a4f7, 0xe4727296, 0x9bc0c05b,
|
0x41adadec, 0xb3d4d467, 0x5fa2a2fd, 0x45afafea, 0x239c9cbf, 0x53a4a4f7, 0xe4727296, 0x9bc0c05b,
|
||||||
|
@ -130,7 +130,7 @@ const (
|
||||||
0x824141c3, 0x299999b0, 0x5a2d2d77, 0x1e0f0f11, 0x7bb0b0cb, 0xa85454fc, 0x6dbbbbd6, 0x2c16163a,
|
0x824141c3, 0x299999b0, 0x5a2d2d77, 0x1e0f0f11, 0x7bb0b0cb, 0xa85454fc, 0x6dbbbbd6, 0x2c16163a,
|
||||||
]
|
]
|
||||||
te1 = [
|
te1 = [
|
||||||
0xa5c66363, 0x84f87c7c, 0x99ee7777, 0x8df67b7b, 0x0dfff2f2, 0xbdd66b6b, 0xb1de6f6f, 0x5491c5c5,
|
u32(0xa5c66363), 0x84f87c7c, 0x99ee7777, 0x8df67b7b, 0x0dfff2f2, 0xbdd66b6b, 0xb1de6f6f, 0x5491c5c5,
|
||||||
0x50603030, 0x03020101, 0xa9ce6767, 0x7d562b2b, 0x19e7fefe, 0x62b5d7d7, 0xe64dabab, 0x9aec7676,
|
0x50603030, 0x03020101, 0xa9ce6767, 0x7d562b2b, 0x19e7fefe, 0x62b5d7d7, 0xe64dabab, 0x9aec7676,
|
||||||
0x458fcaca, 0x9d1f8282, 0x4089c9c9, 0x87fa7d7d, 0x15effafa, 0xebb25959, 0xc98e4747, 0x0bfbf0f0,
|
0x458fcaca, 0x9d1f8282, 0x4089c9c9, 0x87fa7d7d, 0x15effafa, 0xebb25959, 0xc98e4747, 0x0bfbf0f0,
|
||||||
0xec41adad, 0x67b3d4d4, 0xfd5fa2a2, 0xea45afaf, 0xbf239c9c, 0xf753a4a4, 0x96e47272, 0x5b9bc0c0,
|
0xec41adad, 0x67b3d4d4, 0xfd5fa2a2, 0xea45afaf, 0xbf239c9c, 0xf753a4a4, 0x96e47272, 0x5b9bc0c0,
|
||||||
|
@ -164,7 +164,7 @@ const (
|
||||||
0xc3824141, 0xb0299999, 0x775a2d2d, 0x111e0f0f, 0xcb7bb0b0, 0xfca85454, 0xd66dbbbb, 0x3a2c1616,
|
0xc3824141, 0xb0299999, 0x775a2d2d, 0x111e0f0f, 0xcb7bb0b0, 0xfca85454, 0xd66dbbbb, 0x3a2c1616,
|
||||||
]
|
]
|
||||||
te2 = [
|
te2 = [
|
||||||
0x63a5c663, 0x7c84f87c, 0x7799ee77, 0x7b8df67b, 0xf20dfff2, 0x6bbdd66b, 0x6fb1de6f, 0xc55491c5,
|
u32(0x63a5c663), 0x7c84f87c, 0x7799ee77, 0x7b8df67b, 0xf20dfff2, 0x6bbdd66b, 0x6fb1de6f, 0xc55491c5,
|
||||||
0x30506030, 0x01030201, 0x67a9ce67, 0x2b7d562b, 0xfe19e7fe, 0xd762b5d7, 0xabe64dab, 0x769aec76,
|
0x30506030, 0x01030201, 0x67a9ce67, 0x2b7d562b, 0xfe19e7fe, 0xd762b5d7, 0xabe64dab, 0x769aec76,
|
||||||
0xca458fca, 0x829d1f82, 0xc94089c9, 0x7d87fa7d, 0xfa15effa, 0x59ebb259, 0x47c98e47, 0xf00bfbf0,
|
0xca458fca, 0x829d1f82, 0xc94089c9, 0x7d87fa7d, 0xfa15effa, 0x59ebb259, 0x47c98e47, 0xf00bfbf0,
|
||||||
0xadec41ad, 0xd467b3d4, 0xa2fd5fa2, 0xafea45af, 0x9cbf239c, 0xa4f753a4, 0x7296e472, 0xc05b9bc0,
|
0xadec41ad, 0xd467b3d4, 0xa2fd5fa2, 0xafea45af, 0x9cbf239c, 0xa4f753a4, 0x7296e472, 0xc05b9bc0,
|
||||||
|
@ -198,7 +198,7 @@ const (
|
||||||
0x41c38241, 0x99b02999, 0x2d775a2d, 0x0f111e0f, 0xb0cb7bb0, 0x54fca854, 0xbbd66dbb, 0x163a2c16,
|
0x41c38241, 0x99b02999, 0x2d775a2d, 0x0f111e0f, 0xb0cb7bb0, 0x54fca854, 0xbbd66dbb, 0x163a2c16,
|
||||||
]
|
]
|
||||||
te3 = [
|
te3 = [
|
||||||
0x6363a5c6, 0x7c7c84f8, 0x777799ee, 0x7b7b8df6, 0xf2f20dff, 0x6b6bbdd6, 0x6f6fb1de, 0xc5c55491,
|
u32(0x6363a5c6), 0x7c7c84f8, 0x777799ee, 0x7b7b8df6, 0xf2f20dff, 0x6b6bbdd6, 0x6f6fb1de, 0xc5c55491,
|
||||||
0x30305060, 0x01010302, 0x6767a9ce, 0x2b2b7d56, 0xfefe19e7, 0xd7d762b5, 0xababe64d, 0x76769aec,
|
0x30305060, 0x01010302, 0x6767a9ce, 0x2b2b7d56, 0xfefe19e7, 0xd7d762b5, 0xababe64d, 0x76769aec,
|
||||||
0xcaca458f, 0x82829d1f, 0xc9c94089, 0x7d7d87fa, 0xfafa15ef, 0x5959ebb2, 0x4747c98e, 0xf0f00bfb,
|
0xcaca458f, 0x82829d1f, 0xc9c94089, 0x7d7d87fa, 0xfafa15ef, 0x5959ebb2, 0x4747c98e, 0xf0f00bfb,
|
||||||
0xadadec41, 0xd4d467b3, 0xa2a2fd5f, 0xafafea45, 0x9c9cbf23, 0xa4a4f753, 0x727296e4, 0xc0c05b9b,
|
0xadadec41, 0xd4d467b3, 0xa2a2fd5f, 0xafafea45, 0x9c9cbf23, 0xa4a4f753, 0x727296e4, 0xc0c05b9b,
|
||||||
|
@ -236,7 +236,7 @@ const (
|
||||||
// Lookup tables for decryption.
|
// Lookup tables for decryption.
|
||||||
const (
|
const (
|
||||||
td0 = [
|
td0 = [
|
||||||
0x51f4a750, 0x7e416553, 0x1a17a4c3, 0x3a275e96, 0x3bab6bcb, 0x1f9d45f1, 0xacfa58ab, 0x4be30393,
|
u32(0x51f4a750), 0x7e416553, 0x1a17a4c3, 0x3a275e96, 0x3bab6bcb, 0x1f9d45f1, 0xacfa58ab, 0x4be30393,
|
||||||
0x2030fa55, 0xad766df6, 0x88cc7691, 0xf5024c25, 0x4fe5d7fc, 0xc52acbd7, 0x26354480, 0xb562a38f,
|
0x2030fa55, 0xad766df6, 0x88cc7691, 0xf5024c25, 0x4fe5d7fc, 0xc52acbd7, 0x26354480, 0xb562a38f,
|
||||||
0xdeb15a49, 0x25ba1b67, 0x45ea0e98, 0x5dfec0e1, 0xc32f7502, 0x814cf012, 0x8d4697a3, 0x6bd3f9c6,
|
0xdeb15a49, 0x25ba1b67, 0x45ea0e98, 0x5dfec0e1, 0xc32f7502, 0x814cf012, 0x8d4697a3, 0x6bd3f9c6,
|
||||||
0x038f5fe7, 0x15929c95, 0xbf6d7aeb, 0x955259da, 0xd4be832d, 0x587421d3, 0x49e06929, 0x8ec9c844,
|
0x038f5fe7, 0x15929c95, 0xbf6d7aeb, 0x955259da, 0xd4be832d, 0x587421d3, 0x49e06929, 0x8ec9c844,
|
||||||
|
@ -270,7 +270,7 @@ const (
|
||||||
0x39a80171, 0x080cb3de, 0xd8b4e49c, 0x6456c190, 0x7bcb8461, 0xd532b670, 0x486c5c74, 0xd0b85742,
|
0x39a80171, 0x080cb3de, 0xd8b4e49c, 0x6456c190, 0x7bcb8461, 0xd532b670, 0x486c5c74, 0xd0b85742,
|
||||||
]
|
]
|
||||||
td1 = [
|
td1 = [
|
||||||
0x5051f4a7, 0x537e4165, 0xc31a17a4, 0x963a275e, 0xcb3bab6b, 0xf11f9d45, 0xabacfa58, 0x934be303,
|
u32(0x5051f4a7), 0x537e4165, 0xc31a17a4, 0x963a275e, 0xcb3bab6b, 0xf11f9d45, 0xabacfa58, 0x934be303,
|
||||||
0x552030fa, 0xf6ad766d, 0x9188cc76, 0x25f5024c, 0xfc4fe5d7, 0xd7c52acb, 0x80263544, 0x8fb562a3,
|
0x552030fa, 0xf6ad766d, 0x9188cc76, 0x25f5024c, 0xfc4fe5d7, 0xd7c52acb, 0x80263544, 0x8fb562a3,
|
||||||
0x49deb15a, 0x6725ba1b, 0x9845ea0e, 0xe15dfec0, 0x02c32f75, 0x12814cf0, 0xa38d4697, 0xc66bd3f9,
|
0x49deb15a, 0x6725ba1b, 0x9845ea0e, 0xe15dfec0, 0x02c32f75, 0x12814cf0, 0xa38d4697, 0xc66bd3f9,
|
||||||
0xe7038f5f, 0x9515929c, 0xebbf6d7a, 0xda955259, 0x2dd4be83, 0xd3587421, 0x2949e069, 0x448ec9c8,
|
0xe7038f5f, 0x9515929c, 0xebbf6d7a, 0xda955259, 0x2dd4be83, 0xd3587421, 0x2949e069, 0x448ec9c8,
|
||||||
|
@ -304,7 +304,7 @@ const (
|
||||||
0x7139a801, 0xde080cb3, 0x9cd8b4e4, 0x906456c1, 0x617bcb84, 0x70d532b6, 0x74486c5c, 0x42d0b857,
|
0x7139a801, 0xde080cb3, 0x9cd8b4e4, 0x906456c1, 0x617bcb84, 0x70d532b6, 0x74486c5c, 0x42d0b857,
|
||||||
]
|
]
|
||||||
td2 = [
|
td2 = [
|
||||||
0xa75051f4, 0x65537e41, 0xa4c31a17, 0x5e963a27, 0x6bcb3bab, 0x45f11f9d, 0x58abacfa, 0x03934be3,
|
u32(0xa75051f4), 0x65537e41, 0xa4c31a17, 0x5e963a27, 0x6bcb3bab, 0x45f11f9d, 0x58abacfa, 0x03934be3,
|
||||||
0xfa552030, 0x6df6ad76, 0x769188cc, 0x4c25f502, 0xd7fc4fe5, 0xcbd7c52a, 0x44802635, 0xa38fb562,
|
0xfa552030, 0x6df6ad76, 0x769188cc, 0x4c25f502, 0xd7fc4fe5, 0xcbd7c52a, 0x44802635, 0xa38fb562,
|
||||||
0x5a49deb1, 0x1b6725ba, 0x0e9845ea, 0xc0e15dfe, 0x7502c32f, 0xf012814c, 0x97a38d46, 0xf9c66bd3,
|
0x5a49deb1, 0x1b6725ba, 0x0e9845ea, 0xc0e15dfe, 0x7502c32f, 0xf012814c, 0x97a38d46, 0xf9c66bd3,
|
||||||
0x5fe7038f, 0x9c951592, 0x7aebbf6d, 0x59da9552, 0x832dd4be, 0x21d35874, 0x692949e0, 0xc8448ec9,
|
0x5fe7038f, 0x9c951592, 0x7aebbf6d, 0x59da9552, 0x832dd4be, 0x21d35874, 0x692949e0, 0xc8448ec9,
|
||||||
|
@ -338,7 +338,7 @@ const (
|
||||||
0x017139a8, 0xb3de080c, 0xe49cd8b4, 0xc1906456, 0x84617bcb, 0xb670d532, 0x5c74486c, 0x5742d0b8,
|
0x017139a8, 0xb3de080c, 0xe49cd8b4, 0xc1906456, 0x84617bcb, 0xb670d532, 0x5c74486c, 0x5742d0b8,
|
||||||
]
|
]
|
||||||
td3 = [
|
td3 = [
|
||||||
0xf4a75051, 0x4165537e, 0x17a4c31a, 0x275e963a, 0xab6bcb3b, 0x9d45f11f, 0xfa58abac, 0xe303934b,
|
u32(0xf4a75051), 0x4165537e, 0x17a4c31a, 0x275e963a, 0xab6bcb3b, 0x9d45f11f, 0xfa58abac, 0xe303934b,
|
||||||
0x30fa5520, 0x766df6ad, 0xcc769188, 0x024c25f5, 0xe5d7fc4f, 0x2acbd7c5, 0x35448026, 0x62a38fb5,
|
0x30fa5520, 0x766df6ad, 0xcc769188, 0x024c25f5, 0xe5d7fc4f, 0x2acbd7c5, 0x35448026, 0x62a38fb5,
|
||||||
0xb15a49de, 0xba1b6725, 0xea0e9845, 0xfec0e15d, 0x2f7502c3, 0x4cf01281, 0x4697a38d, 0xd3f9c66b,
|
0xb15a49de, 0xba1b6725, 0xea0e9845, 0xfec0e15d, 0x2f7502c3, 0x4cf01281, 0x4697a38d, 0xd3f9c66b,
|
||||||
0x8f5fe703, 0x929c9515, 0x6d7aebbf, 0x5259da95, 0xbe832dd4, 0x7421d358, 0xe0692949, 0xc9c8448e,
|
0x8f5fe703, 0x929c9515, 0x6d7aebbf, 0x5259da95, 0xbe832dd4, 0x7421d358, 0xe0692949, 0xc9c8448e,
|
||||||
|
|
|
@ -107,8 +107,8 @@ pub fn (mut d Digest) checksum() []byte {
|
||||||
// tmp := [1 + 63 + 8]byte{0x80}
|
// tmp := [1 + 63 + 8]byte{0x80}
|
||||||
mut tmp := [byte(0)].repeat(1 + 63 + 8)
|
mut tmp := [byte(0)].repeat(1 + 63 + 8)
|
||||||
tmp[0] = 0x80
|
tmp[0] = 0x80
|
||||||
pad := ((55 - int(d.len)) % u64(64)) // calculate number of padding bytes
|
pad := ((55 - d.len) % 64) // calculate number of padding bytes
|
||||||
binary.little_endian_put_u64(mut tmp[1+pad..], d.len<<u64(3)) // append length in bits
|
binary.little_endian_put_u64(mut tmp[1+pad..], d.len<<3) // append length in bits
|
||||||
d.write(tmp[..1+pad+8])
|
d.write(tmp[..1+pad+8])
|
||||||
|
|
||||||
// The previous write ensures that a whole number of
|
// The previous write ensures that a whole number of
|
||||||
|
|
|
@ -101,9 +101,9 @@ pub fn decode_in_buffer(data &string, buffer byteptr) int {
|
||||||
}
|
}
|
||||||
|
|
||||||
decoded_bytes := (char_a << 18) | (char_b << 12) | (char_c << 6) | (char_d << 0)
|
decoded_bytes := (char_a << 18) | (char_b << 12) | (char_c << 6) | (char_d << 0)
|
||||||
b[j] = decoded_bytes >> 16
|
b[j] = byte(decoded_bytes >> 16)
|
||||||
b[j+1] = (decoded_bytes >> 8) & 0xff
|
b[j+1] = byte((decoded_bytes >> 8) & 0xff)
|
||||||
b[j+2] = (decoded_bytes >> 0) & 0xff
|
b[j+2] = byte((decoded_bytes >> 0) & 0xff)
|
||||||
j += 3
|
j += 3
|
||||||
}
|
}
|
||||||
return output_length
|
return output_length
|
||||||
|
|
|
@ -14,14 +14,14 @@ fn test_long_encoding(){
|
||||||
mut s := 0
|
mut s := 0
|
||||||
|
|
||||||
ebuffer := malloc( s_encoded.len )
|
ebuffer := malloc( s_encoded.len )
|
||||||
for i in 0..repeats {
|
for _ in 0..repeats {
|
||||||
resultsize := base64.encode_in_buffer(s_original, ebuffer)
|
resultsize := base64.encode_in_buffer(s_original, ebuffer)
|
||||||
s += resultsize
|
s += resultsize
|
||||||
assert resultsize == s_encoded.len
|
assert resultsize == s_encoded.len
|
||||||
}
|
}
|
||||||
|
|
||||||
dbuffer := malloc( s_decoded.len )
|
dbuffer := malloc( s_decoded.len )
|
||||||
for i in 0..repeats {
|
for _ in 0..repeats {
|
||||||
resultsize := base64.decode_in_buffer(s_encoded, dbuffer)
|
resultsize := base64.decode_in_buffer(s_encoded, dbuffer)
|
||||||
s += resultsize
|
s += resultsize
|
||||||
assert resultsize == s_decoded.len
|
assert resultsize == s_decoded.len
|
||||||
|
|
|
@ -172,9 +172,9 @@ fn up_low(s string, upper_flag bool) string {
|
||||||
|
|
||||||
if ch_len == 1 {
|
if ch_len == 1 {
|
||||||
if upper_flag==true {
|
if upper_flag==true {
|
||||||
str_res[index] = C.toupper(s.str[index])
|
str_res[index] = byte(C.toupper(s.str[index]))
|
||||||
}else{
|
}else{
|
||||||
str_res[index] = C.tolower(s.str[index])
|
str_res[index] = byte(C.tolower(s.str[index]))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if ch_len > 1 && ch_len < 5{
|
else if ch_len > 1 && ch_len < 5{
|
||||||
|
|
|
@ -77,8 +77,8 @@ pub fn (m Mat4) str() string {
|
||||||
|
|
||||||
fn vec2(x, y int) Vec2 {
|
fn vec2(x, y int) Vec2 {
|
||||||
res := Vec2 {
|
res := Vec2 {
|
||||||
x: x,
|
x: f32(x),
|
||||||
y: y,
|
y: f32(y),
|
||||||
}
|
}
|
||||||
return res
|
return res
|
||||||
}
|
}
|
||||||
|
@ -131,7 +131,7 @@ fn rotate(m Mat4, angle f32, vec Vec3) Mat4 {
|
||||||
*/
|
*/
|
||||||
|
|
||||||
fn f32_calloc(n int) &f32 {
|
fn f32_calloc(n int) &f32 {
|
||||||
return &f32(vcalloc(n * sizeof(f32)))
|
return voidptr(vcalloc(n * int(sizeof(f32))))
|
||||||
}
|
}
|
||||||
// fn translate(vec Vec3) *f32 {
|
// fn translate(vec Vec3) *f32 {
|
||||||
pub fn translate(m Mat4, v Vec3) Mat4 {
|
pub fn translate(m Mat4, v Vec3) Mat4 {
|
||||||
|
@ -273,9 +273,9 @@ fn mult_mat_point(a Mat4, point Mat4) Mat4 {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn rotate(angle f32, axis Vec3, src Mat4) Mat4 {
|
pub fn rotate(angle f32, axis Vec3, src Mat4) Mat4 {
|
||||||
c := math.cos(angle)
|
c := f32(math.cos(angle))
|
||||||
s := math.sin(angle)
|
s := f32(math.sin(angle))
|
||||||
oneminusc := 1.0 - c
|
oneminusc := f32(1.0) - c
|
||||||
|
|
||||||
xy := axis.x * axis.y
|
xy := axis.x * axis.y
|
||||||
yz := axis.y * axis.z
|
yz := axis.y * axis.z
|
||||||
|
@ -325,8 +325,8 @@ pub fn rotate(angle f32, axis Vec3, src Mat4) Mat4 {
|
||||||
pub fn rotate_z(m Mat4, rad f32) Mat4 {
|
pub fn rotate_z(m Mat4, rad f32) Mat4 {
|
||||||
a := m.data
|
a := m.data
|
||||||
mut out := f32_calloc(16)
|
mut out := f32_calloc(16)
|
||||||
s := math.sin(rad)
|
s := f32(math.sin(rad))
|
||||||
c := math.cos(rad)
|
c := f32(math.cos(rad))
|
||||||
a00 := a[0]
|
a00 := a[0]
|
||||||
a01 := a[1]
|
a01 := a[1]
|
||||||
a02 := a[2]
|
a02 := a[2]
|
||||||
|
@ -361,7 +361,7 @@ pub fn identity() Mat4 {
|
||||||
// 0 0 1 0
|
// 0 0 1 0
|
||||||
// 0 0 0 1
|
// 0 0 0 1
|
||||||
n := 16
|
n := 16
|
||||||
mut res := f32_calloc(sizeof(f32) * n)
|
mut res := f32_calloc(int(sizeof(f32)) * n)
|
||||||
res[0] = 1
|
res[0] = 1
|
||||||
res[5] = 1
|
res[5] = 1
|
||||||
res[10] = 1
|
res[10] = 1
|
||||||
|
@ -396,7 +396,7 @@ fn ortho_js(left, right, bottom, top f32) &f32 {
|
||||||
// myfar := 1
|
// myfar := 1
|
||||||
lr := 1.0 / (left - right)
|
lr := 1.0 / (left - right)
|
||||||
bt := 1.0 / (bottom - top)
|
bt := 1.0 / (bottom - top)
|
||||||
nf := 1.0 / 1.0// (mynear -myfar)
|
nf := f32(1.0) / 1.0// (mynear -myfar)
|
||||||
mut out := &f32(0)
|
mut out := &f32(0)
|
||||||
unsafe { out = &f32( malloc (sizeof(f32) * 16)) }
|
unsafe { out = &f32( malloc (sizeof(f32) * 16)) }
|
||||||
out[0] = -2.0 * lr
|
out[0] = -2.0 * lr
|
||||||
|
|
|
@ -89,12 +89,12 @@ fn test_bits(){
|
||||||
|
|
||||||
// 8 bit
|
// 8 bit
|
||||||
i = 0
|
i = 0
|
||||||
for x in 0..9 {
|
for _ in 0..9 {
|
||||||
mut rv := byte(0)
|
mut rv := byte(0)
|
||||||
mut bc := 0
|
mut bc := 0
|
||||||
mut n := i
|
mut n := i
|
||||||
for bc < 8 {
|
for bc < 8 {
|
||||||
rv = (rv << 1) | (n & 0x01)
|
rv = (rv << 1) | (byte(n) & 0x01)
|
||||||
bc++
|
bc++
|
||||||
n = n >> 1
|
n = n >> 1
|
||||||
}
|
}
|
||||||
|
@ -105,12 +105,12 @@ fn test_bits(){
|
||||||
|
|
||||||
// 16 bit
|
// 16 bit
|
||||||
i = 0
|
i = 0
|
||||||
for x in 0..17 {
|
for _ in 0..17 {
|
||||||
mut rv := u16(0)
|
mut rv := u16(0)
|
||||||
mut bc := 0
|
mut bc := 0
|
||||||
mut n := i
|
mut n := i
|
||||||
for bc < 16 {
|
for bc < 16 {
|
||||||
rv = (rv << 1) | (n & 0x01)
|
rv = (rv << 1) | (u16(n) & 0x01)
|
||||||
bc++
|
bc++
|
||||||
n = n >> 1
|
n = n >> 1
|
||||||
}
|
}
|
||||||
|
@ -121,12 +121,12 @@ fn test_bits(){
|
||||||
|
|
||||||
// 32 bit
|
// 32 bit
|
||||||
i = 0
|
i = 0
|
||||||
for x in 0..33 {
|
for _ in 0..33 {
|
||||||
mut rv := u32(0)
|
mut rv := u32(0)
|
||||||
mut bc := 0
|
mut bc := 0
|
||||||
mut n := i
|
mut n := i
|
||||||
for bc < 32 {
|
for bc < 32 {
|
||||||
rv = (rv << 1) | (n & 0x01)
|
rv = (rv << 1) | (u32(n) & 0x01)
|
||||||
bc++
|
bc++
|
||||||
n = n >> 1
|
n = n >> 1
|
||||||
}
|
}
|
||||||
|
@ -137,7 +137,7 @@ fn test_bits(){
|
||||||
|
|
||||||
// 64 bit
|
// 64 bit
|
||||||
i1 = 0
|
i1 = 0
|
||||||
for x in 0..64 {
|
for _ in 0..64 {
|
||||||
mut rv := u64(0)
|
mut rv := u64(0)
|
||||||
mut bc := 0
|
mut bc := 0
|
||||||
mut n := i1
|
mut n := i1
|
||||||
|
|
|
@ -56,7 +56,7 @@ fn eval_cf(whole i64, den []i64) Fraction {
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
last := count - 1
|
last := count - 1
|
||||||
mut n := 1
|
mut n := i64(1)
|
||||||
mut d := den[last]
|
mut d := den[last]
|
||||||
// The calculations are done from back to front
|
// The calculations are done from back to front
|
||||||
for index := count - 2; index >= 0; index-- {
|
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
|
// The integer part is separated first. Then we process the fractional
|
||||||
// part to generate numerators and denominators in tandem.
|
// part to generate numerators and denominators in tandem.
|
||||||
whole := i64(val)
|
whole := i64(val)
|
||||||
mut frac := val - whole
|
mut frac := val - f64(whole)
|
||||||
// Quick exit for integers
|
// Quick exit for integers
|
||||||
if frac == 0.0 {
|
if frac == 0.0 {
|
||||||
return fraction(whole, 1)
|
return fraction(whole, 1)
|
||||||
|
@ -113,7 +113,7 @@ pub fn approximate_with_eps(val, eps f64) Fraction {
|
||||||
if math.fabs(val - partial.f64()) < eps {
|
if math.fabs(val - partial.f64()) < eps {
|
||||||
return partial
|
return partial
|
||||||
}
|
}
|
||||||
frac -= den
|
frac -= f64(den)
|
||||||
}
|
}
|
||||||
panic("Couldn\'t converge. Please create an issue on https://github.com/vlang/v")
|
panic("Couldn\'t converge. Please create an issue on https://github.com/vlang/v")
|
||||||
}
|
}
|
||||||
|
|
|
@ -56,7 +56,7 @@ fn test_gamma() {
|
||||||
|
|
||||||
fn test_mod() {
|
fn test_mod() {
|
||||||
assert 4 % 2 == 0
|
assert 4 % 2 == 0
|
||||||
x := 2
|
x := u64(2)
|
||||||
assert u64(5) % x == 1
|
assert u64(5) % x == 1
|
||||||
mut a := 10
|
mut a := 10
|
||||||
a %= 2
|
a %= 2
|
||||||
|
|
|
@ -1149,7 +1149,7 @@ pub fn (mut re RE) compile(in_txt string) (int,int) {
|
||||||
// ist_simple_char
|
// ist_simple_char
|
||||||
re.prog[pc].ist = ist_simple_char
|
re.prog[pc].ist = ist_simple_char
|
||||||
re.prog[pc].ch = char_tmp
|
re.prog[pc].ch = char_tmp
|
||||||
re.prog[pc].ch_len = char_len
|
re.prog[pc].ch_len = byte(char_len)
|
||||||
re.prog[pc].rep_min = 1
|
re.prog[pc].rep_min = 1
|
||||||
re.prog[pc].rep_max = 1
|
re.prog[pc].rep_max = 1
|
||||||
//println("char: ${char_tmp:c}")
|
//println("char: ${char_tmp:c}")
|
||||||
|
|
|
@ -152,19 +152,19 @@ cgroups_test_suite = [
|
||||||
"http://www.ciao.mondo/hello/pippo12_/pera.html",
|
"http://www.ciao.mondo/hello/pippo12_/pera.html",
|
||||||
r"(?P<format>https?)|(?:ftps?)://(?P<token>[\w_]+.)+",0,46,
|
r"(?P<format>https?)|(?:ftps?)://(?P<token>[\w_]+.)+",0,46,
|
||||||
[8, 0, 0, 4, 1, 7, 11, 1, 11, 16, 1, 16, 22, 1, 22, 28, 1, 28, 37, 1, 37, 42, 1, 42, 46],
|
[8, 0, 0, 4, 1, 7, 11, 1, 11, 16, 1, 16, 22, 1, 22, 28, 1, 28, 37, 1, 37, 42, 1, 42, 46],
|
||||||
{'format':0,'token':1}
|
{'format':int(0),'token':1}
|
||||||
},
|
},
|
||||||
TestItemCGroup{
|
TestItemCGroup{
|
||||||
"http://www.ciao.mondo/hello/pippo12_/pera.html",
|
"http://www.ciao.mondo/hello/pippo12_/pera.html",
|
||||||
r"(?P<format>https?)|(?P<format>ftps?)://(?P<token>[\w_]+.)+",0,46,
|
r"(?P<format>https?)|(?P<format>ftps?)://(?P<token>[\w_]+.)+",0,46,
|
||||||
[8, 0, 0, 4, 1, 7, 11, 1, 11, 16, 1, 16, 22, 1, 22, 28, 1, 28, 37, 1, 37, 42, 1, 42, 46],
|
[8, 0, 0, 4, 1, 7, 11, 1, 11, 16, 1, 16, 22, 1, 22, 28, 1, 28, 37, 1, 37, 42, 1, 42, 46],
|
||||||
{'format':0,'token':1}
|
{'format':int(0),'token':1}
|
||||||
},
|
},
|
||||||
TestItemCGroup{
|
TestItemCGroup{
|
||||||
"http://www.ciao.mondo/hello/pippo12_/pera.html",
|
"http://www.ciao.mondo/hello/pippo12_/pera.html",
|
||||||
r"(?P<format>https?)|(?P<format>ftps?)://([\w_]+.)+",0,46,
|
r"(?P<format>https?)|(?P<format>ftps?)://([\w_]+.)+",0,46,
|
||||||
[8, 0, 0, 4, 1, 7, 11, 1, 11, 16, 1, 16, 22, 1, 22, 28, 1, 28, 37, 1, 37, 42, 1, 42, 46],
|
[8, 0, 0, 4, 1, 7, 11, 1, 11, 16, 1, 16, 22, 1, 22, 28, 1, 28, 37, 1, 37, 42, 1, 42, 46],
|
||||||
{'format':0}
|
{'format':int(0)}
|
||||||
},
|
},
|
||||||
]
|
]
|
||||||
)
|
)
|
||||||
|
|
|
@ -143,7 +143,7 @@ fn test_add_days() {
|
||||||
num_of_days := 3
|
num_of_days := 3
|
||||||
t := time_to_test.add_days(num_of_days)
|
t := time_to_test.add_days(num_of_days)
|
||||||
assert t.day == time_to_test.day + num_of_days
|
assert t.day == time_to_test.day + num_of_days
|
||||||
assert t.unix == time_to_test.unix + 86400 * num_of_days
|
assert t.unix == time_to_test.unix + 86400 * u64(num_of_days)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn test_str() {
|
fn test_str() {
|
||||||
|
|
|
@ -2636,7 +2636,7 @@ fn (mut g Gen) string_inter_literal(node ast.StringInterLiteral) {
|
||||||
if fspec == `_` { // set default representation for type if still missing
|
if fspec == `_` { // set default representation for type if still missing
|
||||||
if node.expr_types[i].is_float() {
|
if node.expr_types[i].is_float() {
|
||||||
fspec = `g`
|
fspec = `g`
|
||||||
} else if node.expr_types[i].is_signed() {
|
} else if node.expr_types[i].is_signed() || node.expr_types[i].is_any_int() {
|
||||||
fspec = `d`
|
fspec = `d`
|
||||||
} else if node.expr_types[i].is_unsigned() {
|
} else if node.expr_types[i].is_unsigned() {
|
||||||
fspec = `u`
|
fspec = `u`
|
||||||
|
@ -2658,7 +2658,7 @@ fn (mut g Gen) string_inter_literal(node ast.StringInterLiteral) {
|
||||||
fields.len == 2 && !(node.expr_types[i].is_float()) ||
|
fields.len == 2 && !(node.expr_types[i].is_float()) ||
|
||||||
node.expr_types[i].is_signed() && fspec !in [`d`, `c`, `x`, `X`, `o`] ||
|
node.expr_types[i].is_signed() && fspec !in [`d`, `c`, `x`, `X`, `o`] ||
|
||||||
node.expr_types[i].is_unsigned() && fspec !in [`u`, `x`, `X`, `o`, `c`] ||
|
node.expr_types[i].is_unsigned() && fspec !in [`u`, `x`, `X`, `o`, `c`] ||
|
||||||
node.expr_types[i].is_any_int() && fspec !in [`d`, `c`, `x`, `X`, `o`, `u`, `x`, `X`, `o`, `c`] ||
|
node.expr_types[i].is_any_int() && fspec !in [`d`, `c`, `x`, `X`, `o`, `u`, `x`, `X`, `o`] ||
|
||||||
node.expr_types[i].is_float() && fspec !in [`E`, `F`, `G`, `e`, `f`, `g`] ||
|
node.expr_types[i].is_float() && fspec !in [`E`, `F`, `G`, `e`, `f`, `g`] ||
|
||||||
node.expr_types[i].is_pointer() && fspec !in [`p`, `x`, `X`] {
|
node.expr_types[i].is_pointer() && fspec !in [`p`, `x`, `X`] {
|
||||||
verror('illegal format specifier ${fspec:c} for type ${g.table.get_type_name(node.expr_types[i])}')
|
verror('illegal format specifier ${fspec:c} for type ${g.table.get_type_name(node.expr_types[i])}')
|
||||||
|
|
|
@ -57,7 +57,7 @@ fn test_assign_multi_expr() {
|
||||||
g, h, i := if true {
|
g, h, i := if true {
|
||||||
1 + val1, awesome, [13]
|
1 + val1, awesome, [13]
|
||||||
} else {
|
} else {
|
||||||
0, 'bad', [0]
|
int(0), 'bad', [0]
|
||||||
}
|
}
|
||||||
assert g == 2
|
assert g == 2
|
||||||
assert h == 'awesome'
|
assert h == 'awesome'
|
||||||
|
|
|
@ -23,6 +23,7 @@ fn test_interpolation_map_to_string() {
|
||||||
assert '$c' == "{'1': true, '2': false}"
|
assert '$c' == "{'1': true, '2': false}"
|
||||||
|
|
||||||
d := {'f1': 1.1, 'f2': 2.2, 'f3': 3.3, 'f4': 4.4}
|
d := {'f1': 1.1, 'f2': 2.2, 'f3': 3.3, 'f4': 4.4}
|
||||||
|
println('d: $d')
|
||||||
assert '$d' == "{'f1': 1.1, 'f2': 2.2, 'f3': 3.3, 'f4': 4.4}"
|
assert '$d' == "{'f1': 1.1, 'f2': 2.2, 'f3': 3.3, 'f4': 4.4}"
|
||||||
|
|
||||||
mut e := map[string]Test
|
mut e := map[string]Test
|
||||||
|
|
|
@ -26,7 +26,7 @@ fn test_match_expression_on_sumtype_else(){
|
||||||
// tests whether else branches support multiple statements,
|
// tests whether else branches support multiple statements,
|
||||||
// when the other branches are simple default expressions
|
// when the other branches are simple default expressions
|
||||||
mut c := 0
|
mut c := 0
|
||||||
s := s2s(123)
|
s := s2s(int(123))
|
||||||
res := match s {
|
res := match s {
|
||||||
string {
|
string {
|
||||||
'a string'
|
'a string'
|
||||||
|
@ -44,7 +44,7 @@ fn test_match_expression_on_sumtype_full(){
|
||||||
// tests whether all branches can have multiple statements,
|
// tests whether all branches can have multiple statements,
|
||||||
// followed by a default expression
|
// followed by a default expression
|
||||||
mut c := 0
|
mut c := 0
|
||||||
s := s2s(123)
|
s := s2s(int(123))
|
||||||
res := match s {
|
res := match s {
|
||||||
int {
|
int {
|
||||||
c = 1
|
c = 1
|
||||||
|
|
|
@ -41,10 +41,11 @@ fn test_shift_operators() {
|
||||||
assert e == b
|
assert e == b
|
||||||
e >>= int(i)
|
e >>= int(i)
|
||||||
assert e == a
|
assert e == a
|
||||||
e <<= i64(i)
|
mut e2 := i64(1)
|
||||||
assert e == b
|
e2 <<= i64(i)
|
||||||
e >>= i64(i)
|
assert e2 == b
|
||||||
assert e == a
|
e2 >>= i64(i)
|
||||||
|
assert e2 == a
|
||||||
e <<= byte(i)
|
e <<= byte(i)
|
||||||
assert e == b
|
assert e == b
|
||||||
e >>= byte(i)
|
e >>= byte(i)
|
||||||
|
@ -53,12 +54,13 @@ fn test_shift_operators() {
|
||||||
assert e == b
|
assert e == b
|
||||||
e >>= u16(i)
|
e >>= u16(i)
|
||||||
assert e == a
|
assert e == a
|
||||||
e <<= u32(i)
|
mut e3 := u64(1)
|
||||||
assert e == b
|
e3 <<= u32(i)
|
||||||
e >>= u32(i)
|
assert e3 == b
|
||||||
assert e == a
|
e3 >>= u32(i)
|
||||||
e <<= u64(i)
|
|
||||||
assert e == b
|
|
||||||
e >>= u64(i)
|
|
||||||
assert e == a
|
assert e == a
|
||||||
|
e3 <<= u64(i)
|
||||||
|
assert e3 == b
|
||||||
|
e3 >>= u64(i)
|
||||||
|
assert e3 == a
|
||||||
}
|
}
|
||||||
|
|
|
@ -79,7 +79,7 @@ fn test_array_of_strings_interpolation() {
|
||||||
|
|
||||||
fn test_array_of_map_interpolation() {
|
fn test_array_of_map_interpolation() {
|
||||||
mut a := []map[string]int{}
|
mut a := []map[string]int{}
|
||||||
a << {'a': 1, 'b': 2}
|
a << {'a': int(1), 'b': 2}
|
||||||
a << {'c': 3, 'd': 4}
|
a << {'c': int(3), 'd': 4}
|
||||||
assert '$a' == "[{'a': 1, 'b': 2}, {'c': 3, 'd': 4}]"
|
assert '$a' == "[{'a': 1, 'b': 2}, {'c': 3, 'd': 4}]"
|
||||||
}
|
}
|
||||||
|
|
|
@ -42,7 +42,7 @@ struct Info {
|
||||||
fn test_struct_map_field_string_interpolation() {
|
fn test_struct_map_field_string_interpolation() {
|
||||||
info := Info{
|
info := Info{
|
||||||
name: 'test'
|
name: 'test'
|
||||||
dict: {'a': 1, 'b': 2}
|
dict: {'a': int(1), 'b': 2}
|
||||||
}
|
}
|
||||||
s := '$info'
|
s := '$info'
|
||||||
assert s.starts_with('Info {')
|
assert s.starts_with('Info {')
|
||||||
|
|
|
@ -19,7 +19,8 @@ type SuperSumType = MySumType | AnotherSumType | string
|
||||||
fn test_typeof_for_builtin_int_types() {
|
fn test_typeof_for_builtin_int_types() {
|
||||||
assert typeof(i8(1)) == 'i8'
|
assert typeof(i8(1)) == 'i8'
|
||||||
assert typeof(i16(1)) == 'i16'
|
assert typeof(i16(1)) == 'i16'
|
||||||
assert typeof(1) == 'int'
|
assert typeof(int(1)) == 'int'
|
||||||
|
// assert typeof(1) == 'any_int'
|
||||||
assert typeof(i64(1)) == 'i64'
|
assert typeof(i64(1)) == 'i64'
|
||||||
assert typeof(byte(1)) == 'byte'
|
assert typeof(byte(1)) == 'byte'
|
||||||
assert typeof(u16(1)) == 'u16'
|
assert typeof(u16(1)) == 'u16'
|
||||||
|
@ -29,7 +30,8 @@ fn test_typeof_for_builtin_int_types() {
|
||||||
|
|
||||||
fn test_typeof_for_builtin_float_types() {
|
fn test_typeof_for_builtin_float_types() {
|
||||||
assert typeof(f32(1.0)) == 'f32'
|
assert typeof(f32(1.0)) == 'f32'
|
||||||
assert typeof(1.0) == 'f64'
|
assert typeof(f64(1.0)) == 'f64'
|
||||||
|
// assert typeof(1.0) == 'any_float'
|
||||||
}
|
}
|
||||||
|
|
||||||
fn test_typeof_for_builtin_string_type() {
|
fn test_typeof_for_builtin_string_type() {
|
||||||
|
|
|
@ -1,10 +1,17 @@
|
||||||
fn test_typeof_on_simple_expressions() {
|
fn test_typeof_on_simple_expressions() {
|
||||||
a := 123
|
a := int(123)
|
||||||
assert typeof(42) == 'int'
|
assert typeof(int(42)) == 'int'
|
||||||
assert typeof(3.14) == 'f64'
|
assert typeof(f64(3.14)) == 'f64'
|
||||||
assert typeof(2+2*10) == 'int'
|
assert typeof(int(2)+2*10) == 'int'
|
||||||
assert typeof(1.0 * 12.2) == 'f64'
|
assert typeof(f64(1.0) * 12.2) == 'f64'
|
||||||
|
// assert typeof(1.0 * f32(12.2)) == 'f32'
|
||||||
assert typeof(a) == 'int'
|
assert typeof(a) == 'int'
|
||||||
|
// a2 := 123
|
||||||
|
// assert typeof(a2) == 'any_int'
|
||||||
|
// assert typeof(42) == 'any_int'
|
||||||
|
// assert typeof(3.14) == 'any_float'
|
||||||
|
// assert typeof(2+2*10) == 'any_int'
|
||||||
|
// assert typeof(1.0 * 12.2) == 'any_float'
|
||||||
}
|
}
|
||||||
|
|
||||||
fn test_typeof_on_atypes() {
|
fn test_typeof_on_atypes() {
|
||||||
|
@ -38,7 +45,7 @@ pub fn (ms MySumType) str() string {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn test_typeof_on_sumtypes() {
|
fn test_typeof_on_sumtypes() {
|
||||||
a := MySumType(32)
|
a := MySumType(int(32))
|
||||||
b := MySumType(f32(123.0))
|
b := MySumType(f32(123.0))
|
||||||
c := MySumType(FooBar{x:43})
|
c := MySumType(FooBar{x:43})
|
||||||
assert typeof(a) == 'int'
|
assert typeof(a) == 'int'
|
||||||
|
|
|
@ -113,7 +113,7 @@ fn (am AssetManager) combine(asset_type string, to_file bool) string {
|
||||||
|
|
||||||
fn (am AssetManager) get_cache_key(asset_type string) string {
|
fn (am AssetManager) get_cache_key(asset_type string) string {
|
||||||
mut files_salt := ''
|
mut files_salt := ''
|
||||||
mut latest_modified := 0
|
mut latest_modified := u64(0)
|
||||||
for asset in am.get_assets(asset_type) {
|
for asset in am.get_assets(asset_type) {
|
||||||
files_salt += asset.file_path
|
files_salt += asset.file_path
|
||||||
if asset.last_modified.unix > latest_modified {
|
if asset.last_modified.unix > latest_modified {
|
||||||
|
@ -157,7 +157,7 @@ fn (mut am AssetManager) add(asset_type, file string) bool {
|
||||||
}
|
}
|
||||||
asset := Asset{
|
asset := Asset{
|
||||||
file_path: file
|
file_path: file
|
||||||
last_modified: time.Time{unix: os.file_last_mod_unix(file)}
|
last_modified: time.Time{unix: u64(os.file_last_mod_unix(file))}
|
||||||
}
|
}
|
||||||
if asset_type == 'css' {
|
if asset_type == 'css' {
|
||||||
am.css << asset
|
am.css << asset
|
||||||
|
|
Loading…
Reference in New Issue