annotate src/testdir/test_float_func.vim @ 15062:3a94f7918980 v8.1.0542

patch 8.1.0542: shiftwidth() does not take 'vartabstop' into account commit https://github.com/vim/vim/commit/f951416a8396a54bbbe21de1a8b16716428549f2 Author: Bram Moolenaar <Bram@vim.org> Date: Thu Nov 22 03:08:29 2018 +0100 patch 8.1.0542: shiftwidth() does not take 'vartabstop' into account Problem: shiftwidth() does not take 'vartabstop' into account. Solution: Use the cursor position or a position explicitly passed. Also make >> and << work better with 'vartabstop'. (Christian Brabandt)
author Bram Moolenaar <Bram@vim.org>
date Thu, 22 Nov 2018 03:15:10 +0100
parents 5be73ebf6a15
children 2c33b119ba92
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
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)))
10557
018b7ecc58db patch 8.0.0168: not all float functionality is tested
Christian Brabandt <cb@256bit.org>
parents: 10555
diff changeset
16 call assert_equal('12', string(abs('-12abc')))
018b7ecc58db patch 8.0.0168: not all float functionality is tested
Christian Brabandt <cb@256bit.org>
parents: 10555
diff changeset
17 call assert_fails("call abs([])", 'E745:')
018b7ecc58db patch 8.0.0168: not all float functionality is tested
Christian Brabandt <cb@256bit.org>
parents: 10555
diff changeset
18 call assert_fails("call abs({})", 'E728:')
018b7ecc58db patch 8.0.0168: not all float functionality is tested
Christian Brabandt <cb@256bit.org>
parents: 10555
diff changeset
19 call assert_fails("call abs(function('string'))", 'E703:')
10532
80b50e43e382 commit https://github.com/vim/vim/commit/453b576ee5d32e9b8e6876712748ae01f9be68dd
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
20 endfunc
80b50e43e382 commit https://github.com/vim/vim/commit/453b576ee5d32e9b8e6876712748ae01f9be68dd
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
21
80b50e43e382 commit https://github.com/vim/vim/commit/453b576ee5d32e9b8e6876712748ae01f9be68dd
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
22 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
23 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
24 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
25 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
26 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
27 call assert_equal('nan', string(sqrt(0.0/0.0)))
10557
018b7ecc58db patch 8.0.0168: not all float functionality is tested
Christian Brabandt <cb@256bit.org>
parents: 10555
diff changeset
28 call assert_fails('call sqrt("")', 'E808:')
10532
80b50e43e382 commit https://github.com/vim/vim/commit/453b576ee5d32e9b8e6876712748ae01f9be68dd
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
29 endfunc
80b50e43e382 commit https://github.com/vim/vim/commit/453b576ee5d32e9b8e6876712748ae01f9be68dd
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
30
80b50e43e382 commit https://github.com/vim/vim/commit/453b576ee5d32e9b8e6876712748ae01f9be68dd
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
31 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
32 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
33 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
34 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
35 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
36 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
37 call assert_equal('nan', string(log(0.0/0.0)))
10557
018b7ecc58db patch 8.0.0168: not all float functionality is tested
Christian Brabandt <cb@256bit.org>
parents: 10555
diff changeset
38 call assert_fails('call log("")', 'E808:')
10532
80b50e43e382 commit https://github.com/vim/vim/commit/453b576ee5d32e9b8e6876712748ae01f9be68dd
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
39 endfunc
80b50e43e382 commit https://github.com/vim/vim/commit/453b576ee5d32e9b8e6876712748ae01f9be68dd
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
40
80b50e43e382 commit https://github.com/vim/vim/commit/453b576ee5d32e9b8e6876712748ae01f9be68dd
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
41 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
42 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
43 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
44 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
45 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
46 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
47 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
48 call assert_equal('nan', string(log10(0.0/0.0)))
10557
018b7ecc58db patch 8.0.0168: not all float functionality is tested
Christian Brabandt <cb@256bit.org>
parents: 10555
diff changeset
49 call assert_fails('call log10("")', 'E808:')
10532
80b50e43e382 commit https://github.com/vim/vim/commit/453b576ee5d32e9b8e6876712748ae01f9be68dd
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
50 endfunc
80b50e43e382 commit https://github.com/vim/vim/commit/453b576ee5d32e9b8e6876712748ae01f9be68dd
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
51
80b50e43e382 commit https://github.com/vim/vim/commit/453b576ee5d32e9b8e6876712748ae01f9be68dd
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
52 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
53 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
54 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
55 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
56 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
57 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
58 call assert_equal('nan', string(exp(0.0/0.0)))
10557
018b7ecc58db patch 8.0.0168: not all float functionality is tested
Christian Brabandt <cb@256bit.org>
parents: 10555
diff changeset
59 call assert_fails('call exp("")', 'E808:')
10532
80b50e43e382 commit https://github.com/vim/vim/commit/453b576ee5d32e9b8e6876712748ae01f9be68dd
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
60 endfunc
80b50e43e382 commit https://github.com/vim/vim/commit/453b576ee5d32e9b8e6876712748ae01f9be68dd
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
61
80b50e43e382 commit https://github.com/vim/vim/commit/453b576ee5d32e9b8e6876712748ae01f9be68dd
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
62 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
63 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
64 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
65 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
66 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
67 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
68 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
69 call assert_equal('-0.0', string(sin(-1.0/(1.0/0.0))))
10557
018b7ecc58db patch 8.0.0168: not all float functionality is tested
Christian Brabandt <cb@256bit.org>
parents: 10555
diff changeset
70 call assert_fails('call sin("")', 'E808:')
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_asin()
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(asin(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('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
76 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
77 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
78 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
79 call assert_equal('nan', string(asin(0.0/0.0)))
10557
018b7ecc58db patch 8.0.0168: not all float functionality is tested
Christian Brabandt <cb@256bit.org>
parents: 10555
diff changeset
80 call assert_fails('call asin("")', 'E808:')
10532
80b50e43e382 commit https://github.com/vim/vim/commit/453b576ee5d32e9b8e6876712748ae01f9be68dd
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
81 endfunc
80b50e43e382 commit https://github.com/vim/vim/commit/453b576ee5d32e9b8e6876712748ae01f9be68dd
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
82
80b50e43e382 commit https://github.com/vim/vim/commit/453b576ee5d32e9b8e6876712748ae01f9be68dd
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
83 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
84 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
85 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
86 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
87 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
88 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
89 call assert_equal('nan', string(sinh(0.0/0.0)))
10557
018b7ecc58db patch 8.0.0168: not all float functionality is tested
Christian Brabandt <cb@256bit.org>
parents: 10555
diff changeset
90 call assert_fails('call sinh("")', 'E808:')
10532
80b50e43e382 commit https://github.com/vim/vim/commit/453b576ee5d32e9b8e6876712748ae01f9be68dd
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
91 endfunc
80b50e43e382 commit https://github.com/vim/vim/commit/453b576ee5d32e9b8e6876712748ae01f9be68dd
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
92
80b50e43e382 commit https://github.com/vim/vim/commit/453b576ee5d32e9b8e6876712748ae01f9be68dd
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
93 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
94 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
95 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
96 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
97 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
98 call assert_equal('nan', string(cos(1.0/0.0)))
10557
018b7ecc58db patch 8.0.0168: not all float functionality is tested
Christian Brabandt <cb@256bit.org>
parents: 10555
diff changeset
99 call assert_fails('call cos("")', 'E808:')
10532
80b50e43e382 commit https://github.com/vim/vim/commit/453b576ee5d32e9b8e6876712748ae01f9be68dd
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
100 endfunc
80b50e43e382 commit https://github.com/vim/vim/commit/453b576ee5d32e9b8e6876712748ae01f9be68dd
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
101
80b50e43e382 commit https://github.com/vim/vim/commit/453b576ee5d32e9b8e6876712748ae01f9be68dd
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
102 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
103 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
104 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
105 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
106 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
107 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
108 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
109 call assert_equal('nan', string(acos(0.0/0.0)))
10557
018b7ecc58db patch 8.0.0168: not all float functionality is tested
Christian Brabandt <cb@256bit.org>
parents: 10555
diff changeset
110 call assert_fails('call acos("")', 'E808:')
10532
80b50e43e382 commit https://github.com/vim/vim/commit/453b576ee5d32e9b8e6876712748ae01f9be68dd
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
111 endfunc
80b50e43e382 commit https://github.com/vim/vim/commit/453b576ee5d32e9b8e6876712748ae01f9be68dd
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
112
80b50e43e382 commit https://github.com/vim/vim/commit/453b576ee5d32e9b8e6876712748ae01f9be68dd
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
113 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
114 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
115 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
116 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
117 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
118 call assert_equal('nan', string(cosh(0.0/0.0)))
10557
018b7ecc58db patch 8.0.0168: not all float functionality is tested
Christian Brabandt <cb@256bit.org>
parents: 10555
diff changeset
119 call assert_fails('call cosh("")', 'E808:')
10532
80b50e43e382 commit https://github.com/vim/vim/commit/453b576ee5d32e9b8e6876712748ae01f9be68dd
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
120 endfunc
80b50e43e382 commit https://github.com/vim/vim/commit/453b576ee5d32e9b8e6876712748ae01f9be68dd
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
121
80b50e43e382 commit https://github.com/vim/vim/commit/453b576ee5d32e9b8e6876712748ae01f9be68dd
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
122 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
123 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
124 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
125 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
126 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
127 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
128 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
129 call assert_equal('-0.0', string(tan(-1.0/(1.0/0.0))))
10557
018b7ecc58db patch 8.0.0168: not all float functionality is tested
Christian Brabandt <cb@256bit.org>
parents: 10555
diff changeset
130 call assert_fails('call tan("")', 'E808:')
10532
80b50e43e382 commit https://github.com/vim/vim/commit/453b576ee5d32e9b8e6876712748ae01f9be68dd
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
131 endfunc
80b50e43e382 commit https://github.com/vim/vim/commit/453b576ee5d32e9b8e6876712748ae01f9be68dd
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
132
80b50e43e382 commit https://github.com/vim/vim/commit/453b576ee5d32e9b8e6876712748ae01f9be68dd
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
133 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
134 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
135 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
136 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
137 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
138 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
139 call assert_equal('nan', string(atan(0.0/0.0)))
10557
018b7ecc58db patch 8.0.0168: not all float functionality is tested
Christian Brabandt <cb@256bit.org>
parents: 10555
diff changeset
140 call assert_fails('call atan("")', 'E808:')
10532
80b50e43e382 commit https://github.com/vim/vim/commit/453b576ee5d32e9b8e6876712748ae01f9be68dd
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
141 endfunc
80b50e43e382 commit https://github.com/vim/vim/commit/453b576ee5d32e9b8e6876712748ae01f9be68dd
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
142
80b50e43e382 commit https://github.com/vim/vim/commit/453b576ee5d32e9b8e6876712748ae01f9be68dd
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
143 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
144 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
145 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
146 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
147 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
148 call assert_equal('nan', string(atan2(0.0/0.0, 1.0)))
10557
018b7ecc58db patch 8.0.0168: not all float functionality is tested
Christian Brabandt <cb@256bit.org>
parents: 10555
diff changeset
149 call assert_fails('call atan2("", -1)', 'E808:')
018b7ecc58db patch 8.0.0168: not all float functionality is tested
Christian Brabandt <cb@256bit.org>
parents: 10555
diff changeset
150 call assert_fails('call atan2(-1, "")', 'E808:')
10532
80b50e43e382 commit https://github.com/vim/vim/commit/453b576ee5d32e9b8e6876712748ae01f9be68dd
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
151 endfunc
80b50e43e382 commit https://github.com/vim/vim/commit/453b576ee5d32e9b8e6876712748ae01f9be68dd
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
152
80b50e43e382 commit https://github.com/vim/vim/commit/453b576ee5d32e9b8e6876712748ae01f9be68dd
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
153 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
154 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
155 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
156 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
157 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
158 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
159 call assert_equal('nan', string(tanh(0.0/0.0)))
10557
018b7ecc58db patch 8.0.0168: not all float functionality is tested
Christian Brabandt <cb@256bit.org>
parents: 10555
diff changeset
160 call assert_fails('call tanh("")', 'E808:')
10532
80b50e43e382 commit https://github.com/vim/vim/commit/453b576ee5d32e9b8e6876712748ae01f9be68dd
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
161 endfunc
80b50e43e382 commit https://github.com/vim/vim/commit/453b576ee5d32e9b8e6876712748ae01f9be68dd
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
162
80b50e43e382 commit https://github.com/vim/vim/commit/453b576ee5d32e9b8e6876712748ae01f9be68dd
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
163 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
164 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
165 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
166 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
167 " 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
168 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
169 if res != 'nan'
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.0', res)
6ddf322ff7cf patch 8.0.0158: float funcion test fails on MS-Windows
Christian Brabandt <cb@256bit.org>
parents: 10532
diff changeset
171 endif
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('nan', string(fmod(1.0, 0.0)))
10557
018b7ecc58db patch 8.0.0168: not all float functionality is tested
Christian Brabandt <cb@256bit.org>
parents: 10555
diff changeset
173 call assert_fails("call fmod('', 1.22)", 'E808:')
018b7ecc58db patch 8.0.0168: not all float functionality is tested
Christian Brabandt <cb@256bit.org>
parents: 10555
diff changeset
174 call assert_fails("call fmod(12.33, '')", 'E808:')
10532
80b50e43e382 commit https://github.com/vim/vim/commit/453b576ee5d32e9b8e6876712748ae01f9be68dd
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
175 endfunc
80b50e43e382 commit https://github.com/vim/vim/commit/453b576ee5d32e9b8e6876712748ae01f9be68dd
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
176
80b50e43e382 commit https://github.com/vim/vim/commit/453b576ee5d32e9b8e6876712748ae01f9be68dd
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
177 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
178 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
179 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
180 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
181 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
182 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
183 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
184 call assert_equal('inf', string(pow(1.0/0.0, 3.0)))
10557
018b7ecc58db patch 8.0.0168: not all float functionality is tested
Christian Brabandt <cb@256bit.org>
parents: 10555
diff changeset
185 call assert_fails("call pow('', 2.0)", 'E808:')
018b7ecc58db patch 8.0.0168: not all float functionality is tested
Christian Brabandt <cb@256bit.org>
parents: 10555
diff changeset
186 call assert_fails("call pow(2.0, '')", 'E808:')
10532
80b50e43e382 commit https://github.com/vim/vim/commit/453b576ee5d32e9b8e6876712748ae01f9be68dd
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
187 endfunc
80b50e43e382 commit https://github.com/vim/vim/commit/453b576ee5d32e9b8e6876712748ae01f9be68dd
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
188
80b50e43e382 commit https://github.com/vim/vim/commit/453b576ee5d32e9b8e6876712748ae01f9be68dd
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
189 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
190 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
191 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
192 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
193 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
194 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
195 call assert_equal('1.0e40', string(str2float('1e40')))
10557
018b7ecc58db patch 8.0.0168: not all float functionality is tested
Christian Brabandt <cb@256bit.org>
parents: 10555
diff changeset
196 call assert_equal('-1.23', string(str2float('-1.23')))
018b7ecc58db patch 8.0.0168: not all float functionality is tested
Christian Brabandt <cb@256bit.org>
parents: 10555
diff changeset
197 call assert_equal('1.23', string(str2float(' + 1.23 ')))
10555
fff45421182b patch 8.0.0167: str2nr()/str2float() fail with negative values
Christian Brabandt <cb@256bit.org>
parents: 10536
diff changeset
198
fff45421182b patch 8.0.0167: str2nr()/str2float() fail with negative values
Christian Brabandt <cb@256bit.org>
parents: 10536
diff changeset
199 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
200 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
201 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
202 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
203
fff45421182b patch 8.0.0167: str2nr()/str2float() fail with negative values
Christian Brabandt <cb@256bit.org>
parents: 10536
diff changeset
204 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
205 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
206 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
207 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
208
10557
018b7ecc58db patch 8.0.0168: not all float functionality is tested
Christian Brabandt <cb@256bit.org>
parents: 10555
diff changeset
209 call assert_equal('0.0', string(str2float('+0.0')))
018b7ecc58db patch 8.0.0168: not all float functionality is tested
Christian Brabandt <cb@256bit.org>
parents: 10555
diff changeset
210 call assert_equal('-0.0', string(str2float('-0.0')))
10536
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(str2float('1e1000')))
6ddf322ff7cf patch 8.0.0158: float funcion test fails on MS-Windows
Christian Brabandt <cb@256bit.org>
parents: 10532
diff changeset
212 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
213 call assert_equal('-inf', string(str2float('-inf')))
10557
018b7ecc58db patch 8.0.0168: not all float functionality is tested
Christian Brabandt <cb@256bit.org>
parents: 10555
diff changeset
214 call assert_equal('inf', string(str2float('+inf')))
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('inf', string(str2float('Inf')))
10557
018b7ecc58db patch 8.0.0168: not all float functionality is tested
Christian Brabandt <cb@256bit.org>
parents: 10555
diff changeset
216 call assert_equal('inf', string(str2float(' +inf ')))
10536
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('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
218 call assert_equal('nan', string(str2float('NaN')))
10557
018b7ecc58db patch 8.0.0168: not all float functionality is tested
Christian Brabandt <cb@256bit.org>
parents: 10555
diff changeset
219 call assert_equal('nan', string(str2float(' nan ')))
018b7ecc58db patch 8.0.0168: not all float functionality is tested
Christian Brabandt <cb@256bit.org>
parents: 10555
diff changeset
220
018b7ecc58db patch 8.0.0168: not all float functionality is tested
Christian Brabandt <cb@256bit.org>
parents: 10555
diff changeset
221 call assert_fails("call str2float(1.2)", 'E806:')
018b7ecc58db patch 8.0.0168: not all float functionality is tested
Christian Brabandt <cb@256bit.org>
parents: 10555
diff changeset
222 call assert_fails("call str2float([])", 'E730:')
018b7ecc58db patch 8.0.0168: not all float functionality is tested
Christian Brabandt <cb@256bit.org>
parents: 10555
diff changeset
223 call assert_fails("call str2float({})", 'E731:')
018b7ecc58db patch 8.0.0168: not all float functionality is tested
Christian Brabandt <cb@256bit.org>
parents: 10555
diff changeset
224 call assert_fails("call str2float(function('string'))", 'E729:')
10532
80b50e43e382 commit https://github.com/vim/vim/commit/453b576ee5d32e9b8e6876712748ae01f9be68dd
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
225 endfunc
80b50e43e382 commit https://github.com/vim/vim/commit/453b576ee5d32e9b8e6876712748ae01f9be68dd
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
226
11461
5be73ebf6a15 patch 8.0.0614: float2nr() is not exactly right
Christian Brabandt <cb@256bit.org>
parents: 10557
diff changeset
227 func Test_float2nr()
5be73ebf6a15 patch 8.0.0614: float2nr() is not exactly right
Christian Brabandt <cb@256bit.org>
parents: 10557
diff changeset
228 call assert_equal(1, float2nr(1.234))
5be73ebf6a15 patch 8.0.0614: float2nr() is not exactly right
Christian Brabandt <cb@256bit.org>
parents: 10557
diff changeset
229 call assert_equal(123, float2nr(1.234e2))
5be73ebf6a15 patch 8.0.0614: float2nr() is not exactly right
Christian Brabandt <cb@256bit.org>
parents: 10557
diff changeset
230 call assert_equal(12, float2nr(123.4e-1))
5be73ebf6a15 patch 8.0.0614: float2nr() is not exactly right
Christian Brabandt <cb@256bit.org>
parents: 10557
diff changeset
231 let max_number = 1/0
5be73ebf6a15 patch 8.0.0614: float2nr() is not exactly right
Christian Brabandt <cb@256bit.org>
parents: 10557
diff changeset
232 let min_number = -max_number
5be73ebf6a15 patch 8.0.0614: float2nr() is not exactly right
Christian Brabandt <cb@256bit.org>
parents: 10557
diff changeset
233 call assert_equal(max_number/2+1, float2nr(pow(2, 62)))
5be73ebf6a15 patch 8.0.0614: float2nr() is not exactly right
Christian Brabandt <cb@256bit.org>
parents: 10557
diff changeset
234 call assert_equal(max_number, float2nr(pow(2, 63)))
5be73ebf6a15 patch 8.0.0614: float2nr() is not exactly right
Christian Brabandt <cb@256bit.org>
parents: 10557
diff changeset
235 call assert_equal(max_number, float2nr(pow(2, 64)))
5be73ebf6a15 patch 8.0.0614: float2nr() is not exactly right
Christian Brabandt <cb@256bit.org>
parents: 10557
diff changeset
236 call assert_equal(min_number/2-1, float2nr(-pow(2, 62)))
5be73ebf6a15 patch 8.0.0614: float2nr() is not exactly right
Christian Brabandt <cb@256bit.org>
parents: 10557
diff changeset
237 call assert_equal(min_number, float2nr(-pow(2, 63)))
5be73ebf6a15 patch 8.0.0614: float2nr() is not exactly right
Christian Brabandt <cb@256bit.org>
parents: 10557
diff changeset
238 call assert_equal(min_number, float2nr(-pow(2, 64)))
5be73ebf6a15 patch 8.0.0614: float2nr() is not exactly right
Christian Brabandt <cb@256bit.org>
parents: 10557
diff changeset
239 endfunc
5be73ebf6a15 patch 8.0.0614: float2nr() is not exactly right
Christian Brabandt <cb@256bit.org>
parents: 10557
diff changeset
240
10532
80b50e43e382 commit https://github.com/vim/vim/commit/453b576ee5d32e9b8e6876712748ae01f9be68dd
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
241 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
242 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
243 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
244 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
245 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
246 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
247 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
248 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
249 call assert_equal('-inf', string(floor(-1.0/0.0)))
10557
018b7ecc58db patch 8.0.0168: not all float functionality is tested
Christian Brabandt <cb@256bit.org>
parents: 10555
diff changeset
250 call assert_fails("call floor('')", 'E808:')
10532
80b50e43e382 commit https://github.com/vim/vim/commit/453b576ee5d32e9b8e6876712748ae01f9be68dd
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
251 endfunc
80b50e43e382 commit https://github.com/vim/vim/commit/453b576ee5d32e9b8e6876712748ae01f9be68dd
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
252
80b50e43e382 commit https://github.com/vim/vim/commit/453b576ee5d32e9b8e6876712748ae01f9be68dd
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
253 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
254 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
255 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
256 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
257 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
258 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
259 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
260 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
261 call assert_equal('-inf', string(ceil(-1.0/0.0)))
10557
018b7ecc58db patch 8.0.0168: not all float functionality is tested
Christian Brabandt <cb@256bit.org>
parents: 10555
diff changeset
262 call assert_fails("call ceil('')", 'E808:')
10532
80b50e43e382 commit https://github.com/vim/vim/commit/453b576ee5d32e9b8e6876712748ae01f9be68dd
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
263 endfunc
80b50e43e382 commit https://github.com/vim/vim/commit/453b576ee5d32e9b8e6876712748ae01f9be68dd
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
264
80b50e43e382 commit https://github.com/vim/vim/commit/453b576ee5d32e9b8e6876712748ae01f9be68dd
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
265 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
266 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
267 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
268 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
269 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
270 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
271 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
272 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
273 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
274 call assert_equal('-inf', string(round(-1.0/0.0)))
10557
018b7ecc58db patch 8.0.0168: not all float functionality is tested
Christian Brabandt <cb@256bit.org>
parents: 10555
diff changeset
275 call assert_fails("call round('')", 'E808:')
10532
80b50e43e382 commit https://github.com/vim/vim/commit/453b576ee5d32e9b8e6876712748ae01f9be68dd
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
276 endfunc
80b50e43e382 commit https://github.com/vim/vim/commit/453b576ee5d32e9b8e6876712748ae01f9be68dd
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
277
80b50e43e382 commit https://github.com/vim/vim/commit/453b576ee5d32e9b8e6876712748ae01f9be68dd
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
278 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
279 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
280 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
281 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
282 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
283 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
284 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
285 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
286 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
287 call assert_equal('-inf', string(trunc(-1.0/0.0)))
10557
018b7ecc58db patch 8.0.0168: not all float functionality is tested
Christian Brabandt <cb@256bit.org>
parents: 10555
diff changeset
288 call assert_fails("call trunc('')", 'E808:')
10532
80b50e43e382 commit https://github.com/vim/vim/commit/453b576ee5d32e9b8e6876712748ae01f9be68dd
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
289 endfunc
80b50e43e382 commit https://github.com/vim/vim/commit/453b576ee5d32e9b8e6876712748ae01f9be68dd
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
290
80b50e43e382 commit https://github.com/vim/vim/commit/453b576ee5d32e9b8e6876712748ae01f9be68dd
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
291 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
292 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
293 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
294 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
295 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
296 call assert_equal(0, isnan([]))
10557
018b7ecc58db patch 8.0.0168: not all float functionality is tested
Christian Brabandt <cb@256bit.org>
parents: 10555
diff changeset
297 call assert_equal(0, isnan({}))
10532
80b50e43e382 commit https://github.com/vim/vim/commit/453b576ee5d32e9b8e6876712748ae01f9be68dd
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
298 endfunc
11461
5be73ebf6a15 patch 8.0.0614: float2nr() is not exactly right
Christian Brabandt <cb@256bit.org>
parents: 10557
diff changeset
299
5be73ebf6a15 patch 8.0.0614: float2nr() is not exactly right
Christian Brabandt <cb@256bit.org>
parents: 10557
diff changeset
300 " This was converted from test65
5be73ebf6a15 patch 8.0.0614: float2nr() is not exactly right
Christian Brabandt <cb@256bit.org>
parents: 10557
diff changeset
301 func Test_float_misc()
5be73ebf6a15 patch 8.0.0614: float2nr() is not exactly right
Christian Brabandt <cb@256bit.org>
parents: 10557
diff changeset
302 call assert_equal('123.456000', printf('%f', 123.456))
5be73ebf6a15 patch 8.0.0614: float2nr() is not exactly right
Christian Brabandt <cb@256bit.org>
parents: 10557
diff changeset
303 call assert_equal('1.234560e+02', printf('%e', 123.456))
5be73ebf6a15 patch 8.0.0614: float2nr() is not exactly right
Christian Brabandt <cb@256bit.org>
parents: 10557
diff changeset
304 call assert_equal('123.456', printf('%g', 123.456))
5be73ebf6a15 patch 8.0.0614: float2nr() is not exactly right
Christian Brabandt <cb@256bit.org>
parents: 10557
diff changeset
305 " +=
5be73ebf6a15 patch 8.0.0614: float2nr() is not exactly right
Christian Brabandt <cb@256bit.org>
parents: 10557
diff changeset
306 let v = 1.234
5be73ebf6a15 patch 8.0.0614: float2nr() is not exactly right
Christian Brabandt <cb@256bit.org>
parents: 10557
diff changeset
307 let v += 6.543
5be73ebf6a15 patch 8.0.0614: float2nr() is not exactly right
Christian Brabandt <cb@256bit.org>
parents: 10557
diff changeset
308 call assert_equal('7.777', printf('%g', v))
5be73ebf6a15 patch 8.0.0614: float2nr() is not exactly right
Christian Brabandt <cb@256bit.org>
parents: 10557
diff changeset
309 let v = 1.234
5be73ebf6a15 patch 8.0.0614: float2nr() is not exactly right
Christian Brabandt <cb@256bit.org>
parents: 10557
diff changeset
310 let v += 5
5be73ebf6a15 patch 8.0.0614: float2nr() is not exactly right
Christian Brabandt <cb@256bit.org>
parents: 10557
diff changeset
311 call assert_equal('6.234', printf('%g', v))
5be73ebf6a15 patch 8.0.0614: float2nr() is not exactly right
Christian Brabandt <cb@256bit.org>
parents: 10557
diff changeset
312 let v = 5
5be73ebf6a15 patch 8.0.0614: float2nr() is not exactly right
Christian Brabandt <cb@256bit.org>
parents: 10557
diff changeset
313 let v += 3.333
5be73ebf6a15 patch 8.0.0614: float2nr() is not exactly right
Christian Brabandt <cb@256bit.org>
parents: 10557
diff changeset
314 call assert_equal('8.333', string(v))
5be73ebf6a15 patch 8.0.0614: float2nr() is not exactly right
Christian Brabandt <cb@256bit.org>
parents: 10557
diff changeset
315 " ==
5be73ebf6a15 patch 8.0.0614: float2nr() is not exactly right
Christian Brabandt <cb@256bit.org>
parents: 10557
diff changeset
316 let v = 1.234
5be73ebf6a15 patch 8.0.0614: float2nr() is not exactly right
Christian Brabandt <cb@256bit.org>
parents: 10557
diff changeset
317 call assert_true(v == 1.234)
5be73ebf6a15 patch 8.0.0614: float2nr() is not exactly right
Christian Brabandt <cb@256bit.org>
parents: 10557
diff changeset
318 call assert_false(v == 1.2341)
5be73ebf6a15 patch 8.0.0614: float2nr() is not exactly right
Christian Brabandt <cb@256bit.org>
parents: 10557
diff changeset
319 " add-subtract
5be73ebf6a15 patch 8.0.0614: float2nr() is not exactly right
Christian Brabandt <cb@256bit.org>
parents: 10557
diff changeset
320 call assert_equal('5.234', printf('%g', 4 + 1.234))
5be73ebf6a15 patch 8.0.0614: float2nr() is not exactly right
Christian Brabandt <cb@256bit.org>
parents: 10557
diff changeset
321 call assert_equal('-6.766', printf('%g', 1.234 - 8))
5be73ebf6a15 patch 8.0.0614: float2nr() is not exactly right
Christian Brabandt <cb@256bit.org>
parents: 10557
diff changeset
322 " mult-div
5be73ebf6a15 patch 8.0.0614: float2nr() is not exactly right
Christian Brabandt <cb@256bit.org>
parents: 10557
diff changeset
323 call assert_equal('4.936', printf('%g', 4 * 1.234))
5be73ebf6a15 patch 8.0.0614: float2nr() is not exactly right
Christian Brabandt <cb@256bit.org>
parents: 10557
diff changeset
324 call assert_equal('0.003241', printf('%g', 4.0 / 1234))
5be73ebf6a15 patch 8.0.0614: float2nr() is not exactly right
Christian Brabandt <cb@256bit.org>
parents: 10557
diff changeset
325 " dict
5be73ebf6a15 patch 8.0.0614: float2nr() is not exactly right
Christian Brabandt <cb@256bit.org>
parents: 10557
diff changeset
326 call assert_equal("{'x': 1.234, 'y': -2.0e20}", string({'x': 1.234, 'y': -2.0e20}))
5be73ebf6a15 patch 8.0.0614: float2nr() is not exactly right
Christian Brabandt <cb@256bit.org>
parents: 10557
diff changeset
327 " list
5be73ebf6a15 patch 8.0.0614: float2nr() is not exactly right
Christian Brabandt <cb@256bit.org>
parents: 10557
diff changeset
328 call assert_equal('[-123.4, 2.0e-20]', string([-123.4, 2.0e-20]))
5be73ebf6a15 patch 8.0.0614: float2nr() is not exactly right
Christian Brabandt <cb@256bit.org>
parents: 10557
diff changeset
329 endfunc
5be73ebf6a15 patch 8.0.0614: float2nr() is not exactly right
Christian Brabandt <cb@256bit.org>
parents: 10557
diff changeset
330
5be73ebf6a15 patch 8.0.0614: float2nr() is not exactly right
Christian Brabandt <cb@256bit.org>
parents: 10557
diff changeset
331 " vim: shiftwidth=2 sts=2 expandtab