Mercurial > vim
annotate src/testdir/test_float_func.vim @ 10555:fff45421182b v8.0.0167
patch 8.0.0167: str2nr()/str2float() fail with negative values
commit https://github.com/vim/vim/commit/08243d26d22ad44a857d02c90071578577b8a55d
Author: Bram Moolenaar <Bram@vim.org>
Date: Tue Jan 10 16:12:29 2017 +0100
patch 8.0.0167: str2nr()/str2float() fail with negative values
Problem: str2nr() and str2float() do not always work with negative values.
Solution: Be more flexible about handling signs. (LemonBoy, closes https://github.com/vim/vim/issues/1332)
Add more tests.
author | Christian Brabandt <cb@256bit.org> |
---|---|
date | Tue, 10 Jan 2017 16:15:04 +0100 |
parents | 6ddf322ff7cf |
children | 018b7ecc58db |
rev | line source |
---|---|
10532
80b50e43e382
commit https://github.com/vim/vim/commit/453b576ee5d32e9b8e6876712748ae01f9be68dd
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
1 " test float functions |
80b50e43e382
commit https://github.com/vim/vim/commit/453b576ee5d32e9b8e6876712748ae01f9be68dd
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
2 |
80b50e43e382
commit https://github.com/vim/vim/commit/453b576ee5d32e9b8e6876712748ae01f9be68dd
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
3 if !has('float') |
80b50e43e382
commit https://github.com/vim/vim/commit/453b576ee5d32e9b8e6876712748ae01f9be68dd
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
4 finish |
80b50e43e382
commit https://github.com/vim/vim/commit/453b576ee5d32e9b8e6876712748ae01f9be68dd
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
5 end |
80b50e43e382
commit https://github.com/vim/vim/commit/453b576ee5d32e9b8e6876712748ae01f9be68dd
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
6 |
80b50e43e382
commit https://github.com/vim/vim/commit/453b576ee5d32e9b8e6876712748ae01f9be68dd
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
7 func Test_abs() |
10536
6ddf322ff7cf
patch 8.0.0158: float funcion test fails on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
10532
diff
changeset
|
8 call assert_equal('1.23', string(abs(1.23))) |
6ddf322ff7cf
patch 8.0.0158: float funcion test fails on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
10532
diff
changeset
|
9 call assert_equal('1.23', string(abs(-1.23))) |
6ddf322ff7cf
patch 8.0.0158: float funcion test fails on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
10532
diff
changeset
|
10 call assert_equal('0.0', string(abs(0.0))) |
6ddf322ff7cf
patch 8.0.0158: float funcion test fails on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
10532
diff
changeset
|
11 call assert_equal('0.0', string(abs(1.0/(1.0/0.0)))) |
6ddf322ff7cf
patch 8.0.0158: float funcion test fails on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
10532
diff
changeset
|
12 call assert_equal('0.0', string(abs(-1.0/(1.0/0.0)))) |
6ddf322ff7cf
patch 8.0.0158: float funcion test fails on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
10532
diff
changeset
|
13 call assert_equal('inf', string(abs(1.0/0.0))) |
6ddf322ff7cf
patch 8.0.0158: float funcion test fails on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
10532
diff
changeset
|
14 call assert_equal('inf', string(abs(-1.0/0.0))) |
6ddf322ff7cf
patch 8.0.0158: float funcion test fails on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
10532
diff
changeset
|
15 call assert_equal('nan', string(abs(0.0/0.0))) |
10532
80b50e43e382
commit https://github.com/vim/vim/commit/453b576ee5d32e9b8e6876712748ae01f9be68dd
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
16 endfunc |
80b50e43e382
commit https://github.com/vim/vim/commit/453b576ee5d32e9b8e6876712748ae01f9be68dd
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
17 |
80b50e43e382
commit https://github.com/vim/vim/commit/453b576ee5d32e9b8e6876712748ae01f9be68dd
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
18 func Test_sqrt() |
10536
6ddf322ff7cf
patch 8.0.0158: float funcion test fails on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
10532
diff
changeset
|
19 call assert_equal('0.0', string(sqrt(0.0))) |
6ddf322ff7cf
patch 8.0.0158: float funcion test fails on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
10532
diff
changeset
|
20 call assert_equal('1.414214', string(sqrt(2.0))) |
6ddf322ff7cf
patch 8.0.0158: float funcion test fails on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
10532
diff
changeset
|
21 call assert_equal('inf', string(sqrt(1.0/0.0))) |
6ddf322ff7cf
patch 8.0.0158: float funcion test fails on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
10532
diff
changeset
|
22 call assert_equal('nan', string(sqrt(-1.0))) |
6ddf322ff7cf
patch 8.0.0158: float funcion test fails on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
10532
diff
changeset
|
23 call assert_equal('nan', string(sqrt(0.0/0.0))) |
10532
80b50e43e382
commit https://github.com/vim/vim/commit/453b576ee5d32e9b8e6876712748ae01f9be68dd
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
24 endfunc |
80b50e43e382
commit https://github.com/vim/vim/commit/453b576ee5d32e9b8e6876712748ae01f9be68dd
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
25 |
80b50e43e382
commit https://github.com/vim/vim/commit/453b576ee5d32e9b8e6876712748ae01f9be68dd
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
26 func Test_log() |
10536
6ddf322ff7cf
patch 8.0.0158: float funcion test fails on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
10532
diff
changeset
|
27 call assert_equal('0.0', string(log(1.0))) |
6ddf322ff7cf
patch 8.0.0158: float funcion test fails on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
10532
diff
changeset
|
28 call assert_equal('-0.693147', string(log(0.5))) |
6ddf322ff7cf
patch 8.0.0158: float funcion test fails on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
10532
diff
changeset
|
29 call assert_equal('-inf', string(log(0.0))) |
6ddf322ff7cf
patch 8.0.0158: float funcion test fails on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
10532
diff
changeset
|
30 call assert_equal('nan', string(log(-1.0))) |
6ddf322ff7cf
patch 8.0.0158: float funcion test fails on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
10532
diff
changeset
|
31 call assert_equal('inf', string(log(1.0/0.0))) |
6ddf322ff7cf
patch 8.0.0158: float funcion test fails on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
10532
diff
changeset
|
32 call assert_equal('nan', string(log(0.0/0.0))) |
10532
80b50e43e382
commit https://github.com/vim/vim/commit/453b576ee5d32e9b8e6876712748ae01f9be68dd
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
33 endfunc |
80b50e43e382
commit https://github.com/vim/vim/commit/453b576ee5d32e9b8e6876712748ae01f9be68dd
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
34 |
80b50e43e382
commit https://github.com/vim/vim/commit/453b576ee5d32e9b8e6876712748ae01f9be68dd
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
35 func Test_log10() |
10536
6ddf322ff7cf
patch 8.0.0158: float funcion test fails on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
10532
diff
changeset
|
36 call assert_equal('0.0', string(log10(1.0))) |
6ddf322ff7cf
patch 8.0.0158: float funcion test fails on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
10532
diff
changeset
|
37 call assert_equal('2.0', string(log10(100.0))) |
6ddf322ff7cf
patch 8.0.0158: float funcion test fails on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
10532
diff
changeset
|
38 call assert_equal('2.079181', string(log10(120.0))) |
6ddf322ff7cf
patch 8.0.0158: float funcion test fails on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
10532
diff
changeset
|
39 call assert_equal('-inf', string(log10(0.0))) |
6ddf322ff7cf
patch 8.0.0158: float funcion test fails on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
10532
diff
changeset
|
40 call assert_equal('nan', string(log10(-1.0))) |
6ddf322ff7cf
patch 8.0.0158: float funcion test fails on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
10532
diff
changeset
|
41 call assert_equal('inf', string(log10(1.0/0.0))) |
6ddf322ff7cf
patch 8.0.0158: float funcion test fails on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
10532
diff
changeset
|
42 call assert_equal('nan', string(log10(0.0/0.0))) |
10532
80b50e43e382
commit https://github.com/vim/vim/commit/453b576ee5d32e9b8e6876712748ae01f9be68dd
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
43 endfunc |
80b50e43e382
commit https://github.com/vim/vim/commit/453b576ee5d32e9b8e6876712748ae01f9be68dd
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
44 |
80b50e43e382
commit https://github.com/vim/vim/commit/453b576ee5d32e9b8e6876712748ae01f9be68dd
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
45 func Test_exp() |
10536
6ddf322ff7cf
patch 8.0.0158: float funcion test fails on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
10532
diff
changeset
|
46 call assert_equal('1.0', string(exp(0.0))) |
6ddf322ff7cf
patch 8.0.0158: float funcion test fails on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
10532
diff
changeset
|
47 call assert_equal('7.389056', string(exp(2.0))) |
6ddf322ff7cf
patch 8.0.0158: float funcion test fails on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
10532
diff
changeset
|
48 call assert_equal('0.367879', string(exp(-1.0))) |
6ddf322ff7cf
patch 8.0.0158: float funcion test fails on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
10532
diff
changeset
|
49 call assert_equal('inf', string(exp(1.0/0.0))) |
6ddf322ff7cf
patch 8.0.0158: float funcion test fails on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
10532
diff
changeset
|
50 call assert_equal('0.0', string(exp(-1.0/0.0))) |
6ddf322ff7cf
patch 8.0.0158: float funcion test fails on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
10532
diff
changeset
|
51 call assert_equal('nan', string(exp(0.0/0.0))) |
10532
80b50e43e382
commit https://github.com/vim/vim/commit/453b576ee5d32e9b8e6876712748ae01f9be68dd
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
52 endfunc |
80b50e43e382
commit https://github.com/vim/vim/commit/453b576ee5d32e9b8e6876712748ae01f9be68dd
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
53 |
80b50e43e382
commit https://github.com/vim/vim/commit/453b576ee5d32e9b8e6876712748ae01f9be68dd
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
54 func Test_sin() |
10536
6ddf322ff7cf
patch 8.0.0158: float funcion test fails on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
10532
diff
changeset
|
55 call assert_equal('0.0', string(sin(0.0))) |
6ddf322ff7cf
patch 8.0.0158: float funcion test fails on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
10532
diff
changeset
|
56 call assert_equal('0.841471', string(sin(1.0))) |
6ddf322ff7cf
patch 8.0.0158: float funcion test fails on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
10532
diff
changeset
|
57 call assert_equal('-0.479426', string(sin(-0.5))) |
6ddf322ff7cf
patch 8.0.0158: float funcion test fails on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
10532
diff
changeset
|
58 call assert_equal('nan', string(sin(0.0/0.0))) |
6ddf322ff7cf
patch 8.0.0158: float funcion test fails on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
10532
diff
changeset
|
59 call assert_equal('nan', string(sin(1.0/0.0))) |
6ddf322ff7cf
patch 8.0.0158: float funcion test fails on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
10532
diff
changeset
|
60 call assert_equal('0.0', string(sin(1.0/(1.0/0.0)))) |
6ddf322ff7cf
patch 8.0.0158: float funcion test fails on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
10532
diff
changeset
|
61 call assert_equal('-0.0', string(sin(-1.0/(1.0/0.0)))) |
10532
80b50e43e382
commit https://github.com/vim/vim/commit/453b576ee5d32e9b8e6876712748ae01f9be68dd
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
62 endfunc |
80b50e43e382
commit https://github.com/vim/vim/commit/453b576ee5d32e9b8e6876712748ae01f9be68dd
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
63 |
80b50e43e382
commit https://github.com/vim/vim/commit/453b576ee5d32e9b8e6876712748ae01f9be68dd
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
64 func Test_asin() |
10536
6ddf322ff7cf
patch 8.0.0158: float funcion test fails on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
10532
diff
changeset
|
65 call assert_equal('0.0', string(asin(0.0))) |
6ddf322ff7cf
patch 8.0.0158: float funcion test fails on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
10532
diff
changeset
|
66 call assert_equal('1.570796', string(asin(1.0))) |
6ddf322ff7cf
patch 8.0.0158: float funcion test fails on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
10532
diff
changeset
|
67 call assert_equal('-0.523599', string(asin(-0.5))) |
6ddf322ff7cf
patch 8.0.0158: float funcion test fails on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
10532
diff
changeset
|
68 call assert_equal('nan', string(asin(1.1))) |
6ddf322ff7cf
patch 8.0.0158: float funcion test fails on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
10532
diff
changeset
|
69 call assert_equal('nan', string(asin(1.0/0.0))) |
6ddf322ff7cf
patch 8.0.0158: float funcion test fails on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
10532
diff
changeset
|
70 call assert_equal('nan', string(asin(0.0/0.0))) |
10532
80b50e43e382
commit https://github.com/vim/vim/commit/453b576ee5d32e9b8e6876712748ae01f9be68dd
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
71 endfunc |
80b50e43e382
commit https://github.com/vim/vim/commit/453b576ee5d32e9b8e6876712748ae01f9be68dd
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
72 |
80b50e43e382
commit https://github.com/vim/vim/commit/453b576ee5d32e9b8e6876712748ae01f9be68dd
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
73 func Test_sinh() |
10536
6ddf322ff7cf
patch 8.0.0158: float funcion test fails on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
10532
diff
changeset
|
74 call assert_equal('0.0', string(sinh(0.0))) |
6ddf322ff7cf
patch 8.0.0158: float funcion test fails on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
10532
diff
changeset
|
75 call assert_equal('0.521095', string(sinh(0.5))) |
6ddf322ff7cf
patch 8.0.0158: float funcion test fails on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
10532
diff
changeset
|
76 call assert_equal('-1.026517', string(sinh(-0.9))) |
6ddf322ff7cf
patch 8.0.0158: float funcion test fails on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
10532
diff
changeset
|
77 call assert_equal('inf', string(sinh(1.0/0.0))) |
6ddf322ff7cf
patch 8.0.0158: float funcion test fails on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
10532
diff
changeset
|
78 call assert_equal('-inf', string(sinh(-1.0/0.0))) |
6ddf322ff7cf
patch 8.0.0158: float funcion test fails on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
10532
diff
changeset
|
79 call assert_equal('nan', string(sinh(0.0/0.0))) |
10532
80b50e43e382
commit https://github.com/vim/vim/commit/453b576ee5d32e9b8e6876712748ae01f9be68dd
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
80 endfunc |
80b50e43e382
commit https://github.com/vim/vim/commit/453b576ee5d32e9b8e6876712748ae01f9be68dd
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
81 |
80b50e43e382
commit https://github.com/vim/vim/commit/453b576ee5d32e9b8e6876712748ae01f9be68dd
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
82 func Test_cos() |
10536
6ddf322ff7cf
patch 8.0.0158: float funcion test fails on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
10532
diff
changeset
|
83 call assert_equal('1.0', string(cos(0.0))) |
6ddf322ff7cf
patch 8.0.0158: float funcion test fails on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
10532
diff
changeset
|
84 call assert_equal('0.540302', string(cos(1.0))) |
6ddf322ff7cf
patch 8.0.0158: float funcion test fails on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
10532
diff
changeset
|
85 call assert_equal('0.877583', string(cos(-0.5))) |
6ddf322ff7cf
patch 8.0.0158: float funcion test fails on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
10532
diff
changeset
|
86 call assert_equal('nan', string(cos(0.0/0.0))) |
6ddf322ff7cf
patch 8.0.0158: float funcion test fails on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
10532
diff
changeset
|
87 call assert_equal('nan', string(cos(1.0/0.0))) |
10532
80b50e43e382
commit https://github.com/vim/vim/commit/453b576ee5d32e9b8e6876712748ae01f9be68dd
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
88 endfunc |
80b50e43e382
commit https://github.com/vim/vim/commit/453b576ee5d32e9b8e6876712748ae01f9be68dd
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
89 |
80b50e43e382
commit https://github.com/vim/vim/commit/453b576ee5d32e9b8e6876712748ae01f9be68dd
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
90 func Test_acos() |
10536
6ddf322ff7cf
patch 8.0.0158: float funcion test fails on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
10532
diff
changeset
|
91 call assert_equal('1.570796', string(acos(0.0))) |
6ddf322ff7cf
patch 8.0.0158: float funcion test fails on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
10532
diff
changeset
|
92 call assert_equal('0.0', string(acos(1.0))) |
6ddf322ff7cf
patch 8.0.0158: float funcion test fails on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
10532
diff
changeset
|
93 call assert_equal('3.141593', string(acos(-1.0))) |
6ddf322ff7cf
patch 8.0.0158: float funcion test fails on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
10532
diff
changeset
|
94 call assert_equal('2.094395', string(acos(-0.5))) |
6ddf322ff7cf
patch 8.0.0158: float funcion test fails on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
10532
diff
changeset
|
95 call assert_equal('nan', string(acos(1.1))) |
6ddf322ff7cf
patch 8.0.0158: float funcion test fails on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
10532
diff
changeset
|
96 call assert_equal('nan', string(acos(1.0/0.0))) |
6ddf322ff7cf
patch 8.0.0158: float funcion test fails on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
10532
diff
changeset
|
97 call assert_equal('nan', string(acos(0.0/0.0))) |
10532
80b50e43e382
commit https://github.com/vim/vim/commit/453b576ee5d32e9b8e6876712748ae01f9be68dd
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
98 endfunc |
80b50e43e382
commit https://github.com/vim/vim/commit/453b576ee5d32e9b8e6876712748ae01f9be68dd
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
99 |
80b50e43e382
commit https://github.com/vim/vim/commit/453b576ee5d32e9b8e6876712748ae01f9be68dd
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
100 func Test_cosh() |
10536
6ddf322ff7cf
patch 8.0.0158: float funcion test fails on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
10532
diff
changeset
|
101 call assert_equal('1.0', string(cosh(0.0))) |
6ddf322ff7cf
patch 8.0.0158: float funcion test fails on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
10532
diff
changeset
|
102 call assert_equal('1.127626', string(cosh(0.5))) |
6ddf322ff7cf
patch 8.0.0158: float funcion test fails on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
10532
diff
changeset
|
103 call assert_equal('inf', string(cosh(1.0/0.0))) |
6ddf322ff7cf
patch 8.0.0158: float funcion test fails on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
10532
diff
changeset
|
104 call assert_equal('inf', string(cosh(-1.0/0.0))) |
6ddf322ff7cf
patch 8.0.0158: float funcion test fails on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
10532
diff
changeset
|
105 call assert_equal('nan', string(cosh(0.0/0.0))) |
10532
80b50e43e382
commit https://github.com/vim/vim/commit/453b576ee5d32e9b8e6876712748ae01f9be68dd
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
106 endfunc |
80b50e43e382
commit https://github.com/vim/vim/commit/453b576ee5d32e9b8e6876712748ae01f9be68dd
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
107 |
80b50e43e382
commit https://github.com/vim/vim/commit/453b576ee5d32e9b8e6876712748ae01f9be68dd
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
108 func Test_tan() |
10536
6ddf322ff7cf
patch 8.0.0158: float funcion test fails on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
10532
diff
changeset
|
109 call assert_equal('0.0', string(tan(0.0))) |
6ddf322ff7cf
patch 8.0.0158: float funcion test fails on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
10532
diff
changeset
|
110 call assert_equal('0.546302', string(tan(0.5))) |
6ddf322ff7cf
patch 8.0.0158: float funcion test fails on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
10532
diff
changeset
|
111 call assert_equal('-0.546302', string(tan(-0.5))) |
6ddf322ff7cf
patch 8.0.0158: float funcion test fails on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
10532
diff
changeset
|
112 call assert_equal('nan', string(tan(1.0/0.0))) |
6ddf322ff7cf
patch 8.0.0158: float funcion test fails on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
10532
diff
changeset
|
113 call assert_equal('nan', string(cos(0.0/0.0))) |
6ddf322ff7cf
patch 8.0.0158: float funcion test fails on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
10532
diff
changeset
|
114 call assert_equal('0.0', string(tan(1.0/(1.0/0.0)))) |
6ddf322ff7cf
patch 8.0.0158: float funcion test fails on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
10532
diff
changeset
|
115 call assert_equal('-0.0', string(tan(-1.0/(1.0/0.0)))) |
10532
80b50e43e382
commit https://github.com/vim/vim/commit/453b576ee5d32e9b8e6876712748ae01f9be68dd
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
116 endfunc |
80b50e43e382
commit https://github.com/vim/vim/commit/453b576ee5d32e9b8e6876712748ae01f9be68dd
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
117 |
80b50e43e382
commit https://github.com/vim/vim/commit/453b576ee5d32e9b8e6876712748ae01f9be68dd
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
118 func Test_atan() |
10536
6ddf322ff7cf
patch 8.0.0158: float funcion test fails on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
10532
diff
changeset
|
119 call assert_equal('0.0', string(atan(0.0))) |
6ddf322ff7cf
patch 8.0.0158: float funcion test fails on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
10532
diff
changeset
|
120 call assert_equal('0.463648', string(atan(0.5))) |
6ddf322ff7cf
patch 8.0.0158: float funcion test fails on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
10532
diff
changeset
|
121 call assert_equal('-0.785398', string(atan(-1.0))) |
6ddf322ff7cf
patch 8.0.0158: float funcion test fails on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
10532
diff
changeset
|
122 call assert_equal('1.570796', string(atan(1.0/0.0))) |
6ddf322ff7cf
patch 8.0.0158: float funcion test fails on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
10532
diff
changeset
|
123 call assert_equal('-1.570796', string(atan(-1.0/0.0))) |
6ddf322ff7cf
patch 8.0.0158: float funcion test fails on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
10532
diff
changeset
|
124 call assert_equal('nan', string(atan(0.0/0.0))) |
10532
80b50e43e382
commit https://github.com/vim/vim/commit/453b576ee5d32e9b8e6876712748ae01f9be68dd
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
125 endfunc |
80b50e43e382
commit https://github.com/vim/vim/commit/453b576ee5d32e9b8e6876712748ae01f9be68dd
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
126 |
80b50e43e382
commit https://github.com/vim/vim/commit/453b576ee5d32e9b8e6876712748ae01f9be68dd
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
127 func Test_atan2() |
10536
6ddf322ff7cf
patch 8.0.0158: float funcion test fails on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
10532
diff
changeset
|
128 call assert_equal('-2.356194', string(atan2(-1, -1))) |
6ddf322ff7cf
patch 8.0.0158: float funcion test fails on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
10532
diff
changeset
|
129 call assert_equal('2.356194', string(atan2(1, -1))) |
6ddf322ff7cf
patch 8.0.0158: float funcion test fails on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
10532
diff
changeset
|
130 call assert_equal('0.0', string(atan2(1.0, 1.0/0.0))) |
6ddf322ff7cf
patch 8.0.0158: float funcion test fails on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
10532
diff
changeset
|
131 call assert_equal('1.570796', string(atan2(1.0/0.0, 1.0))) |
6ddf322ff7cf
patch 8.0.0158: float funcion test fails on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
10532
diff
changeset
|
132 call assert_equal('nan', string(atan2(0.0/0.0, 1.0))) |
10532
80b50e43e382
commit https://github.com/vim/vim/commit/453b576ee5d32e9b8e6876712748ae01f9be68dd
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
133 endfunc |
80b50e43e382
commit https://github.com/vim/vim/commit/453b576ee5d32e9b8e6876712748ae01f9be68dd
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
134 |
80b50e43e382
commit https://github.com/vim/vim/commit/453b576ee5d32e9b8e6876712748ae01f9be68dd
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
135 func Test_tanh() |
10536
6ddf322ff7cf
patch 8.0.0158: float funcion test fails on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
10532
diff
changeset
|
136 call assert_equal('0.0', string(tanh(0.0))) |
6ddf322ff7cf
patch 8.0.0158: float funcion test fails on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
10532
diff
changeset
|
137 call assert_equal('0.462117', string(tanh(0.5))) |
6ddf322ff7cf
patch 8.0.0158: float funcion test fails on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
10532
diff
changeset
|
138 call assert_equal('-0.761594', string(tanh(-1.0))) |
6ddf322ff7cf
patch 8.0.0158: float funcion test fails on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
10532
diff
changeset
|
139 call assert_equal('1.0', string(tanh(1.0/0.0))) |
6ddf322ff7cf
patch 8.0.0158: float funcion test fails on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
10532
diff
changeset
|
140 call assert_equal('-1.0', string(tanh(-1.0/0.0))) |
6ddf322ff7cf
patch 8.0.0158: float funcion test fails on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
10532
diff
changeset
|
141 call assert_equal('nan', string(tanh(0.0/0.0))) |
10532
80b50e43e382
commit https://github.com/vim/vim/commit/453b576ee5d32e9b8e6876712748ae01f9be68dd
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
142 endfunc |
80b50e43e382
commit https://github.com/vim/vim/commit/453b576ee5d32e9b8e6876712748ae01f9be68dd
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
143 |
80b50e43e382
commit https://github.com/vim/vim/commit/453b576ee5d32e9b8e6876712748ae01f9be68dd
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
144 func Test_fmod() |
10536
6ddf322ff7cf
patch 8.0.0158: float funcion test fails on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
10532
diff
changeset
|
145 call assert_equal('0.13', string(fmod(12.33, 1.22))) |
6ddf322ff7cf
patch 8.0.0158: float funcion test fails on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
10532
diff
changeset
|
146 call assert_equal('-0.13', string(fmod(-12.33, 1.22))) |
6ddf322ff7cf
patch 8.0.0158: float funcion test fails on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
10532
diff
changeset
|
147 call assert_equal('nan', string(fmod(1.0/0.0, 1.0))) |
6ddf322ff7cf
patch 8.0.0158: float funcion test fails on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
10532
diff
changeset
|
148 " On Windows we get "nan" instead of 1.0, accept both. |
6ddf322ff7cf
patch 8.0.0158: float funcion test fails on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
10532
diff
changeset
|
149 let res = string(fmod(1.0, 1.0/0.0)) |
6ddf322ff7cf
patch 8.0.0158: float funcion test fails on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
10532
diff
changeset
|
150 if res != 'nan' |
6ddf322ff7cf
patch 8.0.0158: float funcion test fails on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
10532
diff
changeset
|
151 call assert_equal('1.0', res) |
6ddf322ff7cf
patch 8.0.0158: float funcion test fails on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
10532
diff
changeset
|
152 endif |
6ddf322ff7cf
patch 8.0.0158: float funcion test fails on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
10532
diff
changeset
|
153 call assert_equal('nan', string(fmod(1.0, 0.0))) |
10532
80b50e43e382
commit https://github.com/vim/vim/commit/453b576ee5d32e9b8e6876712748ae01f9be68dd
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
154 endfunc |
80b50e43e382
commit https://github.com/vim/vim/commit/453b576ee5d32e9b8e6876712748ae01f9be68dd
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
155 |
80b50e43e382
commit https://github.com/vim/vim/commit/453b576ee5d32e9b8e6876712748ae01f9be68dd
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
156 func Test_pow() |
10536
6ddf322ff7cf
patch 8.0.0158: float funcion test fails on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
10532
diff
changeset
|
157 call assert_equal('1.0', string(pow(0.0, 0.0))) |
6ddf322ff7cf
patch 8.0.0158: float funcion test fails on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
10532
diff
changeset
|
158 call assert_equal('8.0', string(pow(2.0, 3.0))) |
6ddf322ff7cf
patch 8.0.0158: float funcion test fails on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
10532
diff
changeset
|
159 call assert_equal('nan', string(pow(2.0, 0.0/0.0))) |
6ddf322ff7cf
patch 8.0.0158: float funcion test fails on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
10532
diff
changeset
|
160 call assert_equal('nan', string(pow(0.0/0.0, 3.0))) |
6ddf322ff7cf
patch 8.0.0158: float funcion test fails on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
10532
diff
changeset
|
161 call assert_equal('nan', string(pow(0.0/0.0, 3.0))) |
6ddf322ff7cf
patch 8.0.0158: float funcion test fails on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
10532
diff
changeset
|
162 call assert_equal('inf', string(pow(2.0, 1.0/0.0))) |
6ddf322ff7cf
patch 8.0.0158: float funcion test fails on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
10532
diff
changeset
|
163 call assert_equal('inf', string(pow(1.0/0.0, 3.0))) |
10532
80b50e43e382
commit https://github.com/vim/vim/commit/453b576ee5d32e9b8e6876712748ae01f9be68dd
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
164 endfunc |
80b50e43e382
commit https://github.com/vim/vim/commit/453b576ee5d32e9b8e6876712748ae01f9be68dd
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
165 |
80b50e43e382
commit https://github.com/vim/vim/commit/453b576ee5d32e9b8e6876712748ae01f9be68dd
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
166 func Test_str2float() |
10536
6ddf322ff7cf
patch 8.0.0158: float funcion test fails on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
10532
diff
changeset
|
167 call assert_equal('1.0', string(str2float('1'))) |
10555
fff45421182b
patch 8.0.0167: str2nr()/str2float() fail with negative values
Christian Brabandt <cb@256bit.org>
parents:
10536
diff
changeset
|
168 call assert_equal('1.0', string(str2float(' 1 '))) |
fff45421182b
patch 8.0.0167: str2nr()/str2float() fail with negative values
Christian Brabandt <cb@256bit.org>
parents:
10536
diff
changeset
|
169 call assert_equal('1.0', string(str2float(' 1.0 '))) |
10536
6ddf322ff7cf
patch 8.0.0158: float funcion test fails on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
10532
diff
changeset
|
170 call assert_equal('1.23', string(str2float('1.23'))) |
6ddf322ff7cf
patch 8.0.0158: float funcion test fails on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
10532
diff
changeset
|
171 call assert_equal('1.23', string(str2float('1.23abc'))) |
6ddf322ff7cf
patch 8.0.0158: float funcion test fails on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
10532
diff
changeset
|
172 call assert_equal('1.0e40', string(str2float('1e40'))) |
10555
fff45421182b
patch 8.0.0167: str2nr()/str2float() fail with negative values
Christian Brabandt <cb@256bit.org>
parents:
10536
diff
changeset
|
173 |
fff45421182b
patch 8.0.0167: str2nr()/str2float() fail with negative values
Christian Brabandt <cb@256bit.org>
parents:
10536
diff
changeset
|
174 call assert_equal('1.0', string(str2float('+1'))) |
fff45421182b
patch 8.0.0167: str2nr()/str2float() fail with negative values
Christian Brabandt <cb@256bit.org>
parents:
10536
diff
changeset
|
175 call assert_equal('1.0', string(str2float('+1'))) |
fff45421182b
patch 8.0.0167: str2nr()/str2float() fail with negative values
Christian Brabandt <cb@256bit.org>
parents:
10536
diff
changeset
|
176 call assert_equal('1.0', string(str2float(' +1 '))) |
fff45421182b
patch 8.0.0167: str2nr()/str2float() fail with negative values
Christian Brabandt <cb@256bit.org>
parents:
10536
diff
changeset
|
177 call assert_equal('1.0', string(str2float(' + 1 '))) |
fff45421182b
patch 8.0.0167: str2nr()/str2float() fail with negative values
Christian Brabandt <cb@256bit.org>
parents:
10536
diff
changeset
|
178 |
fff45421182b
patch 8.0.0167: str2nr()/str2float() fail with negative values
Christian Brabandt <cb@256bit.org>
parents:
10536
diff
changeset
|
179 call assert_equal('-1.0', string(str2float('-1'))) |
fff45421182b
patch 8.0.0167: str2nr()/str2float() fail with negative values
Christian Brabandt <cb@256bit.org>
parents:
10536
diff
changeset
|
180 call assert_equal('-1.0', string(str2float('-1'))) |
fff45421182b
patch 8.0.0167: str2nr()/str2float() fail with negative values
Christian Brabandt <cb@256bit.org>
parents:
10536
diff
changeset
|
181 call assert_equal('-1.0', string(str2float(' -1 '))) |
fff45421182b
patch 8.0.0167: str2nr()/str2float() fail with negative values
Christian Brabandt <cb@256bit.org>
parents:
10536
diff
changeset
|
182 call assert_equal('-1.0', string(str2float(' - 1 '))) |
fff45421182b
patch 8.0.0167: str2nr()/str2float() fail with negative values
Christian Brabandt <cb@256bit.org>
parents:
10536
diff
changeset
|
183 |
10536
6ddf322ff7cf
patch 8.0.0158: float funcion test fails on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
10532
diff
changeset
|
184 call assert_equal('inf', string(str2float('1e1000'))) |
6ddf322ff7cf
patch 8.0.0158: float funcion test fails on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
10532
diff
changeset
|
185 call assert_equal('inf', string(str2float('inf'))) |
6ddf322ff7cf
patch 8.0.0158: float funcion test fails on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
10532
diff
changeset
|
186 call assert_equal('-inf', string(str2float('-inf'))) |
6ddf322ff7cf
patch 8.0.0158: float funcion test fails on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
10532
diff
changeset
|
187 call assert_equal('inf', string(str2float('Inf'))) |
6ddf322ff7cf
patch 8.0.0158: float funcion test fails on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
10532
diff
changeset
|
188 call assert_equal('nan', string(str2float('nan'))) |
6ddf322ff7cf
patch 8.0.0158: float funcion test fails on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
10532
diff
changeset
|
189 call assert_equal('nan', string(str2float('NaN'))) |
10532
80b50e43e382
commit https://github.com/vim/vim/commit/453b576ee5d32e9b8e6876712748ae01f9be68dd
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
190 endfunc |
80b50e43e382
commit https://github.com/vim/vim/commit/453b576ee5d32e9b8e6876712748ae01f9be68dd
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
191 |
80b50e43e382
commit https://github.com/vim/vim/commit/453b576ee5d32e9b8e6876712748ae01f9be68dd
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
192 func Test_floor() |
10536
6ddf322ff7cf
patch 8.0.0158: float funcion test fails on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
10532
diff
changeset
|
193 call assert_equal('2.0', string(floor(2.0))) |
6ddf322ff7cf
patch 8.0.0158: float funcion test fails on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
10532
diff
changeset
|
194 call assert_equal('2.0', string(floor(2.11))) |
6ddf322ff7cf
patch 8.0.0158: float funcion test fails on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
10532
diff
changeset
|
195 call assert_equal('2.0', string(floor(2.99))) |
6ddf322ff7cf
patch 8.0.0158: float funcion test fails on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
10532
diff
changeset
|
196 call assert_equal('-3.0', string(floor(-2.11))) |
6ddf322ff7cf
patch 8.0.0158: float funcion test fails on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
10532
diff
changeset
|
197 call assert_equal('-3.0', string(floor(-2.99))) |
6ddf322ff7cf
patch 8.0.0158: float funcion test fails on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
10532
diff
changeset
|
198 call assert_equal('nan', string(floor(0.0/0.0))) |
6ddf322ff7cf
patch 8.0.0158: float funcion test fails on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
10532
diff
changeset
|
199 call assert_equal('inf', string(floor(1.0/0.0))) |
6ddf322ff7cf
patch 8.0.0158: float funcion test fails on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
10532
diff
changeset
|
200 call assert_equal('-inf', string(floor(-1.0/0.0))) |
10532
80b50e43e382
commit https://github.com/vim/vim/commit/453b576ee5d32e9b8e6876712748ae01f9be68dd
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
201 endfunc |
80b50e43e382
commit https://github.com/vim/vim/commit/453b576ee5d32e9b8e6876712748ae01f9be68dd
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
202 |
80b50e43e382
commit https://github.com/vim/vim/commit/453b576ee5d32e9b8e6876712748ae01f9be68dd
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
203 func Test_ceil() |
10536
6ddf322ff7cf
patch 8.0.0158: float funcion test fails on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
10532
diff
changeset
|
204 call assert_equal('2.0', string(ceil(2.0))) |
6ddf322ff7cf
patch 8.0.0158: float funcion test fails on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
10532
diff
changeset
|
205 call assert_equal('3.0', string(ceil(2.11))) |
6ddf322ff7cf
patch 8.0.0158: float funcion test fails on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
10532
diff
changeset
|
206 call assert_equal('3.0', string(ceil(2.99))) |
6ddf322ff7cf
patch 8.0.0158: float funcion test fails on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
10532
diff
changeset
|
207 call assert_equal('-2.0', string(ceil(-2.11))) |
6ddf322ff7cf
patch 8.0.0158: float funcion test fails on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
10532
diff
changeset
|
208 call assert_equal('-2.0', string(ceil(-2.99))) |
6ddf322ff7cf
patch 8.0.0158: float funcion test fails on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
10532
diff
changeset
|
209 call assert_equal('nan', string(ceil(0.0/0.0))) |
6ddf322ff7cf
patch 8.0.0158: float funcion test fails on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
10532
diff
changeset
|
210 call assert_equal('inf', string(ceil(1.0/0.0))) |
6ddf322ff7cf
patch 8.0.0158: float funcion test fails on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
10532
diff
changeset
|
211 call assert_equal('-inf', string(ceil(-1.0/0.0))) |
10532
80b50e43e382
commit https://github.com/vim/vim/commit/453b576ee5d32e9b8e6876712748ae01f9be68dd
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
212 endfunc |
80b50e43e382
commit https://github.com/vim/vim/commit/453b576ee5d32e9b8e6876712748ae01f9be68dd
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
213 |
80b50e43e382
commit https://github.com/vim/vim/commit/453b576ee5d32e9b8e6876712748ae01f9be68dd
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
214 func Test_round() |
10536
6ddf322ff7cf
patch 8.0.0158: float funcion test fails on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
10532
diff
changeset
|
215 call assert_equal('2.0', string(round(2.1))) |
6ddf322ff7cf
patch 8.0.0158: float funcion test fails on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
10532
diff
changeset
|
216 call assert_equal('3.0', string(round(2.5))) |
6ddf322ff7cf
patch 8.0.0158: float funcion test fails on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
10532
diff
changeset
|
217 call assert_equal('3.0', string(round(2.9))) |
6ddf322ff7cf
patch 8.0.0158: float funcion test fails on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
10532
diff
changeset
|
218 call assert_equal('-2.0', string(round(-2.1))) |
6ddf322ff7cf
patch 8.0.0158: float funcion test fails on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
10532
diff
changeset
|
219 call assert_equal('-3.0', string(round(-2.5))) |
6ddf322ff7cf
patch 8.0.0158: float funcion test fails on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
10532
diff
changeset
|
220 call assert_equal('-3.0', string(round(-2.9))) |
6ddf322ff7cf
patch 8.0.0158: float funcion test fails on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
10532
diff
changeset
|
221 call assert_equal('nan', string(round(0.0/0.0))) |
6ddf322ff7cf
patch 8.0.0158: float funcion test fails on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
10532
diff
changeset
|
222 call assert_equal('inf', string(round(1.0/0.0))) |
6ddf322ff7cf
patch 8.0.0158: float funcion test fails on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
10532
diff
changeset
|
223 call assert_equal('-inf', string(round(-1.0/0.0))) |
10532
80b50e43e382
commit https://github.com/vim/vim/commit/453b576ee5d32e9b8e6876712748ae01f9be68dd
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
224 endfunc |
80b50e43e382
commit https://github.com/vim/vim/commit/453b576ee5d32e9b8e6876712748ae01f9be68dd
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
225 |
80b50e43e382
commit https://github.com/vim/vim/commit/453b576ee5d32e9b8e6876712748ae01f9be68dd
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
226 func Test_trunc() |
10536
6ddf322ff7cf
patch 8.0.0158: float funcion test fails on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
10532
diff
changeset
|
227 call assert_equal('2.0', string(trunc(2.1))) |
6ddf322ff7cf
patch 8.0.0158: float funcion test fails on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
10532
diff
changeset
|
228 call assert_equal('2.0', string(trunc(2.5))) |
6ddf322ff7cf
patch 8.0.0158: float funcion test fails on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
10532
diff
changeset
|
229 call assert_equal('2.0', string(trunc(2.9))) |
6ddf322ff7cf
patch 8.0.0158: float funcion test fails on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
10532
diff
changeset
|
230 call assert_equal('-2.0', string(trunc(-2.1))) |
6ddf322ff7cf
patch 8.0.0158: float funcion test fails on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
10532
diff
changeset
|
231 call assert_equal('-2.0', string(trunc(-2.5))) |
6ddf322ff7cf
patch 8.0.0158: float funcion test fails on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
10532
diff
changeset
|
232 call assert_equal('-2.0', string(trunc(-2.9))) |
6ddf322ff7cf
patch 8.0.0158: float funcion test fails on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
10532
diff
changeset
|
233 call assert_equal('nan', string(trunc(0.0/0.0))) |
6ddf322ff7cf
patch 8.0.0158: float funcion test fails on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
10532
diff
changeset
|
234 call assert_equal('inf', string(trunc(1.0/0.0))) |
6ddf322ff7cf
patch 8.0.0158: float funcion test fails on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
10532
diff
changeset
|
235 call assert_equal('-inf', string(trunc(-1.0/0.0))) |
10532
80b50e43e382
commit https://github.com/vim/vim/commit/453b576ee5d32e9b8e6876712748ae01f9be68dd
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
236 endfunc |
80b50e43e382
commit https://github.com/vim/vim/commit/453b576ee5d32e9b8e6876712748ae01f9be68dd
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
237 |
80b50e43e382
commit https://github.com/vim/vim/commit/453b576ee5d32e9b8e6876712748ae01f9be68dd
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
238 func Test_isnan() |
10536
6ddf322ff7cf
patch 8.0.0158: float funcion test fails on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
10532
diff
changeset
|
239 call assert_equal(0, isnan(1.0)) |
6ddf322ff7cf
patch 8.0.0158: float funcion test fails on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
10532
diff
changeset
|
240 call assert_equal(1, isnan(0.0/0.0)) |
6ddf322ff7cf
patch 8.0.0158: float funcion test fails on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
10532
diff
changeset
|
241 call assert_equal(0, isnan(1.0/0.0)) |
6ddf322ff7cf
patch 8.0.0158: float funcion test fails on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
10532
diff
changeset
|
242 call assert_equal(0, isnan('a')) |
6ddf322ff7cf
patch 8.0.0158: float funcion test fails on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
10532
diff
changeset
|
243 call assert_equal(0, isnan([])) |
10532
80b50e43e382
commit https://github.com/vim/vim/commit/453b576ee5d32e9b8e6876712748ae01f9be68dd
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
244 endfunc |