From bc4a576c54aece63b1c5099d537e975d91d7584a Mon Sep 17 00:00:00 2001 From: yuyi Date: Tue, 21 Apr 2020 19:44:17 +0800 Subject: [PATCH] flag: fix flag_test.v --- cmd/tools/vtest-fixed.v | 1 - vlib/flag/flag.v | 12 ++++++------ vlib/flag/flag_test.v | 3 +++ 3 files changed, 9 insertions(+), 7 deletions(-) diff --git a/cmd/tools/vtest-fixed.v b/cmd/tools/vtest-fixed.v index c643c99b73..fb2a054569 100644 --- a/cmd/tools/vtest-fixed.v +++ b/cmd/tools/vtest-fixed.v @@ -11,7 +11,6 @@ const ( 'vlib/crypto/rc4/rc4_test.v', 'vlib/encoding/utf8/utf8_util_test.v', 'vlib/eventbus/eventbus_test.v', - 'vlib/flag/flag_test.v', 'vlib/json/json_test.v', 'vlib/net/ftp/ftp_test.v', 'vlib/net/http/http_httpbin_test.v', diff --git a/vlib/flag/flag.v b/vlib/flag/flag.v index d3a62d69b0..01a9f79b9e 100644 --- a/vlib/flag/flag.v +++ b/vlib/flag/flag.v @@ -291,25 +291,25 @@ pub fn (fs mut FlagParser) int(name string, abbr byte, idefault int, usage strin // float_multi returns all instances of values associated with the flags provided // In the case that none were found, it returns an empty array. -pub fn (fs mut FlagParser) float_multi(name string, abbr byte, usage string) []f32 { +pub fn (fs mut FlagParser) float_multi(name string, abbr byte, usage string) []f64 { fs.add_flag(name, abbr, usage, '') parsed := fs.parse_value(name, abbr) - mut value := []f32 + mut value := []f64 for val in parsed { - value << val.f32() + value << val.f64() } return value } // float_opt returns an optional that returns the value associated with the flag. // In the situation that the flag was not provided, it returns null. -pub fn (fs mut FlagParser) float_opt(name string, abbr byte, usage string) ?f32 { +pub fn (fs mut FlagParser) float_opt(name string, abbr byte, usage string) ?f64 { fs.add_flag(name, abbr, usage, '') parsed := fs.parse_value(name, abbr) if parsed.len == 0 { return error("parameter '$name' not provided") } - return parsed[0].f32() + return parsed[0].f64() } // defining and parsing a float flag @@ -319,7 +319,7 @@ pub fn (fs mut FlagParser) float_opt(name string, abbr byte, usage string) ?f32 // the default value is returned // version with abbr //TODO error handling for invalid string to float conversion -pub fn (fs mut FlagParser) float(name string, abbr byte, fdefault f32, usage string) f32 { +pub fn (fs mut FlagParser) float(name string, abbr byte, fdefault f64, usage string) f64 { value := fs.float_opt(name, abbr, usage) or { return fdefault } diff --git a/vlib/flag/flag_test.v b/vlib/flag/flag_test.v index aede4b761d..e8f695dc8f 100644 --- a/vlib/flag/flag_test.v +++ b/vlib/flag/flag_test.v @@ -276,8 +276,11 @@ fn test_not_provided_option_is_not_returned() { //Everything should not return return } + return } + return } + return } //If we reach here, one of them returned a value. assert false