summaryrefslogtreecommitdiff
path: root/src/testdir/test_float_func.vim
diff options
context:
space:
mode:
Diffstat (limited to 'src/testdir/test_float_func.vim')
-rw-r--r--src/testdir/test_float_func.vim17
1 files changed, 16 insertions, 1 deletions
diff --git a/src/testdir/test_float_func.vim b/src/testdir/test_float_func.vim
index ba15ecfc7..628bbb0c0 100644
--- a/src/testdir/test_float_func.vim
+++ b/src/testdir/test_float_func.vim
@@ -239,13 +239,28 @@ func Test_str2float()
call assert_equal('nan', string(str2float('NaN')))
call assert_equal('nan', string(str2float(' nan ')))
- call assert_equal(1.2, str2float(1.2))
+ call assert_equal('123456.789', string(str2float("123'456.789", 1)))
+ call assert_equal('123456.789', string(str2float("12'34'56.789", 1)))
+ call assert_equal('123456.789', string(str2float("1'2'3'4'5'6.789", 1)))
+ call assert_equal('1.0', string(str2float("1''2.3", 1)))
+ call assert_equal('123456.7', string(str2float("123'456.7'89", 1)))
+
+ call assert_equal(1.2, str2float(1.2, 0))
call CheckDefAndScriptFailure2(['str2float(1.2)'], 'E1013: Argument 1: type mismatch, expected string but got float', 'E1174: String required for argument 1')
call assert_fails("call str2float([])", 'E730:')
call assert_fails("call str2float({})", 'E731:')
call assert_fails("call str2float(function('string'))", 'E729:')
endfunc
+def Test_float_quotes()
+ call assert_equal('123456.789', string(123'456.789))
+ call assert_equal('123456.789', string(12'34'56.789))
+ call assert_equal('123456.789', string(1'2'3'4'5'6.789))
+
+ call assert_fails("echo string(1''2.3)", 'E116:')
+ call assert_fails("echo string(123'456.7'89)", 'E116:')
+enddef
+
func Test_float2nr()
call assert_equal(1, float2nr(1.234))
call assert_equal(123, float2nr(1.234e2))