3214
|
1 Test for floating point and logical operators.
|
1624
|
2
|
|
3 STARTTEST
|
|
4 :so small.vim
|
|
5 :if !has("float")
|
|
6 : e! test.ok
|
|
7 : wq! test.out
|
|
8 :endif
|
|
9 :"
|
|
10 :$put =printf('%f', 123.456)
|
|
11 :$put =printf('%e', 123.456)
|
|
12 :$put =printf('%g', 123.456)
|
|
13 :" check we don't crash on division by zero
|
|
14 :echo 1.0 / 0.0
|
|
15 :$put ='+='
|
|
16 :let v = 1.234
|
|
17 :let v += 6.543
|
|
18 :$put =printf('%g', v)
|
|
19 :let v = 1.234
|
|
20 :let v += 5
|
|
21 :$put =printf('%g', v)
|
|
22 :let a = 5
|
|
23 :let a += 3.333
|
|
24 :$put =string(a)
|
|
25 :$put ='=='
|
|
26 :let v = 1.234
|
|
27 :$put =v == 1.234
|
|
28 :$put =v == 1.2341
|
|
29 :$put ='add-subtract'
|
|
30 :$put =printf('%g', 4 + 1.234)
|
|
31 :$put =printf('%g', 1.234 - 8)
|
|
32 :$put ='mult-div'
|
|
33 :$put =printf('%g', 4 * 1.234)
|
|
34 :$put =printf('%g', 4.0 / 1234)
|
|
35 :$put ='dict'
|
|
36 :$put =string({'x': 1.234, 'y': -2.0e20})
|
|
37 :$put ='list'
|
|
38 :$put =string([-123.4, 2.0e-20])
|
|
39 :$put ='abs'
|
|
40 :$put =printf('%d', abs(1456))
|
|
41 :$put =printf('%d', abs(-4))
|
|
42 :$put =printf('%d', abs([1, 2, 3]))
|
|
43 :$put =printf('%g', abs(14.56))
|
|
44 :$put =printf('%g', abs(-54.32))
|
|
45 :$put ='ceil'
|
|
46 :$put =printf('%g', ceil(1.456))
|
|
47 :$put =printf('%g', ceil(-5.456))
|
|
48 :$put =printf('%g', ceil(-4.000))
|
|
49 :$put ='floor'
|
|
50 :$put =printf('%g', floor(1.856))
|
|
51 :$put =printf('%g', floor(-5.456))
|
|
52 :$put =printf('%g', floor(4.0))
|
|
53 :$put ='log10'
|
|
54 :$put =printf('%g', log10(1000))
|
|
55 :$put =printf('%g', log10(0.01000))
|
|
56 :$put ='pow'
|
|
57 :$put =printf('%g', pow(3, 3.0))
|
|
58 :$put =printf('%g', pow(2, 16))
|
|
59 :$put ='round'
|
|
60 :$put =printf('%g', round(0.456))
|
|
61 :$put =printf('%g', round(4.5))
|
|
62 :$put =printf('%g', round(-4.50))
|
|
63 :$put ='sqrt'
|
|
64 :$put =printf('%g', sqrt(100))
|
|
65 :echo sqrt(-4.01)
|
|
66 :$put ='str2float'
|
|
67 :$put =printf('%g', str2float('1e40'))
|
|
68 :$put ='trunc'
|
|
69 :$put =printf('%g', trunc(1.456))
|
|
70 :$put =printf('%g', trunc(-5.456))
|
|
71 :$put =printf('%g', trunc(4.000))
|
|
72 :$put ='float2nr'
|
|
73 :$put =float2nr(123.456)
|
|
74 :$put =float2nr(-123.456)
|
3214
|
75 :$put ='AND'
|
|
76 :$put =and(127, 127)
|
|
77 :$put =and(127, 16)
|
|
78 :$put =and(127, 128)
|
|
79 :$put ='OR'
|
|
80 :$put =or(16, 7)
|
|
81 :$put =or(8, 7)
|
|
82 :$put =or(0, 123)
|
|
83 :$put ='XOR'
|
|
84 :$put =xor(127, 127)
|
|
85 :$put =xor(127, 16)
|
|
86 :$put =xor(127, 128)
|
|
87 :$put ='invert'
|
|
88 :$put =and(invert(127), 65535)
|
|
89 :$put =and(invert(16), 65535)
|
|
90 :$put =and(invert(128), 65535)
|
|
91 :$put =invert(1.0)
|
1624
|
92 :/^Results/,$wq! test.out
|
|
93 ENDTEST
|
|
94
|
|
95 Results of test65:
|