test: fix vlib/math/big/big_test.v

pull/4329/head
yuyi 2020-04-10 17:26:15 +08:00 committed by GitHub
parent 0f11d883fa
commit 7f87ac996d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 9 additions and 10 deletions

View File

@ -2,14 +2,10 @@ module big
// Wrapper for https://github.com/kokke/tiny-bignum-c // Wrapper for https://github.com/kokke/tiny-bignum-c
#flag -I @VROOT/thirdparty/bignum #flag -I thirdparty/bignum
#flag @VROOT/thirdparty/bignum/bn.o #flag thirdparty/bignum/bn.o
#include "bn.h" #include "bn.h"
const (
STRING_BUFFER_SIZE = 8192
)
pub struct Number { pub struct Number {
array [32]u32 array [32]u32
} }
@ -77,8 +73,8 @@ pub fn (n Number) str() string {
} }
pub fn (n Number) hexstr() string { pub fn (n Number) hexstr() string {
mut buf := [STRING_BUFFER_SIZE]byte mut buf := [8192]byte
C.bignum_to_string( &n, buf, STRING_BUFFER_SIZE) C.bignum_to_string( &n, buf, 8192)
// NB: bignum_to_string , returns the HEXADECIMAL representation of the bignum n // NB: bignum_to_string , returns the HEXADECIMAL representation of the bignum n
s := tos_clone( buf ) s := tos_clone( buf )
if s.len == 0 { return '0' } if s.len == 0 { return '0' }

View File

@ -799,7 +799,7 @@ fn (g mut Gen) gen_fn_decl(it ast.FnDecl) {
} else { } else {
mut name := it.name mut name := it.name
c := name[0] c := name[0]
if c in [`+`, `-`, `*`, `/`] { if c in [`+`, `-`, `*`, `/`, `%`] {
name = util.replace_op(name) name = util.replace_op(name)
} }
if it.is_method { if it.is_method {
@ -1439,7 +1439,7 @@ fn (g mut Gen) infix_expr(node ast.InfixExpr) {
g.write(',') g.write(',')
g.expr(node.right) g.expr(node.right)
g.write(')') 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.kind != .alias {
// !left_sym.is_number() { // !left_sym.is_number() {
g.write(g.typ(node.left_type)) g.write(g.typ(node.left_type))

View File

@ -211,6 +211,9 @@ fn replace_op(s string) string {
`/` { `/` {
'_div' '_div'
} }
`%` {
'_mod'
}
else { else {
'' ''
} }