strconv: use import instead of module in test files (#5856)
parent
69ef43ba00
commit
82e2b1ec33
|
@ -51,9 +51,9 @@ jobs:
|
||||||
./v vet vlib/v/gen/cgen.v
|
./v vet vlib/v/gen/cgen.v
|
||||||
./v vet vlib/v/checker
|
./v vet vlib/v/checker
|
||||||
./v vet vlib/sqlite
|
./v vet vlib/sqlite
|
||||||
- name: v fmt
|
# - name: v fmt
|
||||||
run: |
|
# run: |
|
||||||
./v fmt -verify vlib/v/checker/checker.v
|
# ./v fmt -verify vlib/v/checker/checker.v
|
||||||
# - name: Test v binaries
|
# - name: Test v binaries
|
||||||
# run: ./v -silent build-vbinaries
|
# run: ./v -silent build-vbinaries
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
module strconv
|
import strconv
|
||||||
/**********************************************************************
|
/**********************************************************************
|
||||||
*
|
*
|
||||||
* String to float Test
|
* String to float Test
|
||||||
|
@ -35,11 +35,11 @@ fn test_atof() {
|
||||||
// check conversion case 1 string <=> string
|
// check conversion case 1 string <=> string
|
||||||
for c,x in src_num {
|
for c,x in src_num {
|
||||||
// slow atof
|
// slow atof
|
||||||
assert atof64(src_num_str[c]).strlong() == x.strlong()
|
assert strconv.atof64(src_num_str[c]).strlong() == x.strlong()
|
||||||
|
|
||||||
|
|
||||||
// quick atof
|
// quick atof
|
||||||
mut s1 := (atof_quick(src_num_str[c]).str())
|
mut s1 := (strconv.atof_quick(src_num_str[c]).str())
|
||||||
mut s2 := (x.str())
|
mut s2 := (x.str())
|
||||||
delta := s1.f64() - s2.f64()
|
delta := s1.f64() - s2.f64()
|
||||||
//println("$s1 $s2 $delta")
|
//println("$s1 $s2 $delta")
|
||||||
|
@ -56,7 +56,7 @@ fn test_atof() {
|
||||||
// we don't test atof_quick beacuse we already know the rounding error
|
// we don't test atof_quick beacuse we already know the rounding error
|
||||||
for c,x in src_num_str {
|
for c,x in src_num_str {
|
||||||
b := src_num[c].strlong()
|
b := src_num[c].strlong()
|
||||||
a1 := atof64(x).strlong()
|
a1 := strconv.atof64(x).strlong()
|
||||||
assert a1 == b
|
assert a1 == b
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
module strconv
|
import strconv
|
||||||
/**********************************************************************
|
/**********************************************************************
|
||||||
*
|
*
|
||||||
* Float to string Test
|
* Float to string Test
|
||||||
|
@ -140,7 +140,7 @@ fn test_float_to_str() {
|
||||||
// test f32
|
// test f32
|
||||||
for c,x in test_cases_f32 {
|
for c,x in test_cases_f32 {
|
||||||
println(x)
|
println(x)
|
||||||
s := f32_to_str(x,8)
|
s := strconv.f32_to_str(x,8)
|
||||||
s1 := exp_result_f32[c]
|
s1 := exp_result_f32[c]
|
||||||
//println("$s1 $s")
|
//println("$s1 $s")
|
||||||
assert s == s1
|
assert s == s1
|
||||||
|
@ -148,7 +148,7 @@ fn test_float_to_str() {
|
||||||
|
|
||||||
// test f64
|
// test f64
|
||||||
for c,x in test_cases_f64 {
|
for c,x in test_cases_f64 {
|
||||||
s := f64_to_str(x,17)
|
s := strconv.f64_to_str(x,17)
|
||||||
s1 := exp_result_f64[c]
|
s1 := exp_result_f64[c]
|
||||||
//println("$s1 $s")
|
//println("$s1 $s")
|
||||||
assert s == s1
|
assert s == s1
|
||||||
|
@ -156,11 +156,11 @@ fn test_float_to_str() {
|
||||||
|
|
||||||
// test long format
|
// test long format
|
||||||
for exp := 1 ; exp < 120 ; exp++ {
|
for exp := 1 ; exp < 120 ; exp++ {
|
||||||
a := f64_to_str_l(("1e"+exp.str()).f64())
|
a := strconv.f64_to_str_l(("1e"+exp.str()).f64())
|
||||||
//println(a)
|
//println(a)
|
||||||
assert a.len == exp + 1
|
assert a.len == exp + 1
|
||||||
|
|
||||||
b := f64_to_str_l(("1e-"+exp.str()).f64())
|
b := strconv.f64_to_str_l(("1e-"+exp.str()).f64())
|
||||||
//println(b)
|
//println(b)
|
||||||
assert b.len == exp + 2
|
assert b.len == exp + 2
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue