1' Copyright 2011 Jacek Caban for CodeWeavers
2'
3' This library is free software; you can redistribute it and/or
4' modify it under the terms of the GNU Lesser General Public
5' License as published by the Free Software Foundation; either
6' version 2.1 of the License, or (at your option) any later version.
7'
8' This library is distributed in the hope that it will be useful,
9' but WITHOUT ANY WARRANTY; without even the implied warranty of
10' MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
11' Lesser General Public License for more details.
12'
13' You should have received a copy of the GNU Lesser General Public
14' License along with this library; if not, write to the Free Software
15' Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
16'
17
18Option Explicit
19
20Dim x
21
22Class EmptyClass
23End Class
24
25Call ok(vbSunday = 1, "vbSunday = " & vbSunday)
26Call ok(getVT(vbSunday) = "VT_I2", "getVT(vbSunday) = " & getVT(vbSunday))
27Call ok(vbMonday = 2, "vbMonday = " & vbMonday)
28Call ok(getVT(vbMonday) = "VT_I2", "getVT(vbMonday) = " & getVT(vbMonday))
29Call ok(vbTuesday = 3, "vbTuesday = " & vbTuesday)
30Call ok(getVT(vbTuesday) = "VT_I2", "getVT(vbTuesday) = " & getVT(vbTuesday))
31Call ok(vbWednesday = 4, "vbWednesday = " & vbWednesday)
32Call ok(getVT(vbWednesday) = "VT_I2", "getVT(vbWednesday) = " & getVT(vbWednesday))
33Call ok(vbThursday = 5, "vbThursday = " & vbThursday)
34Call ok(getVT(vbThursday) = "VT_I2", "getVT(vbThursday) = " & getVT(vbThursday))
35Call ok(vbFriday = 6, "vbFriday = " & vbFriday)
36Call ok(getVT(vbFriday) = "VT_I2", "getVT(vbFriday) = " & getVT(vbFriday))
37Call ok(vbSaturday = 7, "vbSaturday = " & vbSaturday)
38Call ok(getVT(vbSaturday) = "VT_I2", "getVT(vbSaturday) = " & getVT(vbSaturday))
39
40Sub TestConstant(name, val, exval)
41    Call ok(val = exval, name & " =  " & val & " expected " & exval)
42    Call ok(getVT(val) = "VT_I2*", "getVT(" & name & ") = " & getVT(val))
43End Sub
44
45Sub TestConstantI4(name, val, exval)
46    Call ok(val = exval, name & " =  " & val & " expected " & exval)
47    Call ok(getVT(val) = "VT_I4*", "getVT(" & name & ") = " & getVT(val))
48End Sub
49
50Sub TestConstantBSTR(name, val, exval)
51    Call ok(val = exval, name & " =  " & val & " expected " & exval)
52    Call ok(getVT(val) = "VT_BSTR*", "getVT(" & name & ") = " & getVT(val))
53End Sub
54
55TestConstant "vbEmpty", vbEmpty, 0
56TestConstant "vbNull", vbNull, 1
57TestConstant "vbLong", vbLong, 3
58TestConstant "vbSingle", vbSingle, 4
59TestConstant "vbDouble", vbDouble, 5
60TestConstant "vbCurrency", vbCurrency, 6
61TestConstant "vbDate", vbDate, 7
62TestConstant "vbString", vbString, 8
63TestConstant "vbObject", vbObject, 9
64TestConstant "vbError", vbError, 10
65TestConstant "vbBoolean", vbBoolean, 11
66TestConstant "vbVariant", vbVariant, 12
67TestConstant "vbDataObject", vbDataObject, 13
68TestConstant "vbDecimal", vbDecimal, 14
69TestConstant "vbByte", vbByte, 17
70TestConstant "vbArray", vbArray, 8192
71TestConstant "vbCritical", vbCritical, 16
72TestConstant "vbQuestion", vbQuestion, 32
73TestConstant "vbExclamation", vbExclamation, 48
74TestConstant "vbInformation", vbInformation, 64
75TestConstant "vbDefaultButton1", vbDefaultButton1, 0
76TestConstant "vbDefaultButton2", vbDefaultButton2, 256
77TestConstant "vbDefaultButton3", vbDefaultButton3, 512
78TestConstant "vbDefaultButton4", vbDefaultButton4, 768
79TestConstant "vbApplicationModal", vbApplicationModal, 0
80TestConstant "vbSystemModal", vbSystemModal, 4096
81TestConstant "vbUseSystem", vbUseSystem, 0
82TestConstant "vbUseSystemDayOfWeek", vbUseSystemDayOfWeek, 0
83TestConstant "vbFirstJan1", vbFirstJan1, 1
84TestConstant "vbFirstFourDays", vbFirstFourDays, 2
85TestConstant "vbFirstFullWeek", vbFirstFullWeek, 3
86TestConstant "vbTrue", vbTrue, -1
87TestConstant "vbFalse", vbFalse, 0
88TestConstantI4 "vbMsgBoxHelpButton", vbMsgBoxHelpButton, 16384
89TestConstantI4 "vbMsgBoxSetForeground", vbMsgBoxSetForeground, 65536
90TestConstantI4 "vbMsgBoxRight", vbMsgBoxRight, 524288
91TestConstantI4 "vbMsgBoxRtlReading", vbMsgBoxRtlReading, 1048576
92TestConstant "vbUseDefault", vbUseDefault, -2
93TestConstant "vbBinaryCompare", vbBinaryCompare, 0
94TestConstant "vbTextCompare", vbTextCompare, 1
95TestConstant "vbDatabaseCompare", vbDatabaseCompare, 2
96TestConstant "vbGeneralDate", vbGeneralDate, 0
97TestConstant "vbLongDate", vbLongDate, 1
98TestConstant "vbShortDate", vbShortDate, 2
99TestConstant "vbLongTime", vbLongTime, 3
100TestConstant "vbShortTime", vbShortTime, 4
101TestConstantI4 "vbObjectError", vbObjectError, &h80040000&
102TestConstantI4 "vbBlack", vbBlack, 0
103TestConstantI4 "vbBlue", vbBlue, &hff0000&
104TestConstantI4 "vbCyan", vbCyan, &hffff00&
105TestConstantI4 "vbGreen", vbGreen, &h00ff00&
106TestConstantI4 "vbMagenta", vbMagenta, &hff00ff&
107TestConstantI4 "vbRed", vbRed, &h0000ff&
108TestConstantI4 "vbWhite", vbWhite, &hffffff&
109TestConstantI4 "vbYellow", vbYellow, &h00ffff&
110TestConstantBSTR "vbCr", vbCr, Chr(13)
111TestConstantBSTR "vbCrLf", vbCrLf, Chr(13)&Chr(10)
112TestConstantBSTR "vbNewLine", vbNewLine, Chr(13)&Chr(10)
113TestConstantBSTR "vbFormFeed", vbFormFeed, Chr(12)
114TestConstantBSTR "vbLf", vbLf, Chr(10)
115TestConstantBSTR "vbNullChar", vbNullChar, Chr(0)
116TestConstantBSTR "vbNullString", vbNullString, ""
117TestConstantBSTR "vbTab", vbTab, chr(9)
118TestConstantBSTR "vbVerticalTab", vbVerticalTab, chr(11)
119
120Sub TestCStr(arg, exval)
121    dim x
122    x = CStr(arg)
123    Call ok(getVT(x) = "VT_BSTR*", "getVT(x) = " & getVT(x))
124    Call ok(x = exval, "CStr(" & arg & ") = " & x)
125End Sub
126
127TestCStr "test", "test"
128TestCStr 3, "3"
129if isEnglishLang then TestCStr 3.5, "3.5"
130if isEnglishLang then TestCStr true, "True"
131
132Call ok(getVT(Chr(120)) = "VT_BSTR", "getVT(Chr(120)) = " & getVT(Chr(120)))
133Call ok(getVT(Chr(255)) = "VT_BSTR", "getVT(Chr(255)) = " & getVT(Chr(255)))
134Call ok(Chr(120) = "x", "Chr(120) = " & Chr(120))
135Call ok(Chr(0) <> "", "Chr(0) = """"")
136Call ok(Chr(120.5) = "x", "Chr(120.5) = " & Chr(120.5))
137Call ok(Chr(119.5) = "x", "Chr(119.5) = " & Chr(119.5))
138Call ok(Chr("120") = "x", "Chr(""120"") = " & Chr("120"))
139
140sub testChrError
141    on error resume next
142
143    if isEnglishLang then
144        call Err.clear()
145        call Chr(-1)
146        call ok(Err.number = 5, "Err.number = " & Err.number)
147
148        call Err.clear()
149        call Chr(256)
150        call ok(Err.number = 5, "Err.number = " & Err.number)
151    end if
152
153    call Err.clear()
154    call Chr(65536)
155    call ok(Err.number = 5, "Err.number = " & Err.number)
156
157    call Err.clear()
158    call Chr(-32769)
159    call ok(Err.number = 5, "Err.number = " & Err.number)
160end sub
161
162call testChrError
163
164Call ok(isObject(new EmptyClass), "isObject(new EmptyClass) is not true?")
165Set x = new EmptyClass
166Call ok(isObject(x), "isObject(x) is not true?")
167Call ok(isObject(Nothing), "isObject(Nothing) is not true?")
168Call ok(not isObject(true), "isObject(true) is true?")
169Call ok(not isObject(4), "isObject(4) is true?")
170Call ok(not isObject("x"), "isObject(""x"") is true?")
171Call ok(not isObject(Null), "isObject(Null) is true?")
172
173Call ok(not isEmpty(new EmptyClass), "isEmpty(new EmptyClass) is true?")
174Set x = new EmptyClass
175Call ok(not isEmpty(x), "isEmpty(x) is true?")
176x = empty
177Call ok(isEmpty(x), "isEmpty(x) is not true?")
178Call ok(isEmpty(empty), "isEmpty(empty) is not true?")
179Call ok(not isEmpty(Nothing), "isEmpty(Nothing) is not true?")
180Call ok(not isEmpty(true), "isEmpty(true) is true?")
181Call ok(not isEmpty(4), "isEmpty(4) is true?")
182Call ok(not isEmpty("x"), "isEmpty(""x"") is true?")
183Call ok(not isEmpty(Null), "isEmpty(Null) is true?")
184
185Call ok(not isNull(new EmptyClass), "isNull(new EmptyClass) is true?")
186Set x = new EmptyClass
187Call ok(not isNull(x), "isNull(x) is true?")
188x = null
189Call ok(isNull(x), "isNull(x) is not true?")
190Call ok(not isNull(empty), "isNull(empty) is true?")
191Call ok(not isNull(Nothing), "isNull(Nothing) is true?")
192Call ok(not isNull(true), "isNull(true) is true?")
193Call ok(not isNull(4), "isNull(4) is true?")
194Call ok(not isNull("x"), "isNull(""x"") is true?")
195Call ok(isNull(Null), "isNull(Null) is not true?")
196
197Call ok(isNumeric(Empty), "isNumeric(empty) is not true?")
198Call ok(not isNumeric(Null), "isNumeric(Null) is not true?")
199Call ok(isNumeric(32767), "isNumeric(32767) is true?")
200Call ok(isNumeric(32768), "isNumeric(32768) is true?")
201Call ok(isNumeric(CSng(3242.4)), "isNumeric(CSng(3242.4)) is true?")
202Call ok(isNumeric(32768.4), "isNumeric(32768.4) is true?")
203Call ok(isNumeric(CCur(32768.4)), "isNumeric(CCur(32768.4)) is true?")
204Call ok(isNumeric("44"), "isNumeric(""44"") is true?")
205Call ok(not isNumeric("rwrf"), "isNumeric(""rwrf"") is not true?")
206Call ok(not isNumeric(Nothing), "isNumeric(Nothing) is not true?")
207Call ok(not isNumeric(New EmptyClass), "isNumeric(New EmptyClass) is not true?")
208Call ok(isNumeric(true), "isNumeric(true) is true?")
209Call ok(isNumeric(CByte(32)), "isNumeric(CByte(32)) is true?")
210Dim arr(2)
211arr(0) = 2
212arr(1) = 3
213Call ok(not isNumeric(arr), "isNumeric(arr) is not true?")
214
215Call ok(getVT(Array()) = "VT_ARRAY|VT_VARIANT", "getVT(Array()) = " & getVT(Array()))
216x = Array("a1", 2, "a3")
217Call ok(getVT(x) = "VT_ARRAY|VT_VARIANT*", "getVT(array) = " & getVT(x))
218Call ok(getVT(x(0)) = "VT_BSTR*", "getVT(array(0)) = " & getVT(x(0)))
219Call ok(x(0) = "a1", "array(0) = " & x(0))
220Call ok(getVT(x(1)) = "VT_I2*", "getVT(array(1)) = " & getVT(x(1)))
221Call ok(x(1) = 2, "array(1) = " & x(1))
222Call ok(getVT(x(2)) = "VT_BSTR*", "getVT(array(2)) = " & getVT(x(2)))
223Call ok(x(2) = "a3", "array(2) = " & x(2))
224
225Dim new_array
226new_array = x
227x(0) = "new value"
228Call ok(new_array(0) = "a1", "new_array(0) = " & new_array(0))
229
230Call ok(getVT(UBound(x)) = "VT_I4", "getVT(UBound(x)) = " & getVT(UBound(x)))
231Call ok(UBound(x) = 2, "UBound(x) = " & UBound(x))
232Call ok(getVT(UBound(x, 1)) = "VT_I4", "getVT(UBound(x, 1)) = " & getVT(UBound(x, 1)))
233Call ok(UBound(x, 1) = 2, "UBound(x) = " & UBound(x, 1))
234
235Dim arr2(2, 4)
236Call ok(UBound(arr2) = 2, "UBound(x) = " & UBound(x))
237Call ok(UBound(arr2, 1) = 2, "UBound(x) = " & UBound(x))
238Call ok(UBound(arr2, 2) = 4, "UBound(x) = " & UBound(x))
239
240Dim newObject
241Set newObject = New ValClass
242newObject.myval = 1
243Call ok(isNumeric(newObject), "isNumeric(newObject) is true?")
244newObject.myval = "test"
245Call ok(not isNumeric(newObject), "isNumeric(newObject) is not true?")
246
247Call ok(getVT(err) = "VT_DISPATCH", "getVT(err) = " & getVT(err))
248
249Sub TestHex(x, ex)
250    Call ok(hex(x) = ex, "hex(" & x & ") = " & hex(x) & " expected " & ex)
251End Sub
252
253TestHex 0, "0"
254TestHex 6, "6"
255TestHex 16, "10"
256TestHex &hdeadbeef&, "DEADBEEF"
257TestHex -1, "FFFF"
258TestHex -16, "FFF0"
259TestHex -934859845, "C8472BBB"
260TestHex empty, "0"
261TestHex "17", "11"
262TestHex 228.5, "E4"
263TestHex -32767, "8001"
264TestHex -32768, "FFFF8000"
265TestHex 2147483647.49, "7FFFFFFF"
266TestHex -2147483647.5, "80000000"
267newObject.myval = 30.5
268TestHex newObject, "1E"
269newObject.myval = "27"
270TestHex newObject, "1B"
271
272
273Call ok(getVT(hex(null)) = "VT_NULL", "getVT(hex(null)) = " & getVT(hex(null)))
274Call ok(getVT(hex(empty)) = "VT_BSTR", "getVT(hex(empty)) = " & getVT(hex(empty)))
275
276Sub TestHexError(num, err_num)
277    On Error Resume Next
278    Call Hex(num)
279    Call ok(Err.number = err_num, "Hex(" & num & ") returns error number " & Err.number & " expected " & err_num)
280End Sub
281
282TestHexError 2147483647.5, 6
283TestHexError 2147483648.51, 6
284TestHexError "test", 13
285
286Sub TestOct(x, ex, res_type)
287    Call ok(Oct(x) = ex, "Oct(" & x & ") = " & Oct(x) & " expected " & ex)
288    Call ok(getVT(Oct(x)) = res_type, "getVT(Oct(" &x & ")) = " & getVT(Oct(x)) & "expected " & res_type)
289End Sub
290
291Sub TestOctError(num, err_num)
292    On error resume next
293    Call Oct(num)
294    Call ok(Err.number = err_num, "Oct(" & num & ") error number is " & Err.number & " expected " & err_num)
295End Sub
296
297TestOct empty, "0", "VT_BSTR"
298TestOct 0, "0", "VT_BSTR"
299TestOct 9, "11", "VT_BSTR"
300TestOct "9", "11", "VT_BSTR"
301TestOct 8.5, "10", "VT_BSTR"
302TestOct 9.5, "12", "VT_BSTR"
303TestOct -1, "177777", "VT_BSTR"
304TestOct -32767, "100001", "VT_BSTR"
305TestOct -32768, "37777700000", "VT_BSTR"
306TestOct 2147483647.49, "17777777777", "VT_BSTR"
307TestOct -2147483648.5, "20000000000", "VT_BSTR"
308Call ok(getVT(Oct(null)) = "VT_NULL", "getVT(Oct(null)) = " & getVT(Oct(null)))
309newObject.myval = 5
310TestOct newObject, "5", "VT_BSTR"
311
312TestOctError 2147483647.5, 6
313TestOctError -2147483648.51, 6
314TestOctError "test", 13
315
316x = InStr(1, "abcd", "bc")
317Call ok(x = 2, "InStr returned " & x)
318
319x = InStr("abcd", "bc")
320Call ok(x = 2, "InStr returned " & x)
321Call ok(getVT(x) = "VT_I4*", "getVT(InStr) returned " & getVT(x))
322
323x = InStr("abc", "bc")
324Call ok(x = 2, "InStr returned " & x)
325
326x = InStr("abcbc", "bc")
327Call ok(x = 2, "InStr returned " & x)
328
329x = InStr("bcabc", "bc")
330Call ok(x = 1, "InStr returned " & x)
331
332x = InStr(3, "abcd", "bc")
333Call ok(x = 0, "InStr returned " & x)
334
335x = InStr("abcd", "bcx")
336Call ok(x = 0, "InStr returned " & x)
337
338x = InStr(5, "abcd", "bc")
339Call ok(x = 0, "InStr returned " & x)
340
341x = "abcd"
342x = InStr(x, "bc")
343Call ok(x = 2, "InStr returned " & x)
344
345x = InStr("abcd", null)
346Call ok(isNull(x), "InStr returned " & x)
347x = InStr(null, "abcd")
348Call ok(isNull(x), "InStr returned " & x)
349x = InStr(2, null, "abcd")
350Call ok(isNull(x), "InStr returned " & x)
351
352x = InStr(1.3, "abcd", "bc")
353Call ok(x = 2, "InStr returned " & x)
354
355x = InStr(2.3, "abcd", "bc")
356Call ok(x = 2, "InStr returned " & x)
357
358x = InStr(2.6, "abcd", "bc")
359Call ok(x = 0, "InStr returned " & x)
360
361
362x = InStrRev("bcabcd", "bc")
363Call ok(x = 4, "InStrRev returned " & x)
364Call ok(getVT(x) = "VT_I4*", "getVT(InStrRev) returned " & getVT(x))
365
366x = InStrRev("bcabcd", "bc", 6)
367Call ok(x = 4, "InStrRev returned " & x)
368
369x = InStrRev("abcd", "bcx")
370Call ok(x = 0, "InStrRev returned " & x)
371
372x = InStrRev("abcd", "bc", 3)
373Call ok(x = 2, "InStrRev returned " & x)
374
375x = InStrRev("abcd", "bc", 2)
376Call ok(x = 0, "InStrRev returned " & x)
377
378x = InStrRev("abcd", "b", 2)
379Call ok(x = 2, "InStrRev returned " & x)
380
381x = InStrRev("abcd", "bc", 5)
382Call ok(x = 0, "InStrRev returned " & x)
383
384x = InStrRev("abcd", "bc", 15)
385Call ok(x = 0, "InStrRev returned " & x)
386
387x = "abcd"
388x = InStrRev(x, "bc")
389Call ok(x = 2, "InStrRev returned " & x)
390
391x = InStrRev("abcd", "bc", 1.3)
392Call ok(x = 0, "InStrRev returned " & x)
393
394x = InStrRev("abcd", "bc", 2.3)
395Call ok(x = 0, "InStrRev returned " & x)
396
397x = InStrRev("abcd", "bc", 2.6)
398Call ok(x = 2, "InStrRev returned " & x)
399
400x = InStrRev("1234", 34)
401Call ok(x = 3, "InStrRev returned " & x)
402
403x = InStrRev(1234, 34)
404Call ok(x = 3, "InStrRev returned " & x)
405
406Sub testInStrRevError(arg1, arg2, arg3, error_num)
407    on error resume next
408    Dim x
409
410    Call Err.clear()
411    x = InStrRev(arg1, arg2, arg3)
412    Call ok(Err.number = error_num, "Err.number = " & Err.number)
413End Sub
414
415call testInStrRevError("abcd", null, 2, 94)
416call testInStrRevError(null, "abcd", 2, 94)
417call testInStrRevError("abcd", "abcd", null, 94)
418
419Sub TestMid(str, start, len, ex)
420    x = Mid(str, start, len)
421    Call ok(x = ex, "Mid(" & str & ", " & start & ", " & len & ") = " & x & " expected " & ex)
422End Sub
423
424Sub TestMid2(str, start, ex)
425    x = Mid(str, start)
426    Call ok(x = ex, "Mid(" & str & ", " & start & ") = " & x & " expected " & ex)
427End Sub
428
429TestMid "test", 2, 2, "es"
430TestMid "test", 2, 4, "est"
431TestMid "test", 1, 2, "te"
432TestMid "test", 1, 0, ""
433TestMid "test", 1, 0, ""
434TestMid "test", 5, 2, ""
435TestMid2 "test", 1, "test"
436TestMid2 "test", 2, "est"
437TestMid2 "test", 4, "t"
438TestMid2 "test", 5, ""
439
440Sub TestUCase(str, ex)
441    x = UCase(str)
442    Call ok(x = ex, "UCase(" & str & ") = " & x & " expected " & ex)
443End Sub
444
445TestUCase "test", "TEST"
446TestUCase "123aBC?", "123ABC?"
447TestUCase "", ""
448TestUCase 1, "1"
449if isEnglishLang then TestUCase true, "TRUE"
450TestUCase 0.123, doubleAsString(0.123)
451TestUCase Empty, ""
452Call ok(getVT(UCase(Null)) = "VT_NULL", "getVT(UCase(Null)) = " & getVT(UCase(Null)))
453
454Sub TestLCase(str, ex)
455    x = LCase(str)
456    Call ok(x = ex, "LCase(" & str & ") = " & x & " expected " & ex)
457End Sub
458
459TestLCase "test", "test"
460TestLCase "123aBC?", "123abc?"
461TestLCase "", ""
462TestLCase 1, "1"
463if isEnglishLang then TestLCase true, "true"
464TestLCase 0.123, doubleAsString(0.123)
465TestLCase Empty, ""
466Call ok(getVT(LCase(Null)) = "VT_NULL", "getVT(LCase(Null)) = " & getVT(LCase(Null)))
467
468Sub TestStrComp(str_left, str_right, mode, ex)
469    x = StrComp(str_left, str_right, mode)
470    Call ok(x = ex, "StrComp(" & str_left & ", " & str_right & ", " & mode & ") = " & x & " expected " & ex)
471End Sub
472
473TestStrComp "ABC",  "abc",  0, -1
474TestStrComp "abc",  "ABC",  0,  1
475TestStrComp "ABC",  "ABC",  0,  0
476TestStrComp "ABC",  "abc",  0, -1
477TestStrComp "abc",  "ABC",  0,  1
478TestStrComp "ABC",  "ABC",  0,  0
479TestStrComp "ABCD", "ABC",  0,  1
480TestStrComp "ABC",  "ABCD", 0, -1
481TestStrComp "ABC",  "abc",  1,  0
482TestStrComp "ABC",  "ABC",  1,  0
483TestStrComp "ABCD", "ABC",  1,  1
484TestStrComp "ABC",  "ABCD", 1, -1
485TestStrComp "ABC",  "ABCD", "0", -1
486TestStrComp "ABC",  "ABCD", "1", -1
487TestStrComp 1,      1,      1,  0
488TestStrComp "1",    1,      1,  0
489TestStrComp "1",    1.0,    1,  0
490TestStrComp Empty,  Empty,  1,  0
491TestStrComp Empty,  "",     1,  0
492TestStrComp Empty,  "ABC",  1,  -1
493TestStrComp "ABC",  Empty,  1,  1
494TestStrComp vbNull, vbNull, 1,  0
495TestStrComp "",     vbNull, 1,  -1
496
497Call ok(Len("abc") = 3, "Len(abc) = " & Len("abc"))
498Call ok(Len("") = 0, "Len() = " & Len(""))
499Call ok(Len(1) = 1, "Len(1) = " & Len(1))
500Call ok(isNull(Len(null)), "Len(null) = " & Len(null))
501Call ok(Len(empty) = 0, "Len(empty) = " & Len(empty))
502Call ok(getVT(Len("abc")) = "VT_I4", "getVT(Len(abc)) = " & getVT(Len("abc")))
503
504Call ok(Space(1) = " ", "Space(1) = " & Space(1) & """")
505Call ok(Space(0) = "", "Space(0) = " & Space(0) & """")
506Call ok(Space(false) = "", "Space(false) = " & Space(false) & """")
507Call ok(Space(5) = "     ", "Space(5) = " & Space(5) & """")
508Call ok(Space(5.2) = "     ", "Space(5.2) = " & Space(5.2) & """")
509Call ok(Space(5.8) = "      ", "Space(5.8) = " & Space(5.8) & """")
510Call ok(Space(5.5) = "      ", "Space(5.5) = " & Space(5.5) & """")
511Call ok(Space(4.5) = "    ", "Space(4.5) = " & Space(4.5) & """")
512Call ok(Space(0.5) = "", "Space(0.5) = " & Space(0.5) & """")
513Call ok(Space(1.5) = "  ", "Space(1.5) = " & Space(1.5) & """")
514Call ok(Space("1") = " ", "Space(""1"") = " & Space("1") & """")
515
516Sub TestStrReverse(str, ex)
517    Call ok(StrReverse(str) = ex, "StrReverse(" & str & ") = " & StrReverse(str))
518End Sub
519
520TestStrReverse "test", "tset"
521TestStrReverse "", ""
522TestStrReverse 123, "321"
523if isEnglishLang then TestStrReverse true, "eurT"
524
525Sub TestLeft(str, len, ex)
526    Call ok(Left(str, len) = ex, "Left(" & str & ", " & len & ") = " & Left(str, len))
527End Sub
528
529TestLeft "test", 2, "te"
530TestLeft "test", 5, "test"
531TestLeft "test", 0, ""
532TestLeft 123, 2, "12"
533TestLeft "123456", 1.5, "12"
534TestLeft "123456", 2.5, "12"
535TestLeft "test", "2", "te"
536if isEnglishLang then TestLeft true, 2, "Tr"
537
538Sub TestRight(str, len, ex)
539    Call ok(Right(str, len) = ex, "Right(" & str & ", " & len & ") = " & Right(str, len))
540End Sub
541
542TestRight "test", 2, "st"
543TestRight "test", 5, "test"
544TestRight "test", 0, ""
545TestRight 123, 2, "23"
546if isEnglishLang then TestRight true, 2, "ue"
547
548Sub TestTrim(str, exstr)
549    Call ok(Trim(str) = exstr, "Trim(" & str & ") = " & Trim(str))
550End Sub
551
552TestTrim "   test    ", "test"
553TestTrim "test    ", "test"
554TestTrim "   test", "test"
555TestTrim "test", "test"
556TestTrim "", ""
557TestTrim 123, "123"
558if isEnglishLang then TestTrim true, "True"
559
560Sub TestLTrim(str, exstr)
561    Call ok(LTrim(str) = exstr, "LTrim(" & str & ") = " & LTrim(str))
562End Sub
563
564TestLTrim "   test    ", "test    "
565TestLTrim "test    ", "test    "
566TestLTrim "   test", "test"
567TestLTrim "test", "test"
568TestLTrim "", ""
569TestLTrim 123, "123"
570if isEnglishLang then TestLTrim true, "True"
571
572Sub TestRound(val, exval, vt)
573    Call ok(Round(val) = exval, "Round(" & val & ") = " & Round(val))
574    Call ok(getVT(Round(val)) = vt, "getVT(Round(" & val & ")) = " & getVT(Round(val)))
575End Sub
576
577Sub TestRTrim(str, exstr)
578    Call ok(RTrim(str) = exstr, "RTrim(" & str & ") = " & RTrim(str))
579End Sub
580
581TestRTrim "   test    ", "   test"
582TestRTrim "test    ", "test"
583TestRTrim "   test", "   test"
584TestRTrim "test", "test"
585TestRTrim "", ""
586TestRTrim 123, "123"
587if isEnglishLang then TestRTrim true, "True"
588
589TestRound 3, 3, "VT_I2"
590TestRound 3.3, 3, "VT_R8"
591TestRound 3.8, 4, "VT_R8"
592TestRound 3.5, 4, "VT_R8"
593TestRound -3.3, -3, "VT_R8"
594TestRound -3.5, -4, "VT_R8"
595TestRound "2", 2, "VT_R8"
596TestRound true, true, "VT_BOOL"
597TestRound false, false, "VT_BOOL"
598
599if isEnglishLang then
600    Call ok(WeekDayName(1) = "Sunday", "WeekDayName(1) = " & WeekDayName(1))
601    Call ok(WeekDayName(3) = "Tuesday", "WeekDayName(3) = " & WeekDayName(3))
602    Call ok(WeekDayName(7) = "Saturday", "WeekDayName(7) = " & WeekDayName(7))
603    Call ok(WeekDayName(1.1) = "Sunday", "WeekDayName(1.1) = " & WeekDayName(1.1))
604    Call ok(WeekDayName(1, false) = "Sunday", "WeekDayName(1, false) = " & WeekDayName(1, false))
605    Call ok(WeekDayName(1, true) = "Sun", "WeekDayName(1, true) = " & WeekDayName(1, true))
606    Call ok(WeekDayName(1, 10) = "Sun", "WeekDayName(1, 10) = " & WeekDayName(1, 10))
607    Call ok(WeekDayName(1, true, 2) = "Mon", "WeekDayName(1, true, 2) = " & WeekDayName(1, true, 2))
608    Call ok(WeekDayName(1, true, 2.5) = "Mon", "WeekDayName(1, true, 2.5) = " & WeekDayName(1, true, 2.5))
609    Call ok(WeekDayName(1, true, 1.5) = "Mon", "WeekDayName(1, true, 1.5) = " & WeekDayName(1, true, 1.5))
610    Call ok(WeekDayName(1, true, 7) = "Sat", "WeekDayName(1, true, 7) = " & WeekDayName(1, true, 7))
611    Call ok(WeekDayName(1, true, 7.1) = "Sat", "WeekDayName(1, true, 7.1) = " & WeekDayName(1, true, 7.1))
612
613    Call ok(MonthName(1) = "January", "MonthName(1) = " & MonthName(1))
614    Call ok(MonthName(12) = "December", "MonthName(12) = " & MonthName(12))
615    Call ok(MonthName(1, 0) = "January", "MonthName(1, 0) = " & MonthName(1, 0))
616    Call ok(MonthName(12, false) = "December", "MonthName(12, false) = " & MonthName(12, false))
617    Call ok(MonthName(1, 10) = "Jan", "MonthName(1, 10) = " & MonthName(1, 10))
618    Call ok(MonthName(12, true) = "Dec", "MonthName(12, true) = " & MonthName(12, true))
619end if
620
621Call ok(WeekDayName(1, true, 0) = WeekDayName(1, true, firstDayOfWeek), _
622        "WeekDayName(1, true, 0) = " & WeekDayName(1, true, 0))
623
624Call ok(getVT(Now()) = "VT_DATE", "getVT(Now()) = " & getVT(Now()))
625
626Call ok(vbOKOnly = 0, "vbOKOnly = " & vbOKOnly)
627Call ok(getVT(vbOKOnly) = "VT_I2", "getVT(vbOKOnly) = " & getVT(vbOKOnly))
628Call ok(vbOKCancel = 1, "vbOKCancel = " & vbOKCancel)
629Call ok(getVT(vbOKCancel) = "VT_I2", "getVT(vbOKCancel) = " & getVT(vbOKCancel))
630Call ok(vbAbortRetryIgnore = 2, "vbAbortRetryIgnore = " & vbAbortRetryIgnore)
631Call ok(getVT(vbAbortRetryIgnore) = "VT_I2", "getVT(vbAbortRetryIgnore) = " & getVT(vbAbortRetryIgnore))
632Call ok(vbYesNoCancel = 3, "vbYesNoCancel = " & vbYesNoCancel)
633Call ok(getVT(vbYesNoCancel) = "VT_I2", "getVT(vbYesNoCancel) = " & getVT(vbYesNoCancel))
634Call ok(vbYesNo = 4, "vbYesNo = " & vbYesNo)
635Call ok(getVT(vbYesNo) = "VT_I2", "getVT(vbYesNo) = " & getVT(vbYesNo))
636Call ok(vbRetryCancel = 5, "vbRetryCancel = " & vbRetryCancel)
637Call ok(getVT(vbRetryCancel) = "VT_I2", "getVT(vbRetryCancel) = " & getVT(vbRetryCancel))
638
639Call ok(vbOK = 1, "vbOK = " & vbOK)
640Call ok(getVT(vbOK) = "VT_I2", "getVT(vbOK) = " & getVT(vbOK))
641Call ok(vbCancel = 2, "vbCancel = " & vbCancel)
642Call ok(getVT(vbCancel) = "VT_I2", "getVT(vbCancel) = " & getVT(vbCancel))
643Call ok(vbAbort = 3, "vbAbort = " & vbAbort)
644Call ok(getVT(vbAbort) = "VT_I2", "getVT(vbAbort) = " & getVT(vbAbort))
645Call ok(vbRetry = 4, "vbRetry = " & vbRetry)
646Call ok(getVT(vbRetry) = "VT_I2", "getVT(vbRetry) = " & getVT(vbRetry))
647Call ok(vbIgnore = 5, "vbIgnore = " & vbIgnore)
648Call ok(getVT(vbIgnore) = "VT_I2", "getVT(vbIgnore) = " & getVT(vbIgnore))
649Call ok(vbYes = 6, "vbYes = " & vbYes)
650Call ok(getVT(vbYes) = "VT_I2", "getVT(vbYes) = " & getVT(vbYes))
651Call ok(vbNo = 7, "vbNo = " & vbNo)
652Call ok(getVT(vbNo) = "VT_I2", "getVT(vbNo) = " & getVT(vbNo))
653
654Call ok(CInt(-36.75) = -37, "CInt(-36.75) = " & CInt(-36.75))
655Call ok(getVT(CInt(-36.75)) = "VT_I2", "getVT(CInt(-36.75)) = " & getVT(CInt(-36.75)))
656Call ok(CInt(-36.50) = -36, "CInt(-36.50) = " & CInt(-36.50))
657Call ok(getVT(CInt(-36.50)) = "VT_I2", "getVT(CInt(-36.50)) = " & getVT(CInt(-36.50)))
658Call ok(CInt(-36.25) = -36, "CInt(-36.25) = " & CInt(-36.25))
659Call ok(getVT(CInt(-36.25)) = "VT_I2", "getVT(CInt(-36.25)) = " & getVT(CInt(-36.25)))
660Call ok(CInt(-36) = -36, "CInt(-36) = " & CInt(-36))
661Call ok(getVT(CInt(-36)) = "VT_I2", "getVT(CInt(-36)) = " & getVT(CInt(-36)))
662Call ok(CInt(0) = 0, "CInt(0) = " & CInt(0))
663Call ok(getVT(CInt(0)) = "VT_I2", "getVT(CInt(0)) = " & getVT(CInt(0)))
664Call ok(CInt(0.0) = 0, "CInt(0.0) = " & CInt(0))
665Call ok(getVT(CInt(0.0)) = "VT_I2", "getVT(CInt(0.0)) = " & getVT(CInt(0.0)))
666Call ok(CInt(0.5) = 0, "CInt(0.5) = " & CInt(0))
667Call ok(getVT(CInt(0.5)) = "VT_I2", "getVT(CInt(0.5)) = " & getVT(CInt(0.5)))
668Call ok(CInt(36) = 36, "CInt(36) = " & CInt(36))
669Call ok(getVT(CInt(36)) = "VT_I2", "getVT(CInt(36)) = " & getVT(CInt(36)))
670Call ok(CInt(36.25) = 36, "CInt(36.25) = " & CInt(36.25))
671Call ok(getVT(CInt(36.25)) = "VT_I2", "getVT(CInt(36.25)) = " & getVT(CInt(36.25)))
672Call ok(CInt(36.50) = 36, "CInt(36.50) = " & CInt(36.50))
673Call ok(getVT(CInt(36.50)) = "VT_I2", "getVT(CInt(36.50)) = " & getVT(CInt(36.50)))
674Call ok(CInt(36.75) = 37, "CInt(36.75) = " & CInt(36.75))
675Call ok(getVT(CInt(36.75)) = "VT_I2", "getVT(CInt(36.75)) = " & getVT(CInt(36.75)))
676
677
678Call ok(CBool(5) = true, "CBool(5) = " & CBool(5))
679Call ok(getVT(CBool(5)) = "VT_BOOL", "getVT(CBool(5)) = " & getVT(CBool(5)))
680Call ok(CBool(0) = false, "CBool(0) = " & CBool(0))
681Call ok(getVT(CBool(0)) = "VT_BOOL", "getVT(CBool(0)) = " & getVT(CBool(0)))
682Call ok(CBool(-5) = true, "CBool(-5) = " & CBool(-5))
683Call ok(getVT(CBool(-5)) = "VT_BOOL", "getVT(CBool(-5)) = " & getVT(CBool(-5)))
684
685Sub testCBoolError(strings, error_num)
686    on error resume next
687
688    Call Err.clear()
689    Call CBool(strings)
690    Call ok(Err.number = error_num, "Err.number = " & Err.number)
691End Sub
692
693Class ValClass
694    Public myval
695
696    Public default Property Get defprop
697        defprop = myval
698    End Property
699End Class
700
701Dim MyObject
702Set MyObject = New ValClass
703
704Call ok(CBool(Empty) = False, "CBool(Empty) = " & CBool(Empty))
705Call ok(getVT(CBool(Empty)) = "VT_BOOL", "getVT(CBool(Empty)) = " & getVT(CBool(Empty)))
706Call ok(CBool(1) = True, "CBool(1) = " & CBool(1))
707Call ok(getVT(CBool(1)) = "VT_BOOL", "getVT(CBool(1)) = " & getVT(CBool(1)))
708Call ok(CBool(0) = False, "CBool(0) = " & CBool(0))
709Call ok(getVT(CBool(0)) = "VT_BOOL", "getVT(CBool(0)) = " & getVT(CBool(0)))
710Call ok(CBool(-0.56) = True, "CBool(-0.56) = " & CBool(-0.56))
711Call ok(getVT(CBool(-0.56)) = "VT_BOOL", "getVT(CBool(-0.56)) = " & getVT(CBool(-0.56)))
712Call testCBoolError("", 13)
713Call ok(CBool("0") = False, "CBool(""0"") = " & CBool("0"))
714Call ok(getVT(CBool("0")) = "VT_BOOL", "getVT(CBool(""0"")) = " & getVT(CBool("0")))
715If isEnglishLang Then
716    Call ok(CBool("0.1") = True, "CBool(""0.1"") = " & CBool("0.1"))
717    Call ok(getVT(CBool("0.1")) = "VT_BOOL", "getVT(CBool(""0.1"")) = " & getVT(CBool("0.1")))
718End If
719    Call ok(CBool("true") = True, "CBool(""true"") = " & CBool("true"))
720Call ok(getVT(CBool("true")) = "VT_BOOL", "getVT(CBool(""true"")) = " & getVT(CBool("true")))
721Call ok(CBool("false") = False, "CBool(""false"") = " & CBool("false"))
722Call ok(getVT(CBool("false")) = "VT_BOOL", "getVT(CBool(""false"")) = " & getVT(CBool("false")))
723Call ok(CBool("TRUE") = True, "CBool(""TRUE"") = " & CBool("TRUE"))
724Call ok(getVT(CBool("TRUE")) = "VT_BOOL", "getVT(CBool(""TRUE"")) = " & getVT(CBool("TRUE")))
725Call ok(CBool("FALSE") = False, "CBool(""FALSE"") = " & CBool("FALSE"))
726Call ok(getVT(CBool("FALSE")) = "VT_BOOL", "getVT(CBool(""FALSE"")) = " & getVT(CBool("FALSE")))
727Call ok(CBool("#TRUE#") = True, "CBool(""#TRUE#"") = " & CBool("#TRUE#"))
728Call ok(getVT(CBool("#TRUE#")) = "VT_BOOL", "getVT(CBool(""#TRUE#"")) = " & getVT(CBool("#TRUE#")))
729Call ok(CBool("#FALSE#") = False, "CBool(""#FALSE#"") = " & CBool("#FALSE#"))
730Call ok(getVT(CBool("#FALSE#")) = "VT_BOOL", "getVT(CBool(""#FALSE#"")) = " & getVT(CBool("#FALSE#")))
731Call ok(CBool(MyObject) = False, "CBool(MyObject) = " & CBool(MyObject))
732Call ok(getVT(CBool(MyObject)) = "VT_BOOL", "getVT(CBool(MyObject)) = " & getVT(CBool(MyObject)))
733MyObject.myval = 1
734Call ok(CBool(MyObject) = True, "CBool(MyObject) = " & CBool(MyObject))
735Call ok(getVT(CBool(MyObject)) = "VT_BOOL", "getVT(CBool(MyObject)) = " & getVT(CBool(MyObject)))
736MyObject.myval = 0
737Call ok(CBool(MyObject) = False, "CBool(MyObject) = " & CBool(MyObject))
738Call ok(getVT(CBool(MyObject)) = "VT_BOOL", "getVT(CBool(MyObject)) = " & getVT(CBool(MyObject)))
739
740Sub testCByteError(strings, error_num1,error_num2)
741    on error resume next
742    Dim x
743
744    Call Err.clear()
745    x = CByte(strings)
746    Call ok(Err.number = error_num1, "Err.number = " & Err.number)
747
748    Call Err.clear()
749    Call CByte(strings)
750    Call ok(Err.number = error_num2, "Err.number = " & Err.number)
751End Sub
752
753Call ok(CByte(Empty) = 0, "CByte(Empty) = " & CByte(Empty))
754Call ok(getVT(CByte(Empty)) = "VT_UI1", "getVT(CByte(Empty)) = " & getVT(CByte(Empty)))
755Call ok(CByte(255) = 255, "CByte(255) = " & CByte(255))
756Call ok(getVT(CByte(255)) = "VT_UI1", "getVT(CByte(255)) = " & getVT(CByte(255)))
757Call ok(CByte(255.49) = 255, "CByte(255.49) = " & CByte(255.49))
758Call ok(getVT(CByte(255.49)) = "VT_UI1", "getVT(CByte(255.49)) = " & getVT(CByte(255.49)))
759Call testCByteError(1, 0, 458)
760Call testCByteError("", 13, 13)
761Call testCByteError("-1", 6, 6)
762Call testCByteError("258", 6, 6)
763Call testCByteError("TRUE", 13, 13)
764Call testCByteError("FALSE", 13, 13)
765Call testCByteError("#TRue#", 13, 13)
766Call testCByteError("#fAlSE#", 13, 13)
767If isEnglishLang Then
768    Call ok(CByte("-0.5") = 0, "CByte(""-0.5"") = " & CByte("-0.5"))
769    Call ok(getVT(CByte("-0.5")) = "VT_UI1", "getVT(CByte(""-0.5"")) = " & getVT(CByte("-0.5")))
770End If
771Call ok(CByte(True) = 255, "CByte(True) = " & CByte(True))
772Call ok(getVT(CByte(True)) = "VT_UI1", "getVT(CByte(True)) = " & getVT(CByte(True)))
773Call ok(CByte(False) = 0, "CByte(False) = " & CByte(False))
774Call ok(getVT(CByte(False)) = "VT_UI1", "getVT(CByte(False)) = " & getVT(CByte(False)))
775Call ok(CByte(MyObject) = 0, "CByte(MyObject) = " & CByte(MyObject))
776Call ok(getVT(CByte(MyObject)) = "VT_UI1", "getVT(CByte(MyObject)) = " & getVT(CByte(MyObject)))
777MyObject.myval = 1
778Call ok(CByte(MyObject) = 1, "CByte(MyObject) = " & CByte(MyObject))
779Call ok(getVT(CByte(MyObject)) = "VT_UI1", "getVT(CByte(MyObject)) = " & getVT(CByte(MyObject)))
780MyObject.myval = 0
781Call ok(CByte(MyObject) = 0, "CByte(MyObject) = " & CByte(MyObject))
782Call ok(getVT(CByte(MyObject)) = "VT_UI1", "getVT(CByte(MyObject)) = " & getVT(CByte(MyObject)))
783
784Sub testCCurError(strings, error_num1, error_num2)
785    on error resume next
786    Dim x
787
788    Call Err.clear()
789    x = CCur(strings)
790    Call ok(Err.number = error_num1, "Err.number = " & Err.number)
791
792    Call Err.clear()
793    Call CCur(strings)
794    Call ok(Err.number = error_num2, "Err.number = " & Err.number)
795End Sub
796
797Call ok(CCur(Empty) = 0, "CCur(Empty) = " & CCur(Empty))
798Call ok(getVT(CCur(Empty)) = "VT_CY", "getVT(CCur(Empty)) = " & getVT(CCur(Empty)))
799Call ok(CCur(-32768) = -32768, "CCur(-32768) = " & CCur(-32768))
800Call ok(getVT(CCur(-32768)) = "VT_CY", "getVT(CCur(-32768)) = " & getVT(CCur(-32768)))
801Call ok(CCur(32768) = 32768, "CCur(32768) = " & CCur(32768))
802Call ok(getVT(CCur(32768)) = "VT_CY", "getVT(CCur(32768)) = " & getVT(CCur(32768)))
803Call ok(CCur(0.000149) = 0.0001, "CCur(0.000149) = " & CCur(0.000149))
804Call ok(getVT(CCur(0.000149)) = "VT_CY", "getVT(CCur(0.000149)) = " & getVT(CCur(0.000149)))
805Call ok(CCur(2147483647.99) = 2147483647.99, "CCur(2147483647.99) = " & CCur(2147483647.99))
806Call ok(getVT(CCur(2147483647.99)) = "VT_CY", "getVT(CCur(2147483647.99)) = " & getVT(CCur(2147483647.99)))
807Call ok(CCur("-1") = -1, "CCur(""-1"") = " & CCur("-1"))
808Call ok(getVT(CCur("-1")) = "VT_CY", "getVT(CCur(""-1"")) = " & getVT(CCur("-1")))
809If isEnglishLang Then
810    Call ok(CCur("-0.5") = -0.5, "CCur(""-0.5"") = " & CCur("-0.5"))
811    Call ok(getVT(CCur("-0.5")) = "VT_CY", "getVT(CCur(""-0.5"")) = " & getVT(CCur("-0.5")))
812End If
813Call testCCurError("", 13, 13)
814Call testCCurError("-1", 0, 458)
815Call testCCurError("TRUE", 13, 13)
816Call testCCurError("FALSE", 13, 13)
817Call testCCurError("#TRue#", 13, 13)
818Call testCCurError("#fAlSE#", 13, 13)
819Call testCCurError(1, 0, 458)
820Call ok(CCur(True) = -1, "CCur(True) = " & CCur(True))
821Call ok(getVT(CCur(True)) = "VT_CY", "getVT(CCur(True)) = " & getVT(CCur(True)))
822Call ok(CCur(False) = 0, "CCur(False) = " & CCur(False))
823Call ok(getVT(CCur(False)) = "VT_CY", "getVT(CCur(False)) = " & getVT(CCur(False)))
824MyObject.myval = 0.1
825Call ok(CCur(MyObject) = 0.1, "CCur(MyObject) = " & CCur(MyObject))
826Call ok(getVT(CCur(MyObject)) = "VT_CY", "getVT(CCur(MyObject)) = " & getVT(CCur(MyObject)))
827MyObject.myval = 0
828Call ok(CCur(MyObject) = 0, "CCur(MyObject) = " & CCur(MyObject))
829Call ok(getVT(CCur(MyObject)) = "VT_CY", "getVT(CCur(MyObject)) = " & getVT(CCur(MyObject)))
830
831Sub testCDblError(strings, error_num1, error_num2)
832    on error resume next
833    Dim x
834
835    Call Err.clear()
836    x = CDbl(strings)
837    Call ok(Err.number = error_num1, "Err.number = " & Err.number)
838
839    Call Err.clear()
840    Call CDbl(strings)
841    Call ok(Err.number = error_num2, "Err.number = " & Err.number)
842End Sub
843
844Call ok(CDbl(Empty) = 0, "CDbl(Empty) = " & CDbl(Empty))
845Call ok(getVT(CDbl(Empty)) = "VT_R8", "getVT(CDbl(Empty)) = " & getVT(CDbl(Empty)))
846Call ok(CDbl(CByte(0)) = 0, "CDbl(CByte(0)) = " & CDbl(CByte(0)))
847Call ok(getVT(CDbl(CCur(0))) = "VT_R8", "getVT(CDbl(CCur(0))) = " & getVT(CDbl(CCur(0))))
848Call ok(CDbl(CCur(0)) = 0, "CDbl(CCur(0)) = " & CDbl(CCur(0)))
849Call ok(getVT(CDbl(CCur(0))) = "VT_R8", "getVT(CDbl(CCur(0))) = " & getVT(CDbl(CCur(0))))
850Call ok(CDbl(0) = 0, "CDbl(0) = " & CDbl(0))
851Call ok(getVT(CDbl(0)) = "VT_R8", "getVT(CDbl(0)) = " & getVT(CDbl(0)))
852Call ok(CDbl(32768) = 32768, "CDbl(32768) = " & CDbl(32768))
853Call ok(getVT(CDbl(32768)) = "VT_R8", "getVT(CDbl(32768)) = " & getVT(CDbl(32768)))
854Call ok(CDbl(0.001 * 0.001) = 0.000001, "CDbl(0.001 * 0.001) = " & CDbl(0.001 * 0.001))
855Call ok(getVT(CDbl(0.001 * 0.001)) = "VT_R8", "getVT(CDbl(0.001 * 0.001)) = " & getVT(CDbl(0.001 * 0.001)))
856Call ok(CDbl("-1") = -1, "CDbl(""-1"") = " & CDbl("-1"))
857Call ok(getVT(CDbl("-1")) = "VT_R8", "getVT(CDbl(""-1"")) = " & getVT(CDbl("-1")))
858If isEnglishLang Then
859    Call ok(CDbl("-0.5") = -0.5, "CDbl(""-0.5"") = " & CDbl("-0.5"))
860    Call ok(getVT(CDbl("-0.5")) = "VT_R8", "getVT(CDbl(""-0.5"")) = " & getVT(CDbl("-0.5")))
861End If
862Call testCDblError("", 13, 13)
863Call testCDblError("TRUE", 13, 13)
864Call testCDblError("FALSE", 13, 13)
865Call testCDblError("#TRue#", 13, 13)
866Call testCDblError("#fAlSE#", 13, 13)
867Call testCDblError(1, 0, 458)
868Call ok(CDbl(True) = -1, "CDbl(True) = " & CDbl(True))
869Call ok(getVT(CDbl(True)) = "VT_R8", "getVT(CDbl(True)) = " & getVT(CDbl(True)))
870Call ok(CDbl(False) = 0, "CDbl(False) = " & CDbl(False))
871Call ok(getVT(CDbl(False)) = "VT_R8", "getVT(CDbl(False)) = " & getVT(CDbl(False)))
872MyObject.myval = 0.1
873Call ok(CDbl(MyObject) = 0.1, "CDbl(MyObject) = " & CDbl(MyObject))
874Call ok(getVT(CDbl(MyObject)) = "VT_R8", "getVT(CDbl(MyObject)) = " & getVT(CDbl(MyObject)))
875MyObject.myval = 0
876Call ok(CDbl(MyObject) = 0, "CDbl(MyObject) = " & CDbl(MyObject))
877Call ok(getVT(CDbl(MyObject)) = "VT_R8", "getVT(CDbl(MyObject)) = " & getVT(CDbl(MyObject)))
878
879Sub testCLngError(strings, error_num1, error_num2)
880    on error resume next
881    Dim x
882
883    Call Err.clear()
884    x = CLng(strings)
885    Call ok(Err.number = error_num1, "Err.number = " & Err.number)
886
887    Call Err.clear()
888    Call CLng(strings)
889    Call ok(Err.number = error_num2, "Err.number = " & Err.number)
890End Sub
891
892Call ok(CLng(Empty) = 0, "CLng(Empty) = " & CLng(Empty))
893Call ok(getVT(CLng(Empty)) = "VT_I4", "getVT(CLng(Empty)) = " & getVT(CLng(Empty)))
894Call ok(CLng(CByte(0)) = 0, "CLng(CByte(0)) = " & CLng(CByte(0)))
895Call ok(getVT(CLng(CCur(0))) = "VT_I4", "getVT(CLng(CCur(0))) = " & getVT(CLng(CCur(0))))
896Call ok(CLng(CCur(0)) = 0, "CLng(CCur(0)) = " & CLng(CCur(0)))
897Call ok(getVT(CLng(CCur(0))) = "VT_I4", "getVT(CLng(CCur(0))) = " & getVT(CLng(CCur(0))))
898Call ok(CLng(0) = 0, "CLng(0) = " & CLng(0))
899Call ok(getVT(CLng(0)) = "VT_I4", "getVT(CLng(0)) = " & getVT(CLng(0)))
900Call ok(CLng(0.49) = 0, "CLng(0.49) = " & CLng(0.49))
901Call ok(getVT(CLng(0.49)) = "VT_I4", "getVT(CLng(0.49)) = " & getVT(CLng(0.49)))
902Call ok(CLng(0.5) = 0, "CLng(0.5) = " & CLng(0.5))
903Call ok(getVT(CLng(0.5)) = "VT_I4", "getVT(CLng(0.5)) = " & getVT(CLng(0.5)))
904Call ok(CLng(0.51) = 1, "CLng(0.51) = " & CLng(0.51))
905Call ok(getVT(CLng(0.51)) = "VT_I4", "getVT(CLng(0.51)) = " & getVT(CLng(0.51)))
906Call ok(CLng(1.49) = 1, "CLng(1.49) = " & CLng(1.49))
907Call ok(getVT(CLng(1.49)) = "VT_I4", "getVT(CLng(1.49)) = " & getVT(CLng(1.49)))
908Call ok(CLng(1.5) = 2, "CLng(1.5) = " & CLng(1.5))
909Call ok(getVT(CLng(1.5)) = "VT_I4", "getVT(CLng(1.5)) = " & getVT(CLng(1.5)))
910Call ok(CLng(1.51) = 2, "CLng(1.51) = " & CLng(1.51))
911Call ok(getVT(CLng(1.51)) = "VT_I4", "getVT(CLng(1.51)) = " & getVT(CLng(1.51)))
912Call ok(CLng("-1") = -1, "CLng(""-1"") = " & CLng("-1"))
913Call ok(getVT(CLng("-1")) = "VT_I4", "getVT(CLng(""-1"")) = " & getVT(CLng("-1")))
914If isEnglishLang Then
915    Call ok(CLng("-0.5") = 0, "CLng(""-0.5"") = " & CLng("-0.5"))
916    Call ok(getVT(CLng("-0.5")) = "VT_I4", "getVT(CLng(""-0.5"")) = " & getVT(CLng("-0.5")))
917End If
918Call testCLngError("", 13, 13)
919Call testCLngError("TRUE", 13, 13)
920Call testCLngError("FALSE", 13, 13)
921Call testCLngError("#TRue#", 13, 13)
922Call testCLngError("#fAlSE#", 13, 13)
923Call testCLngError(1, 0, 458)
924Call ok(CLng(True) = -1, "CLng(True) = " & CLng(True))
925Call ok(getVT(CLng(True)) = "VT_I4", "getVT(CLng(True)) = " & getVT(CLng(True)))
926Call ok(CLng(False) = 0, "CLng(False) = " & CLng(False))
927Call ok(getVT(CLng(False)) = "VT_I4", "getVT(CLng(False)) = " & getVT(CLng(False)))
928MyObject.myval = 1
929Call ok(CLng(MyObject) = 1, "CLng(MyObject) = " & CLng(MyObject))
930Call ok(getVT(CLng(MyObject)) = "VT_I4", "getVT(CLng(MyObject)) = " & getVT(CLng(MyObject)))
931MyObject.myval = 0
932Call ok(CLng(MyObject) = 0, "CLng(MyObject) = " & CLng(MyObject))
933Call ok(getVT(CLng(MyObject)) = "VT_I4", "getVT(CLng(MyObject)) = " & getVT(CLng(MyObject)))
934
935Sub testCIntError(strings, error_num1, error_num2)
936    on error resume next
937    Dim x
938
939    Call Err.clear()
940    x = CInt(strings)
941    Call ok(Err.number = error_num1, "Err.number = " & Err.number)
942
943    Call Err.clear()
944    Call CInt(strings)
945    Call ok(Err.number = error_num2, "Err.number = " & Err.number)
946End Sub
947
948Call ok(CInt(Empty) = 0, "CInt(Empty) = " & CInt(Empty))
949Call ok(getVT(CInt(Empty)) = "VT_I2", "getVT(CInt(Empty)) = " & getVT(CInt(Empty)))
950Call ok(CInt(CByte(0)) = 0, "CInt(CByte(0)) = " & CInt(CByte(0)))
951Call ok(getVT(CInt(CByte(0))) = "VT_I2", "getVT(CInt(CByte(0))) = " & getVT(CInt(CByte(0))))
952Call ok(CInt(CCur(0)) = 0, "CInt(CCur(0)) = " & CInt(CCur(0)))
953Call ok(getVT(CInt(CCur(0))) = "VT_I2", "getVT(CInt(CCur(0))) = " & getVT(CInt(CCur(0))))
954Call ok(CInt(0.49) = 0, "CInt(0.49) = " & CInt(0.49))
955Call ok(getVT(CInt(0.49)) = "VT_I2", "getVT(CInt(0.49)) = " & getVT(CInt(0.49)))
956Call ok(CInt(0.5) = 0, "CInt(0.5) = " & CInt(0.5))
957Call ok(getVT(CInt(0.5)) = "VT_I2", "getVT(CInt(0.5)) = " & getVT(CInt(0.5)))
958Call ok(CInt(0.51) = 1, "CInt(0.51) = " & CInt(0.51))
959Call ok(getVT(CInt(0.51)) = "VT_I2", "getVT(CInt(0.51)) = " & getVT(CInt(0.51)))
960Call ok(CInt(1.49) = 1, "CInt(0.49) = " & CInt(0.49))
961Call ok(getVT(CInt(0.49)) = "VT_I2", "getVT(CInt(0.49)) = " & getVT(CInt(0.49)))
962Call ok(CInt(1.5) = 2, "CInt(1.5) = " & CInt(1.5))
963Call ok(getVT(CInt(1.5)) = "VT_I2", "getVT(CInt(1.5)) = " & getVT(CInt(1.5)))
964Call ok(CInt(1.51) = 2, "CInt(1.51) = " & CInt(1.51))
965Call ok(getVT(CInt(1.51)) = "VT_I2", "getVT(CInt(1.51)) = " & getVT(CInt(1.51)))
966Call ok(CInt("-1") = -1, "CInt(""-1"") = " & CInt("-1"))
967Call ok(getVT(CInt("-1")) = "VT_I2", "getVT(CInt(""-1"")) = " & getVT(CInt("-1")))
968If isEnglishLang Then
969    Call ok(CInt("-0.5") = 0, "CInt(""-0.5"") = " & CInt("-0.5"))
970    Call ok(getVT(CInt("-0.5")) = "VT_I2", "getVT(CInt(""-0.5"")) = " & getVT(CInt("-0.5")))
971End If
972Call testCIntError("", 13, 13)
973Call testCIntError("-1", 0, 458)
974Call testCIntError("TRUE", 13, 13)
975Call testCIntError("FALSE", 13, 13)
976Call testCIntError("#TRue#", 13, 13)
977Call testCIntError("#fAlSE#", 13, 13)
978Call testCIntError(1, 0, 458)
979Call testCIntError(32767.49, 0, 458)
980Call testCIntError(32767.5, 6, 6)
981Call testCIntError(-32768.5, 0, 458)
982Call testCIntError(-32768.51, 6, 6)
983Call ok(CInt(True) = -1, "CInt(True) = " & CInt(True))
984Call ok(getVT(CInt(True)) = "VT_I2", "getVT(CInt(True)) = " & getVT(CInt(True)))
985Call ok(CInt(False) = 0, "CInt(False) = " & CInt(False))
986Call ok(getVT(CInt(False)) = "VT_I2", "getVT(CInt(False)) = " & getVT(CInt(False)))
987MyObject.myval = 2.5
988Call ok(CInt(MyObject) = 2, "CInt(MyObject) = " & CInt(MyObject))
989Call ok(getVT(CInt(MyObject)) = "VT_I2", "getVT(CInt(MyObject)) = " & getVT(CInt(MyObject)))
990MyObject.myval = 1.5
991Call ok(CInt(MyObject) = 2, "CInt(MyObject) = " & CInt(MyObject))
992Call ok(getVT(CInt(MyObject)) = "VT_I2", "getVT(CInt(MyObject)) = " & getVT(CInt(MyObject)))
993
994Sub testCSngError(strings, error_num1, error_num2)
995    on error resume next
996    Dim x
997
998    Call Err.clear()
999    x = CSng(strings)
1000    Call ok(Err.number = error_num1, "Err.number = " & Err.number)
1001
1002    Call Err.clear()
1003    Call CSng(strings)
1004    Call ok(Err.number = error_num2, "Err.number = " & Err.number)
1005End Sub
1006
1007Call ok(CSng(Empty) = 0, "CSng(Empty) = " & CSng(Empty))
1008Call ok(getVT(CSng(Empty)) = "VT_R4", "getVT(CSng(Empty)) = " & getVT(CSng(Empty)))
1009Call ok(CSng(CByte(0)) = 0, "CSng(CByte(0)) = " & CSng(CByte(0)))
1010Call ok(getVT(CSng(CCur(0))) = "VT_R4", "getVT(CSng(CCur(0))) = " & getVT(CSng(CCur(0))))
1011Call ok(CSng(CCur(0)) = 0, "CSng(CCur(0)) = " & CSng(CCur(0)))
1012Call ok(getVT(CSng(CCur(0))) = "VT_R4", "getVT(CSng(CCur(0))) = " & getVT(CSng(CCur(0))))
1013Call ok(CSng(0) = 0, "CSng(0) = " & CSng(0))
1014Call ok(getVT(CSng(0)) = "VT_R4", "getVT(CSng(0)) = " & getVT(CSng(0)))
1015Call ok(CSng(32768) = 32768, "CSng(32768) = " & CSng(32768))
1016Call ok(getVT(CSng(32768)) = "VT_R4", "getVT(CSng(32768)) = " & getVT(CSng(32768)))
1017Call ok(CSng(0.001 * 0.001) = 0.000001, "CSng(0.001 * 0.001) = " & CSng(0.001 * 0.001))
1018Call ok(getVT(CSng(0.001 * 0.001)) = "VT_R4", "getVT(CSng(0.001 * 0.001)) = " & getVT(CSng(0.001 * 0.001)))
1019Call ok(CSng("-1") = -1, "CSng(""-1"") = " & CSng("-1"))
1020Call ok(getVT(CSng("-1")) = "VT_R4", "getVT(CSng(""-1"")) = " & getVT(CSng("-1")))
1021If isEnglishLang Then
1022    Call ok(CSng("-0.5") = -0.5, "CSng(""-0.5"") = " & CSng("-0.5"))
1023    Call ok(getVT(CSng("-0.5")) = "VT_R4", "getVT(CSng(""-0.5"")) = " & getVT(CSng("-0.5")))
1024End If
1025Call testCSngError("", 13, 13)
1026Call testCSngError("TRUE", 13, 13)
1027Call testCSngError("FALSE", 13, 13)
1028Call testCSngError("#TRue#", 13, 13)
1029Call testCSngError("#fAlSE#", 13, 13)
1030Call testCSngError(1, 0, 458)
1031Call ok(CSng(True) = -1, "CSng(True) = " & CSng(True))
1032Call ok(getVT(CSng(True)) = "VT_R4", "getVT(CSng(True)) = " & getVT(CSng(True)))
1033Call ok(CSng(False) = 0, "CSng(False) = " & CSng(False))
1034Call ok(getVT(CSng(False)) = "VT_R4", "getVT(CSng(False)) = " & getVT(CSng(False)))
1035MyObject.myval = 0.1
1036Call ok(CSng(MyObject) = 0.1, "CSng(MyObject) = " & CSng(MyObject))
1037Call ok(getVT(CSng(MyObject)) = "VT_R4", "getVT(CSng(MyObject)) = " & getVT(CSng(MyObject)))
1038MyObject.myval = 0
1039Call ok(CSng(MyObject) = 0, "CSng(MyObject) = " & CSng(MyObject))
1040Call ok(getVT(CSng(MyObject)) = "VT_R4", "getVT(CSng(MyObject)) = " & getVT(CSng(MyObject)))
1041
1042Call ok(TypeName(Empty) = "Empty", "TypeName(MyEmpty) = " & TypeName(Empty))
1043Call ok(getVT(TypeName(Empty)) = "VT_BSTR", "getVT(TypeName(Empty)) = " & getVT(TypeName(Empty)))
1044Call ok(TypeName(Null) = "Null", "TypeName(Null) = " & TypeName(Null))
1045Call ok(getVT(TypeName(Null)) = "VT_BSTR", "getVT(TypeName(Null)) = " & getVT(TypeName(Null)))
1046Call ok(TypeName(CByte(255)) = "Byte", "TypeName(CByte(255)) = " & TypeName(CByte(255)))
1047Call ok(getVT(TypeName(CByte(255))) = "VT_BSTR", "getVT(TypeName(CByte(255))) = " & getVT(TypeName(CByte(255))))
1048Call ok(TypeName(255) = "Integer", "TypeName(255) = " & TypeName(255))
1049Call ok(getVT(TypeName(255)) = "VT_BSTR", "getVT(TypeName(255)) = " & getVT(TypeName(255)))
1050Call ok(TypeName(32768) = "Long", "TypeName(32768) = " & TypeName(32768))
1051Call ok(getVT(TypeName(32768)) = "VT_BSTR", "getVT(TypeName(32768)) = " & getVT(TypeName(32768)))
1052Call ok(TypeName(CSng(0.5)) = "Single", "TypeName(CSng(0.5)) = " & TypeName(CSng(0.5)))
1053Call ok(getVT(TypeName(CSng(0.5))) = "VT_BSTR", "getVT(TypeName(CSng(0.5))) = " & getVT(TypeName(CSng(0.5))))
1054Call ok(TypeName(-0.5) = "Double", "TypeName(-0.5) = " & TypeName(-0.5))
1055Call ok(getVT(TypeName(-0.5)) = "VT_BSTR", "getVT(TypeName(-0.5)) = " & getVT(TypeName(-0.5)))
1056Call ok(TypeName(CCur(0.5)) = "Currency", "TypeName(CCur(0.5)) = " & TypeName(CCur(0.5)))
1057Call ok(getVT(TypeName(CCur(0.5))) = "VT_BSTR", "getVT(TypeName(CCur(0.5))) = " & getVT(TypeName(CCur(0.5))))
1058Call ok(TypeName(CStr(0.5)) = "String", "TypeName(CStr(0.5)) = " & TypeName(CStr(0.5)))
1059Call ok(getVT(TypeName(CStr(0.5))) = "VT_BSTR", "getVT(TypeName(CStr(0.5))) = " & getVT(TypeName(CStr(0.5))))
1060Call ok(TypeName(True) = "Boolean", "TypeName(True) = " & TypeName(True))
1061Call ok(getVT(TypeName(True)) = "VT_BSTR", "getVT(TypeName(True)) = " & getVT(TypeName(True)))
1062
1063Call ok(VarType(Empty) = vbEmpty, "VarType(Empty) = " & VarType(Empty))
1064Call ok(getVT(VarType(Empty)) = "VT_I2", "getVT(VarType(Empty)) = " & getVT(VarType(Empty)))
1065Call ok(VarType(Null) = vbNull, "VarType(Null) = " & VarType(Null))
1066Call ok(getVT(VarType(Null)) = "VT_I2", "getVT(VarType(Null)) = " & getVT(VarType(Null)))
1067Call ok(VarType(255) = vbInteger, "VarType(255) = " & VarType(255))
1068Call ok(getVT(VarType(255)) = "VT_I2", "getVT(VarType(255)) = " & getVT(VarType(255)))
1069Call ok(VarType(32768) = vbLong, "VarType(32768) = " & VarType(32768))
1070Call ok(getVT(VarType(32768)) = "VT_I2", "getVT(VarType(32768)) = " & getVT(VarType(32768)))
1071Call ok(VarType(CSng(0.5)) = vbSingle, "VarType(CSng(0.5)) = " & VarType(CSng(0.5)))
1072Call ok(getVT(VarType(CSng(0.5))) = "VT_I2", "getVT(VarType(CSng(0.5))) = " & getVT(VarType(CSng(0.5))))
1073Call ok(VarType(-0.5) = vbDouble, "VarType(-0.5) = " & VarType(-0.5))
1074Call ok(getVT(VarType(-0.5)) = "VT_I2", "getVT(VarType(-0.5)) = " & getVT(VarType(-0.5)))
1075Call ok(VarType(CCur(0.5)) = vbCurrency, "VarType(CCur(0.5)) = " & VarType(CCur(0.5)))
1076Call ok(getVT(VarType(CCur(0.5))) = "VT_I2", "getVT(VarType(CCur(0.5))) = " & getVT(VarType(CCur(0.5))))
1077Call ok(VarType(CStr(0.5)) = vbString, "VarType(CStr(0.5)) = " & VarType(CStr(0.5)))
1078Call ok(getVT(VarType(CStr(0.5))) = "VT_I2", "getVT(VarType(CStr(0.5))) = " & getVT(VarType(CStr(0.5))))
1079Call ok(VarType(CBool(0.5)) = vbBoolean, "VarType(CBool(0.5)) = " & VarType(CBool(0.5)))
1080Call ok(getVT(VarType(CBool(0.5))) = "VT_I2", "getVT(VarType(CBool(0.5))) = " & getVT(VarType(CBool(0.5))))
1081Call ok(VarType(CByte(255)) = vbByte, "VarType(CByte(255)) = " & VarType(CByte(255)))
1082Call ok(getVT(VarType(CByte(255))) = "VT_I2", "getVT(VarType(CByte(255))) = " & getVT(VarType(CByte(255))))
1083
1084Call ok(Sgn(Empty) = 0, "Sgn(MyEmpty) = " & Sgn(Empty))
1085Call ok(getVT(Sgn(Empty)) = "VT_I2", "getVT(Sgn(MyEmpty)) = " & getVT(Sgn(Empty)))
1086Call ok(Sgn(0) = 0, "Sgn(0) = " & Sgn(0))
1087Call ok(getVT(Sgn(0)) = "VT_I2", "getVT(Sgn(0)) = " & getVT(Sgn(0)))
1088Call ok(Sgn(-32769) = -1, "Sgn(-32769) = " & Sgn(-32769))
1089Call ok(getVT(Sgn(-32769)) = "VT_I2", "getVT(Sgn(-32769)) = " & getVT(Sgn(-32769)))
1090Call ok(Sgn(CSng(-0.5)) = -1, "Sgn(CSng(-0.5)) = " & Sgn(CSng(-0.5)))
1091Call ok(getVT(Sgn(CSng(-0.5))) = "VT_I2", "getVT(Sgn(CSng(-0.5))) = " & getVT(Sgn(CSng(-0.5))))
1092Call ok(Sgn(0.5) = 1, "Sgn(0.5) = " & Sgn(0.5))
1093Call ok(getVT(Sgn(0.5)) = "VT_I2", "getVT(Sgn(0.5)) = " & getVT(Sgn(0.5)))
1094Call ok(Sgn(CCur(-1)) = -1, "Sgn(CCur(-1)) = " & Sgn(CCur(-1)))
1095Call ok(getVT(Sgn(CCur(-1))) = "VT_I2", "getVT(Sgn(CCur(-1))) = " & getVT(Sgn(CCur(-1))))
1096Call ok(Sgn(CStr(-1)) = -1, "Sgn(CStr(-1)) = " & Sgn(CStr(-1)))
1097Call ok(getVT(Sgn(CStr(-1))) = "VT_I2", "getVT(Sgn(CStr(-1))) = " & getVT(Sgn(CStr(-1))))
1098Call ok(Sgn(False) = 0, "Sgn(False) = " & Sgn(False))
1099Call ok(getVT(Sgn(False)) = "VT_I2", "getVT(Sgn(False)) = " & getVT(Sgn(False)))
1100Call ok(Sgn(True) = -1, "Sgn(True) = " & Sgn(True))
1101Call ok(getVT(Sgn(True)) = "VT_I2", "getVT(Sgn(True)) = " & getVT(Sgn(True)))
1102Call ok(Sgn(CByte(1)) = 1, "Sgn(CByte(1)) = " & Sgn(CByte(1)))
1103Call ok(getVT(Sgn(CByte(1))) ="VT_I2", "getVT(Sgn(CByte(1))) = " & getVT(Sgn(CByte(1))))
1104
1105Sub testSgnError(strings, error_num)
1106    on error resume next
1107
1108    Call Err.clear()
1109    Call Sgn(strings)
1110    Call ok(Err.number = error_num, "Err.number = " & Err.number)
1111End Sub
1112
1113Call testSgnError(Null, 94)
1114
1115Call ok(Abs(Empty) = 0, "Abs(Empty) = " & Abs(Empty))
1116Call ok(getVT(Abs(Empty)) = "VT_I2", "getVT(Abs(Empty)) = " & getVT(Abs(Empty)))
1117Call ok(IsNull(Abs(Null)), "Is Abs(Null) not Null?")
1118Call ok(getVT(Abs(Null)) = "VT_NULL", "getVT(Abs(Null)) = " & getVT(Abs(Null)))
1119Call ok(Abs(0) = 0, "Abs(0) = " & Abs(0))
1120Call ok(getVT(Abs(0)) = "VT_I2", "getVT(Abs(0)) = " & getVT(Abs(0)))
1121Call ok(Abs(-32769) = 32769, "Abs(-32769) = " & Abs(-32769))
1122Call ok(getVT(Abs(-32769)) = "VT_I4", "getVT(Abs(-32769)) = " & getVT(Abs(-32769)))
1123Call ok(Abs(CSng(-0.5)) = 0.5, "Abs(CSng(-0.5)) = " & Abs(CSng(-0.5)))
1124Call ok(getVT(Abs(CSng(-0.5))) = "VT_R4", "getVT(Abs(CSng(-0.5))) = " & getVT(Abs(CSng(-0.5))))
1125Call ok(Abs(0.5) = 0.5, "Abs(0.5) = " & Abs(0.5))
1126Call ok(getVT(Abs(0.5)) = "VT_R8", "getVT(Abs(0.5)) = " & getVT(Abs(0.5)))
1127Call ok(Abs(CCur(-1)) = 1, "Abs(CCur(-1)) = " & Abs(CCur(-1)))
1128Call ok(getVT(Abs(CCur(-1))) = "VT_CY", "getVT(Abs(CCur(-1))) = " & getVT(Abs(CCur(-1))))
1129Call ok(Abs("-1") = 1, "Abs(""-1"") = " & Abs("-1"))
1130Call ok(getVT(Abs("-1")) = "VT_R8", "getVT(Abs(""-1"")) = " & getVT(Abs("-1")))
1131Call ok(Abs(False) = 0, "Abs(False) = " & Abs(False))
1132Call ok(getVT(Abs(False)) = "VT_I2", "getVT(Abs(False)) = " & getVT(Abs(False)))
1133Call ok(Abs(True) = 1, "Abs(True) = " & Abs(True))
1134Call ok(getVT(Abs(True)) = "VT_I2", "getVT(Abs(True)) = " & getVT(Abs(True)))
1135Call ok(Abs(CByte(1)) = 1, "Abs(CByte(1)) = " & Abs(CByte(1)))
1136Call ok(getVT(Abs(CByte(1))) = "VT_UI1", "getVT(Abs(CByte(1))) = " & getVT(Abs(CByte(1))))
1137
1138Sub testAbsError(strings, error_num1, error_num2)
1139    on error resume next
1140    Dim x
1141
1142    Call Err.clear()
1143    x = Abs(strings)
1144    Call ok(Err.number = error_num1, "Err.number1 = " & Err.number)
1145
1146    Call Err.clear()
1147    Call Abs(strings)
1148    Call ok(Err.number = error_num2, "Err.number2 = " & Err.number)
1149End Sub
1150
1151Call testAbsError("strings", 13, 13)
1152Call testAbsError(-4, 0, 0)
1153
1154Call ok(ScriptEngine = "VBScript", "Is scriptengine not VBScript?")
1155Call ok(getVT(ScriptEngine) = "VT_BSTR", "getVT(ScriptEngine) = " & getVT(ScriptEngine))
1156
1157Call ok(getVT(ScriptEngineBuildVersion) = "VT_I4", "getVT(ScriptEngineBuildVersion) = " & getVT(ScriptEngineBuildVersion))
1158
1159Call ok(getVT(ScriptEngineMajorVersion) = "VT_I4", "getVT(ScriptEngineMajorVersion) = " & getVT(ScriptEngineMajorVersion))
1160
1161Call ok(getVT(ScriptEngineMinorVersion) = "VT_I4", "getVT(ScriptEngineMinorVersion) = " & getVT(ScriptEngineMinorVersion))
1162
1163Call ok(Fix(Empty) = 0, "Fix(Empty) = " & Fix(Empty))
1164Call ok(getVT(Fix(Empty)) = "VT_I2", "getVT(Fix(Empty)) = " & getVT(Fix(Empty)))
1165Call ok(Fix(CCur(-0.99)) = 0, "Fix(CCur(-0.99)) = " & Fix(CCur(-0.99)))
1166Call ok(getVT(Fix(CCur(-0.99))) = "VT_CY", "getVT(Fix(CCur(-0.99))) = " & getVT(Fix(CCur(-0.99))))
1167Call ok(Fix(1.99) = 1, "Fix(1.99) = " & Fix(1.99))
1168Call ok(getVT(Fix(1.99)) = "VT_R8", "getVT(Fix(1.99)) = " & getVT(Fix(1.99)))
1169Call ok(Fix(-1.99) = -1, "Fix(-1.99) = " & Fix(-1.99))
1170Call ok(getVT(Fix(-1.99)) = "VT_R8", "getVT(Fix(-1.99)) = " & getVT(Fix(-1.99)))
1171If isEnglishLang Then
1172    Call ok(Fix("1.99") = 1, "Fix(""1.99"") = " & Fix("1.99"))
1173    Call ok(getVT(Fix("1.99")) = "VT_R8", "getVT(Fix(""1.99"")) = " & getVT(Fix("1.99")))
1174    Call ok(Fix("-1.99") = -1, "Fix(""-1.99"") = " & Fix("-1.99"))
1175    Call ok(getVT(Fix("-1.99")) = "VT_R8", "getVT(Fix(""-1.99"")) = " & getVT(Fix("-1.99")))
1176End If
1177Call ok(Fix(True) = -1, "Fix(True) = " & Fix(True))
1178Call ok(getVT(Fix(True)) = "VT_I2", "getVT(Fix(True)) = " & getVT(Fix(True)))
1179Call ok(Fix(False) = 0, "Fix(False) = " & Fix(False))
1180Call ok(getVT(Fix(False)) = "VT_I2", "getVT(Fix(False)) = " & getVT(Fix(False)))
1181MyObject.myval = 2.5
1182Call ok(Fix(MyObject) = 2, "Fix(MyObject) = " & Fix(MyObject))
1183Call ok(getVT(Fix(MyObject)) = "VT_R8", "getVT(Fix(MyObject)) = " & getVT(Fix(MyObject)))
1184MyObject.myval = -2.5
1185Call ok(Fix(MyObject) = -2, "Fix(MyObject) = " & Fix(MyObject))
1186Call ok(getVT(Fix(MyObject)) = "VT_R8", "getVT(Fix(MyObject)) = " & getVT(Fix(MyObject)))
1187
1188Call ok(Int(Empty) = 0, "Int(Empty) = " & Int(Empty))
1189Call ok(getVT(Int(Empty)) = "VT_I2", "getVT(Int(Empty)) = " & getVT(Int(Empty)))
1190Call ok(Int(CCur(-0.99)) = -1, "Int(CCur(-0.99)) = " & Int(CCur(-0.99)))
1191Call ok(getVT(Int(CCur(-0.99))) = "VT_CY", "getVT(Int(CCur(-0.99))) = " & getVT(Int(CCur(-0.99))))
1192Call ok(Int(1.99) = 1, "Int(1.99) = " & Int(1.99))
1193Call ok(getVT(Int(1.99)) = "VT_R8", "getVT(Int(1.99)) = " & getVT(Int(1.99)))
1194Call ok(Int(-1.99) = -2, "Int(-1.99) = " & Int(-1.99))
1195Call ok(getVT(Int(-1.99)) = "VT_R8", "getVT(Int(-1.99)) = " & getVT(Int(-1.99)))
1196If isEnglishLang Then
1197    Call ok(Int("1.99") = 1, "Int(""1.99"") = " & Int("1.99"))
1198    Call ok(getVT(Int("1.99")) = "VT_R8", "getVT(Int(""1.99"")) = " & getVT(Int("1.99")))
1199    Call ok(Int("-1.99") = -2, "Int(""-1.99"") = " & Int("-1.99"))
1200    Call ok(getVT(Int("-1.99")) = "VT_R8", "getVT(Int(""-1.99"")) = " & getVT(Int("-1.99")))
1201End If
1202Call ok(Int(True) = -1, "Int(True) = " & Int(True))
1203Call ok(getVT(Int(True)) = "VT_I2", "getVT(Int(True)) = " & getVT(Int(True)))
1204Call ok(Int(False) = 0, "Int(False) = " & Int(False))
1205Call ok(getVT(Int(False)) = "VT_I2", "getVT(Int(False)) = " & getVT(Int(False)))
1206MyObject.myval = 2.5
1207Call ok(Int(MyObject) = 2, "Int(MyObject) = " & Int(MyObject))
1208Call ok(getVT(Int(MyObject)) = "VT_R8", "getVT(Int(MyObject)) = " & getVT(Int(MyObject)))
1209MyObject.myval = -2.5
1210Call ok(Int(MyObject) = -3, "Int(MyObject) = " & Int(MyObject))
1211Call ok(getVT(Int(MyObject)) = "VT_R8", "getVT(Int(MyObject)) = " & getVT(Int(MyObject)))
1212
1213Sub testSqrError(strings, error_num1, error_num2)
1214    on error resume next
1215    Dim x
1216
1217    Call Err.clear()
1218    x = Sqr(strings)
1219    Call ok(Err.number = error_num1, "Err.number1 = " & Err.number)
1220
1221    Call Err.clear()
1222    Call Sqr(strings)
1223    Call ok(Err.number = error_num2, "Err.number2 = " & Err.number)
1224End Sub
1225
1226Call testSqrError(-2, 5, 5)
1227Call testSqrError(True, 5, 5)
1228
1229Call ok(Sqr(Empty) = 0, "Sqr(Empty) = " & Sqr(Empty))
1230Call ok(getVT(Sqr(Empty)) = "VT_R8", "getVT(Sqr(Empty)) = " & getVT(Sqr(Empty)))
1231Call ok(Sqr(0) = 0, "Sqr(0) = " & Sqr(0))
1232Call ok(getVT(Sqr(0)) = "VT_R8", "getVT(Sqr(0)) = " & getVT(Sqr(0)))
1233Call ok(Sqr(1) = 1, "Sqr(1) = " & Sqr(1))
1234Call ok(getVT(Sqr(1)) = "VT_R8", "getVT(Sqr(1)) = " & getVT(Sqr(1)))
1235Call ok(Sqr(CSng(121)) = 11, "Sqr(CSng(121)) = " & Sqr(CSng(121)))
1236Call ok(getVT(Sqr(CSng(121))) = "VT_R8", "getVT(Sqr(CSng(121))) = " & getVT(Sqr(CSng(121))))
1237Call ok(Sqr(36100) = 190, "Sqr(36100) = " & Sqr(36100))
1238Call ok(getVT(Sqr(36100)) = "VT_R8", "getVT(Sqr(36100)) = " & getVT(Sqr(36100)))
1239Call ok(Sqr(CCur(0.0625)) = 0.25, "Sqr(CCur(0.0625)) = " & Sqr(CCur(0.0625)))
1240Call ok(getVT(Sqr(CCur(0.0625))) = "VT_R8", "getVT(Sqr(CCur(0.0625))) = " & getVT(Sqr(CCur(0.0625))))
1241Call ok(Sqr("100000000") = 10000, "Sqr(""100000000"") = " & Sqr("100000000"))
1242Call ok(getVT(Sqr("100000000")) = "VT_R8", "getVT(Sqr(""100000000"")) = " & getVT(Sqr("100000000")))
1243Call ok(Sqr(False) = 0, "Sqr(False) = " & Sqr(False))
1244Call ok(getVT(Sqr(False)) = "VT_R8", "getVT(Sqr(False)) = " & getVT(Sqr(False)))
1245Call ok(Sqr(CByte(225)) = 15, "Sqr(CByte(225)) = " & Sqr(CByte(225)))
1246Call ok(getVT(Sqr(CByte(225))) = "VT_R8", "getVT(Sqr(CByte(225))) = " & getVT(Sqr(CByte(225))))
1247
1248Function Approch(func, res)
1249    If Abs(func - res) < 0.001 Then
1250        Approch = True
1251    Else
1252        Approch = False
1253    End If
1254End Function
1255
1256Const PI = 3.1415926
1257
1258Call ok(Approch(Cos(Empty), 1), "Cos(Empty) = " & Cos(Empty))
1259Call ok(getVT(Cos(Empty)) = "VT_R8", "getVT(Cos(Empty)) = " & getVT(Cos(Empty)))
1260Call ok(Approch(Cos(PI / 6), Sqr(3) / 2), "Cos(PI / 6) = " & Cos(PI / 6))
1261Call ok(getVT(Cos(PI / 6)) = "VT_R8", "getVT(Cos(PI / 6)) = " & getVT(Cos(PI / 6)))
1262Call ok(Approch(Cos(CCur(PI / 4)), Sqr(2) / 2), "Cos(CCur(PI / 4)) = " & Cos(CCur(PI / 4)))
1263Call ok(getVT(Cos(CCur(PI / 4))) = "VT_R8", "getVT(Cos(CCur(PI / 4))) = " & getVT(Cos(CCur(PI / 4))))
1264Call ok(Approch(Cos(CSng(PI / 3)), 1 / 2), "Cos(CSng(PI / 3)) = " & Cos(CSng(PI / 3)))
1265Call ok(getVT(Cos(CSng(PI / 3))) = "VT_R8", "getVT(Cos(CSng(PI))) = " & getVT(Cos(CSng(PI))))
1266Call ok(Approch(Cos(PI / 2), 0), "Cos(0) = " & Cos(PI / 2))
1267Call ok(getVT(Cos(PI / 2)) = "VT_R8", "getVT(Cos(PI / 2)) = " & getVT(Cos(PI / 2)))
1268Call ok(Approch(Cos(PI), -1), "Cos(PI) = " & Cos(PI))
1269Call ok(getVT(Cos(PI)) = "VT_R8", "getVT(Cos(PI)) = " & getVT(Cos(PI)))
1270Call ok(Approch(Cos(5 * PI / 4), -Sqr(2) / 2), "Cos(5 * PI / 4) = " & Cos(5 * PI / 4))
1271Call ok(getVT(Cos(5 * PI / 4)) = "VT_R8", "getVT(Cos(5 * PI / 4)) = " & getVT(Cos(5 * PI / 4)))
1272Call ok(Approch(Cos(3 * PI / 2), 0), "Cos(3 * PI / 2) = " & Cos(3 * PI / 2))
1273Call ok(getVT(Cos(3 * PI / 2)) = "VT_R8", "getVT(Cos(3 * PI / 2)) = " & getVT(Cos(3 * PI / 2)))
1274Call ok(Approch(Cos(2 * PI), 1), "Cos(2 * PI) = " & Cos(2 * PI))
1275Call ok(getVT(Cos(2 * PI)) = "VT_R8", "getVT(Cos(2 * PI)) = " & getVT(Cos(2 * PI)))
1276Call ok(Approch(Cos("-32768"), 0.3729), "Cos(""-32768"") = " & Cos("-32768"))
1277Call ok(getVT(Cos("-32768")) = "VT_R8", "getVT(Cos(""-32768"")) = " & getVT(Cos("-32768")))
1278Call ok(Approch(Cos(False), 1), "Cos(False) = " & Cos(False))
1279Call ok(getVT(Cos(False)) = "VT_R8", "getVT(Cos(False)) = " & getVT(Cos(False)))
1280Call ok(Approch(Cos(True), 0.5403), "Cos(True) = " & Cos(True))
1281Call ok(getVT(Cos(True)) = "VT_R8", "getVT(Cos(True)) = " & getVT(Cos(True)))
1282Call ok(Approch(Cos(CByte(255)), -0.8623), "Cos(CByte(255)) = " & Cos(CByte(255)))
1283Call ok(getVT(Cos(CByte(255))) = "VT_R8", "getVT(Cos(CByte(255))) = " & getVT(Cos(CByte(255))))
1284
1285Call ok(Approch(Sin(Empty), 0), "Sin(Empty) = " & Sin(Empty))
1286Call ok(getVT(Sin(Empty)) = "VT_R8", "getVT(Sin(Empty)) = " & getVT(Sin(Empty)))
1287Call ok(Approch(Sin(PI / 6), 1 / 2), "Sin(PI / 6) = " & Sin(PI / 6))
1288Call ok(getVT(Sin(PI / 6)) = "VT_R8", "getVT(Sin(PI / 6)) = " & getVT(Sin(PI / 6)))
1289Call ok(Approch(Sin(CCur(PI / 4)), Sqr(2) / 2), "Sin(CCur(PI / 4)) = " & Sin(CCur(PI / 4)))
1290Call ok(getVT(Sin(CCur(PI / 4))) = "VT_R8", "getVT(Sin(CCur(PI / 4))) = " & getVT(Sin(CCur(PI / 4))))
1291Call ok(Approch(Sin(CSng(PI / 3)), Sqr(3) / 2), "Sin(CSng(PI / 3)) = " & Sin(CSng(PI / 3)))
1292Call ok(getVT(Sin(CSng(PI / 3))) = "VT_R8", "getVT(Sin(CSng(PI))) = " & getVT(Sin(CSng(PI))))
1293Call ok(Approch(Sin(PI / 2), 1), "Sin(0) = " & Sin(PI / 2))
1294Call ok(getVT(Sin(PI / 2)) = "VT_R8", "getVT(Sin(PI / 2)) = " & getVT(Sin(PI / 2)))
1295Call ok(Approch(Sin(PI), 0), "Sin(PI) = " & Sin(PI))
1296Call ok(getVT(Sin(PI)) = "VT_R8", "getVT(Sin(PI)) = " & getVT(Sin(PI)))
1297Call ok(Approch(Sin(5 * PI / 4), -Sqr(2) / 2), "Sin(5 * PI / 4) = " & Sin(5 * PI / 4))
1298Call ok(getVT(Sin(5 * PI / 4)) = "VT_R8", "getVT(Sin(5 * PI / 4)) = " & getVT(Sin(5 * PI / 4)))
1299Call ok(Approch(Sin(3 * PI / 2), -1), "Sin(3 * PI / 2) = " & Sin(3 * PI / 2))
1300Call ok(getVT(Sin(3 * PI / 2)) = "VT_R8", "getVT(Sin(3 * PI / 2)) = " & getVT(Sin(3 * PI / 2)))
1301Call ok(Approch(Sin(2 * PI), 0), "Sin(2 * PI) = " & Sin(2 * PI))
1302Call ok(getVT(Sin(2 * PI)) = "VT_R8", "getVT(Sin(2 * PI)) = " & getVT(Sin(2 * PI)))
1303Call ok(Approch(Sin("-32768"), -0.9278), "Sin(""-32768"") = " & Sin("-32768"))
1304Call ok(getVT(Sin("-32768")) = "VT_R8", "getVT(Sin(""-32768"")) = " & getVT(Sin("-32768")))
1305Call ok(Approch(Sin(False), 0), "Sin(False) = " & Sin(False))
1306Call ok(getVT(Sin(False)) = "VT_R8", "getVT(Sin(False)) = " & getVT(Sin(False)))
1307Call ok(Approch(Sin(True), -0.84147), "Sin(True) = " & Sin(True))
1308Call ok(getVT(Sin(True)) = "VT_R8", "getVT(Sin(True)) = " & getVT(Sin(True)))
1309Call ok(Approch(Sin(CByte(255)), -0.5063), "Sin(CByte(255)) = " & Sin(CByte(255)))
1310Call ok(getVT(Sin(CByte(255))) = "VT_R8", "getVT(Sin(CByte(255))) = " & getVT(Sin(CByte(255))))
1311
1312Call ok(Approch(Tan(Empty), 0), "Tan(Empty) = " & Tan(Empty))
1313Call ok(getVT(Tan(Empty)) = "VT_R8", "getVT(Tan(Empty)) = " & getVT(Tan(Empty)))
1314Call ok(Approch(Tan(PI / 6), Sqr(3) / 3), "Tan(PI / 6) = " & Tan(PI / 6))
1315Call ok(getVT(Tan(PI / 6)) = "VT_R8", "getVT(Tan(PI / 6)) = " & getVT(Tan(PI / 6)))
1316Call ok(Approch(Tan(CCur(PI / 4)), 1), "Tan(CCur(PI / 4)) = " & Tan(CCur(PI / 4)))
1317Call ok(getVT(Tan(CCur(PI / 4))) = "VT_R8", "getVT(Tan(CCur(PI / 4))) = " & getVT(Tan(CCur(PI / 4))))
1318Call ok(Approch(Tan(CSng(PI / 3)), Sqr(3)), "Tan(CSng(PI / 3)) = " & Tan(CSng(PI / 3)))
1319Call ok(getVT(Tan(CSng(PI / 3))) = "VT_R8", "getVT(Tan(CSng(PI))) = " & getVT(Tan(CSng(PI))))
1320Call ok(Approch(Tan(PI), 0), "Tan(PI) = " & Tan(PI))
1321Call ok(getVT(Tan(PI)) = "VT_R8", "getVT(Tan(PI)) = " & getVT(Tan(PI)))
1322Call ok(Approch(Tan(3 * PI / 4), -1), "Tan(3 * PI / 4) = " & Tan(3 * PI / 4))
1323Call ok(getVT(Tan(3 * PI / 4)) = "VT_R8", "getVT(Tan(3 * PI / 4)) = " & getVT(Tan(3 * PI / 4)))
1324Call ok(Approch(Tan(5 * PI / 4), 1), "Tan(5 * PI / 4) = " & Tan(5 * PI / 4))
1325Call ok(getVT(Tan(5 * PI / 4)) = "VT_R8", "getVT(Tan(5 * PI / 4)) = " & getVT(Tan(5 * PI / 4)))
1326Call ok(Approch(Tan(2 * PI), 0), "Tan(2 * PI) = " & Tan(2 * PI))
1327Call ok(getVT(Tan(2 * PI)) = "VT_R8", "getVT(Tan(2 * PI)) = " & getVT(Tan(2 * PI)))
1328Call ok(Approch(Tan("-32768"), -2.4879), "Tan(""-32768"") = " & Tan("-32768"))
1329Call ok(getVT(Tan("-32768")) = "VT_R8", "getVT(Tan(""-32768"")) = " & getVT(Tan("-32768")))
1330Call ok(Approch(Tan(False), 0), "Tan(False) = " & Tan(False))
1331Call ok(getVT(Tan(False)) = "VT_R8", "getVT(Tan(False)) = " & getVT(Tan(False)))
1332Call ok(Approch(Tan(True), -1.5574), "Tan(True) = " & Tan(True))
1333Call ok(getVT(Tan(True)) = "VT_R8", "getVT(Tan(True)) = " & getVT(Tan(True)))
1334Call ok(Approch(Tan(CByte(255)), 0.5872), "Tan(CByte(255)) = " & Tan(CByte(255)))
1335Call ok(getVT(Tan(CByte(255))) = "VT_R8", "getVT(Tan(CByte(255))) = " & getVT(Tan(CByte(255))))
1336
1337Call ok(Approch(Atn(Empty), 0), "Atn(Empty) = " & Atn(Empty))
1338Call ok(getVT(Atn(Empty)) = "VT_R8", "getVT(Atn(Empty)) = " & getVT(Atn(Empty)))
1339Call ok(Approch(Atn(Sqr(3) / 3), PI / 6), "Atn(Sqr(3) / 3) = " & Atn(Sqr(3) / 3))
1340Call ok(getVT(Atn(Sqr(3) / 3)) = "VT_R8", "getVT(Atn(Sqr(3) / 3)) = " & getVT(Atn(Sqr(3) / 3)))
1341Call ok(Approch(Atn(CCur(1)), PI / 4), "Atn(CCur(1)) = " & Atn(CCur(1)))
1342Call ok(getVT(Atn(CCur(1))) = "VT_R8", "getVT(Atn(CCur(1))) = " & getVT(Atn(CCur(1))))
1343Call ok(Approch(Atn(CSng(Sqr(3))), PI / 3), "Atn(CSng(Sqr(3))) = " & Atn(CSng(Sqr(3))))
1344Call ok(getVT(Atn(CSng(Sqr(3)))) = "VT_R8", "getVT(Atn(CSng(PI))) = " & getVT(Atn(CSng(PI))))
1345Call ok(Approch(Atn(0), 0), "Atn(0) = " & Atn(0))
1346Call ok(getVT(Atn(0)) = "VT_R8", "getVT(Atn(0)) = " & getVT(Atn(0)))
1347Call ok(Approch(Atn(-1), -PI / 4), "Atn(-1) = " & Atn(-1))
1348Call ok(getVT(Atn(-1)) = "VT_R8", "getVT(Atn(-1)) = " & getVT(Atn(-1)))
1349Call ok(Approch(Atn("-32768"), -1.5707), "Atn(""-32768"") = " & Atn("-32768"))
1350Call ok(getVT(Atn("-32768")) = "VT_R8", "getVT(Atn(""-32768"")) = " & getVT(Atn("-32768")))
1351Call ok(Approch(Atn(False), 0), "Atn(False) = " & Atn(False))
1352Call ok(getVT(Atn(False)) = "VT_R8", "getVT(Atn(False)) = " & getVT(Atn(False)))
1353Call ok(Approch(Atn(True), -0.7853), "Atn(True) = " & Atn(True))
1354Call ok(getVT(Atn(True)) = "VT_R8", "getVT(Atn(True)) = " & getVT(Atn(True)))
1355Call ok(Approch(Atn(CByte(255)), 1.5668), "Atn(CByte(255)) = " & Atn(CByte(255)))
1356Call ok(getVT(Atn(CByte(255))) = "VT_R8", "getVT(Atn(CByte(255))) = " & getVT(Atn(CByte(255))))
1357
1358Call ok(Approch(Exp(Empty), 1), "Exp(Empty) = " & Exp(Empty))
1359Call ok(getVT(Exp(Empty)) = "VT_R8", "getVT(Exp(Empty)) = " & getVT(Exp(Empty)))
1360Call ok(Approch(Exp(1), 2.7182), "Exp(1) = " & Exp(1))
1361Call ok(getVT(Exp(1)) = "VT_R8", "getVT(Exp(1)) = " & getVT(Exp(1)))
1362Call ok(Approch(Exp(CCur(-1)), 0.3678), "Exp(CCur(-1)) = " & Exp(CCur(-1)))
1363Call ok(getVT(Exp(CCur(-1))) = "VT_R8", "getVT(Exp(CCur(-1))) = " & getVT(Exp(CCur(-1))))
1364Call ok(Approch(Exp(CSng(0.5)), 1.6487), "Exp(CSng(0.5)) = " & Exp(CSng(0.5)))
1365Call ok(getVT(Exp(CSng(0.5))) = "VT_R8", "getVT(Exp(CSng(PI))) = " & getVT(Exp(CSng(PI))))
1366Call ok(Approch(Exp(-0.5), 0.6065), "Exp(-0.5) = " & Exp(-0.5))
1367Call ok(getVT(Exp(-0.5)) = "VT_R8", "getVT(Exp(-0.5)) = " & getVT(Exp(-0.5)))
1368Call ok(Approch(Exp("-2"), 0.1353), "Exp(""-2"") = " & Exp("-2"))
1369Call ok(getVT(Exp("-2")) = "VT_R8", "getVT(Exp(""-2"")) = " & getVT(Exp("-2")))
1370Call ok(Approch(Exp(False), 1), "Exp(False) = " & Exp(False))
1371Call ok(getVT(Exp(False)) = "VT_R8", "getVT(Exp(False)) = " & getVT(Exp(False)))
1372Call ok(Approch(Exp(True), 0.3678), "Exp(True) = " & Exp(True))
1373Call ok(getVT(Exp(True)) = "VT_R8", "getVT(Exp(True)) = " & getVT(Exp(True)))
1374Call ok(Approch(Exp(CByte(2)), 7.389), "Exp(CByte(2)) = " & Exp(CByte(2)))
1375Call ok(getVT(Exp(CByte(2))) = "VT_R8", "getVT(Exp(CByte(2))) = " & getVT(Exp(CByte(2))))
1376
1377Sub testLogError(strings, error_num1, error_num2)
1378    on error resume next
1379    Dim x
1380
1381    Call Err.clear()
1382    x = Log(strings)
1383    Call ok(Err.number = error_num1, "Err.number1 = " & Err.number)
1384
1385    Call Err.clear()
1386    Call Log(strings)
1387    Call ok(Err.number = error_num2, "Err.number2 = " & Err.number)
1388End Sub
1389
1390Call testLogError(0, 5, 5)
1391Call testLogError(-2, 5, 5)
1392Call testLogError(False, 5, 5)
1393Call testLogError(True, 5, 5)
1394Call ok(Approch(Log(1), 0), "Log(1) = " & Log(1))
1395Call ok(getVT(Log(1)) = "VT_R8", "getVT(Log(1)) = " & getVT(Log(1)))
1396Call ok(Approch(Log(CCur(0.5)), -0.6931), "Log(CCur(0.5)) = " & Log(CCur(0.5)))
1397Call ok(getVT(Log(CCur(0.5))) = "VT_R8", "getVT(Log(CCur(0.5))) = " & getVT(Log(CCur(0.5))))
1398Call ok(Approch(Log(CSng(2.7182)), 1), "Log(CSng(2.7182)) = " & Log(CSng(2.7182)))
1399Call ok(getVT(Log(CSng(2.7182))) = "VT_R8", "getVT(Log(CSng(PI))) = " & getVT(Log(CSng(PI))))
1400Call ok(Approch(Log(32768), 10.3972), "Log(32768) = " & Log(32768))
1401Call ok(getVT(Log(32768)) = "VT_R8", "getVT(Log(32768)) = " & getVT(Log(32768)))
1402Call ok(Approch(Log("10"), 2.3025), "Log(""10"") = " & Log("10"))
1403Call ok(getVT(Log("10")) = "VT_R8", "getVT(Log(""10"")) = " & getVT(Log("10")))
1404Call ok(Approch(Log(CByte(2)), 0.6931), "Log(CByte(2)) = " & Log(CByte(2)))
1405Call ok(getVT(Log(CByte(2))) = "VT_R8", "getVT(Log(CByte(2))) = " & getVT(Log(CByte(2))))
1406
1407Call ok(getVT(Date) = "VT_DATE", "getVT(Date) = " & getVT(Date))
1408Call ok(getVT(Time) = "VT_DATE", "getVT(Time) = " & getVT(Time))
1409
1410Sub testRGBError(arg1, arg2, arg3, error_num)
1411    on error resume next
1412    Dim x
1413
1414    Call Err.clear()
1415    x = RGB(arg1, arg2, arg3)
1416    Call ok(Err.number = error_num, "Err.number1 = " & Err.number)
1417
1418    Call Err.clear()
1419    Call RGB(arg1, arg2, arg3)
1420    Call ok(Err.number = error_num, "Err.number2 = " & Err.number)
1421End Sub
1422
1423Call ok(RGB(0, &h1f&, &hf1&) =  &hf11f00&, "RGB(0, &h1f&, &hf1&) = " & RGB(0, &h1f&, &hf1&))
1424Call ok(getVT(RGB(0, &h1f&, &hf1&)) = "VT_I4", "getVT(RGB(&hf1&, &h1f&, &hf1&)) = " & getVT(RGB(&hf1&, &h1f&, &hf1&)))
1425Call ok(RGB(&hef&, &hab&, &hcd&) =  &hcdabef&, "RGB(&hef&, &hab&, &hcd&) = " & RGB(&hef&, &hab&, &hcd&))
1426Call ok(getVT(RGB(&hef&, &hab&, &hcd&)) = "VT_I4", "getVT(RGB(&hef&, &hab&, &hcd&)) = " & getVT(RGB(&hef&, &hab&, &hcd&)))
1427Call ok(RGB(&h1&, &h100&, &h111&) =  &hffff01&, "RGB(&h1&, &h100&, &h111&) = " & RGB(&h1&, &h100&, &h111&))
1428Call ok(getVT(RGB(&h1&, &h100&, &h111&)) = "VT_I4", "getVT(RGB(&h1&, &h100&, &h111&)) = " & getVT(RGB(&h1&, &h100&, &h111&)))
1429Call testRGBError(-1, &h1e&, &h3b&, 5)
1430Call testRGBError(&h4d&, -2, &h2f&, 5)
1431
1432Call ok(getVT(Timer) = "VT_R4", "getVT(Timer) = " & getVT(Timer))
1433
1434Call reportSuccess()
1435