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