diff options
| author | James McCoy <jamessan@jamessan.com> | 2017-06-05 22:39:09 -0400 |
|---|---|---|
| committer | James McCoy <jamessan@jamessan.com> | 2017-06-06 05:07:14 -0400 |
| commit | 17d616037d9312be6fb99ab559861175a1bc35e6 (patch) | |
| tree | 717c27a0a25d29ea99bd05dbf4c1dcc8c4992cbc /src/nvim/testdir/test_float_func.vim | |
| parent | b1d4ef2b420b1fa9826a9e79344adaf71ad27e18 (diff) | |
| download | rneovim-17d616037d9312be6fb99ab559861175a1bc35e6.tar.gz rneovim-17d616037d9312be6fb99ab559861175a1bc35e6.tar.bz2 rneovim-17d616037d9312be6fb99ab559861175a1bc35e6.zip | |
vim-patch:8.0.0167
Problem: str2nr() and str2float() do not always work with negative values.
Solution: Be more flexible about handling signs. (LemonBoy, closes vim/vim#1332)
Add more tests.
https://github.com/vim/vim/commit/08243d26d22ad44a857d02c90071578577b8a55d
Diffstat (limited to 'src/nvim/testdir/test_float_func.vim')
| -rw-r--r-- | src/nvim/testdir/test_float_func.vim | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/src/nvim/testdir/test_float_func.vim b/src/nvim/testdir/test_float_func.vim index 8600ce5b60..21a156e3d8 100644 --- a/src/nvim/testdir/test_float_func.vim +++ b/src/nvim/testdir/test_float_func.vim @@ -165,9 +165,22 @@ endfunc func Test_str2float() call assert_equal('1.0', string(str2float('1'))) + call assert_equal('1.0', string(str2float(' 1 '))) + call assert_equal('1.0', string(str2float(' 1.0 '))) call assert_equal('1.23', string(str2float('1.23'))) call assert_equal('1.23', string(str2float('1.23abc'))) call assert_equal('1.0e40', string(str2float('1e40'))) + + call assert_equal('1.0', string(str2float('+1'))) + call assert_equal('1.0', string(str2float('+1'))) + call assert_equal('1.0', string(str2float(' +1 '))) + call assert_equal('1.0', string(str2float(' + 1 '))) + + call assert_equal('-1.0', string(str2float('-1'))) + call assert_equal('-1.0', string(str2float('-1'))) + call assert_equal('-1.0', string(str2float(' -1 '))) + call assert_equal('-1.0', string(str2float(' - 1 '))) + call assert_equal("str2float('inf')", string(str2float('1e1000'))) call assert_equal("str2float('inf')", string(str2float('inf'))) call assert_equal("-str2float('inf')", string(str2float('-inf'))) |