test: fix vlib/math/big/big_test.v
parent
0f11d883fa
commit
7f87ac996d
|
@ -2,14 +2,10 @@ module big
|
|||
|
||||
// Wrapper for https://github.com/kokke/tiny-bignum-c
|
||||
|
||||
#flag -I @VROOT/thirdparty/bignum
|
||||
#flag @VROOT/thirdparty/bignum/bn.o
|
||||
#flag -I thirdparty/bignum
|
||||
#flag thirdparty/bignum/bn.o
|
||||
#include "bn.h"
|
||||
|
||||
const (
|
||||
STRING_BUFFER_SIZE = 8192
|
||||
)
|
||||
|
||||
pub struct Number {
|
||||
array [32]u32
|
||||
}
|
||||
|
@ -77,8 +73,8 @@ pub fn (n Number) str() string {
|
|||
}
|
||||
|
||||
pub fn (n Number) hexstr() string {
|
||||
mut buf := [STRING_BUFFER_SIZE]byte
|
||||
C.bignum_to_string( &n, buf, STRING_BUFFER_SIZE)
|
||||
mut buf := [8192]byte
|
||||
C.bignum_to_string( &n, buf, 8192)
|
||||
// NB: bignum_to_string , returns the HEXADECIMAL representation of the bignum n
|
||||
s := tos_clone( buf )
|
||||
if s.len == 0 { return '0' }
|
||||
|
|
|
@ -799,7 +799,7 @@ fn (g mut Gen) gen_fn_decl(it ast.FnDecl) {
|
|||
} else {
|
||||
mut name := it.name
|
||||
c := name[0]
|
||||
if c in [`+`, `-`, `*`, `/`] {
|
||||
if c in [`+`, `-`, `*`, `/`, `%`] {
|
||||
name = util.replace_op(name)
|
||||
}
|
||||
if it.is_method {
|
||||
|
@ -1439,7 +1439,7 @@ fn (g mut Gen) infix_expr(node ast.InfixExpr) {
|
|||
g.write(',')
|
||||
g.expr(node.right)
|
||||
g.write(')')
|
||||
} else if node.op in [.plus, .minus, .mul, .div] && (left_sym.name[0].is_capital() || left_sym.name.contains('.')) &&
|
||||
} else if node.op in [.plus, .minus, .mul, .div, .mod] && (left_sym.name[0].is_capital() || left_sym.name.contains('.')) &&
|
||||
left_sym.kind != .alias {
|
||||
// !left_sym.is_number() {
|
||||
g.write(g.typ(node.left_type))
|
||||
|
|
|
@ -211,6 +211,9 @@ fn replace_op(s string) string {
|
|||
`/` {
|
||||
'_div'
|
||||
}
|
||||
`%` {
|
||||
'_mod'
|
||||
}
|
||||
else {
|
||||
''
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue