Release 1.4.1.
[wine] / dlls / vbscript / tests / lang.vbs
1 '
2 ' Copyright 2011 Jacek Caban for CodeWeavers
3 '
4 ' This library is free software; you can redistribute it and/or
5 ' modify it under the terms of the GNU Lesser General Public
6 ' License as published by the Free Software Foundation; either
7 ' version 2.1 of the License, or (at your option) any later version.
8 '
9 ' This library is distributed in the hope that it will be useful,
10 ' but WITHOUT ANY WARRANTY; without even the implied warranty of
11 ' MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12 ' Lesser General Public License for more details.
13 '
14 ' You should have received a copy of the GNU Lesser General Public
15 ' License along with this library; if not, write to the Free Software
16 ' Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
17 '
18
19 Option Explicit
20
21 dim x, y, z
22
23 call ok(true, "true is not true?")
24 ok true, "true is not true?"
25 call ok((true), "true is not true?")
26
27 ok not false, "not false but not true?"
28 ok not not true, "not not true but not true?"
29
30 Call ok(true = true, "true = true is false")
31 Call ok(false = false, "false = false is false")
32 Call ok(not (true = false), "true = false is true")
33 Call ok("x" = "x", """x"" = ""x"" is false")
34 Call ok(empty = empty, "empty = empty is false")
35 Call ok(empty = "", "empty = """" is false")
36 Call ok(0 = 0.0, "0 <> 0.0")
37 Call ok(16 = &h10&, "16 <> &h10&")
38 Call ok(010 = 10, "010 <> 10")
39 Call ok(10. = 10, "10. <> 10")
40 Call ok(&hffFFffFF& = -1, "&hffFFffFF& <> -1")
41 Call ok(&hffFFffFF& = -1, "&hffFFffFF& <> -1")
42 Call ok(--1 = 1, "--1 = " & --1)
43 Call ok(-empty = 0, "-empty = " & (-empty))
44 Call ok(true = -1, "! true = -1")
45 Call ok(false = 0, "false <> 0")
46 Call ok(&hff = 255, "&hff <> 255")
47 Call ok(&Hff = 255, "&Hff <> 255")
48
49 x = "xx"
50 Call ok(x = "xx", "x = " & x & " expected ""xx""")
51
52 Call ok(true <> false, "true <> false is false")
53 Call ok(not (true <> true), "true <> true is true")
54 Call ok(not ("x" <> "x"), """x"" <> ""x"" is true")
55 Call ok(not (empty <> empty), "empty <> empty is true")
56 Call ok(x <> "x", "x = ""x""")
57 Call ok("true" <> true, """true"" = true is true")
58
59 Call ok("" = true = false, """"" = true = false is false")
60 Call ok(not(false = true = ""), "false = true = """" is true")
61 Call ok(not (false = false <> false = false), "false = false <> false = false is true")
62 Call ok(not ("" <> false = false), """"" <> false = false is true")
63
64 Call ok(getVT(false) = "VT_BOOL", "getVT(false) is not VT_BOOL")
65 Call ok(getVT(true) = "VT_BOOL", "getVT(true) is not VT_BOOL")
66 Call ok(getVT("") = "VT_BSTR", "getVT("""") is not VT_BSTR")
67 Call ok(getVT("test") = "VT_BSTR", "getVT(""test"") is not VT_BSTR")
68 Call ok(getVT(Empty) = "VT_EMPTY", "getVT(Empty) is not VT_EMPTY")
69 Call ok(getVT(null) = "VT_NULL", "getVT(null) is not VT_NULL")
70 Call ok(getVT(0) = "VT_I2", "getVT(0) is not VT_I2")
71 Call ok(getVT(1) = "VT_I2", "getVT(1) is not VT_I2")
72 Call ok(getVT(0.5) = "VT_R8", "getVT(0.5) is not VT_R8")
73 Call ok(getVT(0.0) = "VT_R8", "getVT(0.0) is not VT_R8")
74 Call ok(getVT(2147483647) = "VT_I4", "getVT(2147483647) is not VT_I4")
75 Call ok(getVT(2147483648) = "VT_R8", "getVT(2147483648) is not VT_R8")
76 Call ok(getVT(&h10&) = "VT_I2", "getVT(&h10&) is not VT_I2")
77 Call ok(getVT(&h10000&) = "VT_I4", "getVT(&h10000&) is not VT_I4")
78 Call ok(getVT(&H10000&) = "VT_I4", "getVT(&H10000&) is not VT_I4")
79 Call ok(getVT(&hffFFffFF&) = "VT_I2", "getVT(&hffFFffFF&) is not VT_I2")
80 Call ok(getVT(1 & 100000) = "VT_BSTR", "getVT(1 & 100000) is not VT_BSTR")
81 Call ok(getVT(-empty) = "VT_I2", "getVT(-empty) = " & getVT(-empty))
82 Call ok(getVT(-null) = "VT_NULL", "getVT(-null) = " & getVT(-null))
83 Call ok(getVT(y) = "VT_EMPTY*", "getVT(y) = " & getVT(y))
84 Call ok(getVT(nothing) = "VT_DISPATCH", "getVT(nothing) = " & getVT(nothing))
85 set x = nothing
86 Call ok(getVT(x) = "VT_DISPATCH*", "getVT(x=nothing) = " & getVT(x))
87 x = true
88 Call ok(getVT(x) = "VT_BOOL*", "getVT(x) = " & getVT(x))
89 Call ok(getVT(false or true) = "VT_BOOL", "getVT(false) is not VT_BOOL")
90 x = "x"
91 Call ok(getVT(x) = "VT_BSTR*", "getVT(x) is not VT_BSTR*")
92 x = 0.0
93 Call ok(getVT(x) = "VT_R8*", "getVT(x) = " & getVT(x))
94
95 Call ok(isNullDisp(nothing), "nothing is not nulldisp?")
96
97 x = "xx"
98 Call ok("ab" & "cd" = "abcd", """ab"" & ""cd"" <> ""abcd""")
99 Call ok("ab " & null = "ab ", """ab"" & null = " & ("ab " & null))
100 Call ok("ab " & empty = "ab ", """ab"" & empty = " & ("ab " & empty))
101 Call ok(1 & 100000 = "1100000", "1 & 100000 = " & (1 & 100000))
102 Call ok("ab" & x = "abxx", """ab"" & x = " & ("ab"&x))
103
104 if(isEnglishLang) then
105     Call ok("" & true = "True", """"" & true = " & true)
106     Call ok(true & false = "TrueFalse", "true & false = " & (true & false))
107 end if
108
109 call ok(true and true, "true and true is not true")
110 call ok(true and not false, "true and not false is not true")
111 call ok(not (false and true), "not (false and true) is not true")
112 call ok(getVT(null and true) = "VT_NULL", "getVT(null and true) = " & getVT(null and true))
113
114 call ok(false or true, "false or uie is false?")
115 call ok(not (false or false), "false or false is not false?")
116 call ok(false and false or true, "false and false or true is false?")
117 call ok(true or false and false, "true or false and false is false?")
118 call ok(null or true, "null or true is false")
119
120 call ok(true xor false, "true xor false is false?")
121 call ok(not (false xor false), "false xor false is true?")
122 call ok(not (true or false xor true), "true or false xor true is true?")
123 call ok(not (true xor false or true), "true xor false or true is true?")
124
125 call ok(false eqv false, "false does not equal false?")
126 call ok(not (false eqv true), "false equals true?")
127 call ok(getVT(false eqv null) = "VT_NULL", "getVT(false eqv null) = " & getVT(false eqv null))
128
129 call ok(true imp true, "true does not imp true?")
130 call ok(false imp false, "false does not imp false?")
131 call ok(not (true imp false), "true imp false?")
132 call ok(false imp null, "false imp null is false?")
133
134 Call ok(2 >= 1, "! 2 >= 1")
135 Call ok(2 >= 2, "! 2 >= 2")
136 Call ok(not(true >= 2), "true >= 2 ?")
137 Call ok(2 > 1, "! 2 > 1")
138 Call ok(false > true, "! false < true")
139 Call ok(0 > true, "! 0 > true")
140 Call ok(not (true > 0), "true > 0")
141 Call ok(not (0 > 1 = 1), "0 > 1 = 1")
142 Call ok(1 < 2, "! 1 < 2")
143 Call ok(1 = 1 < 0, "! 1 = 1 < 0")
144 Call ok(1 <= 2, "! 1 <= 2")
145 Call ok(2 <= 2, "! 2 <= 2")
146
147 x = 3
148 Call ok(2+2 = 4, "2+2 = " & (2+2))
149 Call ok(false + 6 + true = 5, "false + 6 + true <> 5")
150 Call ok(getVT(2+null) = "VT_NULL", "getVT(2+null) = " & getVT(2+null))
151 Call ok(2+empty = 2, "2+empty = " & (2+empty))
152 Call ok(x+x = 6, "x+x = " & (x+x))
153
154 Call ok(5-1 = 4, "5-1 = " & (5-1))
155 Call ok(3+5-true = 9, "3+5-true <> 9")
156 Call ok(getVT(2-null) = "VT_NULL", "getVT(2-null) = " & getVT(2-null))
157 Call ok(2-empty = 2, "2-empty = " & (2-empty))
158 Call ok(2-x = -1, "2-x = " & (2-x))
159
160 Call ok(9 Mod 6 = 3, "9 Mod 6 = " & (9 Mod 6))
161 Call ok(11.6 Mod 5.5 = False, "11.6 Mod 5.5 = " & (11.6 Mod 5.5 = 0.6))
162 Call ok(7 Mod 4+2 = 5, "7 Mod 4+2 <> 5")
163 Call ok(getVT(2 mod null) = "VT_NULL", "getVT(2 mod null) = " & getVT(2 mod null))
164 Call ok(getVT(null mod 2) = "VT_NULL", "getVT(null mod 2) = " & getVT(null mod 2))
165 'FIXME: Call ok(empty mod 2 = 0, "empty mod 2 = " & (empty mod 2))
166
167 Call ok(5 \ 2 = 2, "5 \ 2 = " & (5\2))
168 Call ok(4.6 \ 1.5 = 2, "4.6 \ 1.5 = " & (4.6\1.5))
169 Call ok(4.6 \ 1.49 = 5, "4.6 \ 1.49 = " & (4.6\1.49))
170 Call ok(2+3\4 = 2, "2+3\4 = " & (2+3\4))
171
172 Call ok(2*3 = 6, "2*3 = " & (2*3))
173 Call ok(3/2 = 1.5, "3/2 = " & (3/2))
174 Call ok(5\4/2 = 2, "5\4/2 = " & (5\2/1))
175 Call ok(12/3\2 = 2, "12/3\2 = " & (12/3\2))
176
177 Call ok(2^3 = 8, "2^3 = " & (2^3))
178 Call ok(2^3^2 = 64, "2^3^2 = " & (2^3^2))
179 Call ok(-3^2 = 9, "-3^2 = " & (-3^2))
180 Call ok(2*3^2 = 18, "2*3^2 = " & (2*3^2))
181
182 x =_
183     3
184 x _
185     = 3
186
187 x = 3
188
189 if true then y = true : x = y
190 ok x, "x is false"
191
192 x = true : if false then x = false
193 ok x, "x is false, if false called?"
194
195 if not false then x = true
196 ok x, "x is false, if not false not called?"
197
198 if not false then x = "test" : x = true
199 ok x, "x is false, if not false not called?"
200
201 if false then x = y : call ok(false, "if false .. : called")
202
203 if false then x = y : call ok(false, "if false .. : called") else x = "else"
204 Call ok(x = "else", "else not called?")
205
206 if true then x = y else y = x : Call ok(false, "in else?")
207
208 if false then :
209
210 if false then x = y : if true then call ok(false, "embedded if called")
211
212 if false then
213     ok false, "if false called"
214 end if
215
216 x = true
217 if x then
218     x = false
219 end if
220 Call ok(not x, "x is false, if not evaluated?")
221
222 x = false
223 If false Then
224    Call ok(false, "inside if false")
225 Else
226    x = true
227 End If
228 Call ok(x, "else not called?")
229
230 x = false
231 If false Then
232    Call ok(false, "inside if false")
233 ElseIf not True Then
234    Call ok(false, "inside elseif not true")
235 Else
236    x = true
237 End If
238 Call ok(x, "else not called?")
239
240 x = false
241 If false Then
242    Call ok(false, "inside if false")
243    x = 1
244    y = 10+x
245 ElseIf not False Then
246    x = true
247 Else
248    Call ok(false, "inside else not true")
249 End If
250 Call ok(x, "elseif not called?")
251
252 x = false
253 If false Then
254    Call ok(false, "inside if false")
255 ElseIf not False Then
256    x = true
257 End If
258 Call ok(x, "elseif not called?")
259
260 x = false
261 y = false
262 while not (x and y)
263     if x then
264         y = true
265     end if
266     x = true
267 wend
268 call ok((x and y), "x or y is false after while")
269
270 while false
271 wend
272
273 x = false
274 y = false
275 do while not (x and y)
276     if x then
277         y = true
278     end if
279     x = true
280 loop
281 call ok((x and y), "x or y is false after while")
282
283 do while false
284 loop
285
286 do while true
287     exit do
288     ok false, "exit do didn't work"
289 loop
290
291 x = false
292 y = false
293 do until x and y
294     if x then
295         y = true
296     end if
297     x = true
298 loop
299 call ok((x and y), "x or y is false after do until")
300
301 do until true
302 loop
303
304 do until false
305     exit do
306     ok false, "exit do didn't work"
307 loop
308
309 x = false
310 y = false
311 do
312     if x then
313         y = true
314     end if
315     x = true
316 loop until x and y
317 call ok((x and y), "x or y is false after while")
318
319 do
320 loop until true
321
322 do
323     exit do
324     ok false, "exit do didn't work"
325 loop until false
326
327 x = false
328 y = false
329 do
330     if x then
331         y = true
332     end if
333     x = true
334 loop while not (x and y)
335 call ok((x and y), "x or y is false after while")
336
337 do
338 loop while false
339
340 do
341     exit do
342     ok false, "exit do didn't work"
343 loop while true
344
345 y = "for1:"
346 for x = 5 to 8
347     y = y & " " & x
348 next
349 Call ok(y = "for1: 5 6 7 8", "y = " & y)
350
351 y = "for2:"
352 for x = 5 to 8 step 2
353     y = y & " " & x
354 next
355 Call ok(y = "for2: 5 7", "y = " & y)
356
357 y = "for3:"
358 x = 2
359 for x = x+3 to 8
360     y = y & " " & x
361 next
362 Call ok(y = "for3: 5 6 7 8", "y = " & y)
363
364 y = "for4:"
365 for x = 5 to 4
366     y = y & " " & x
367 next
368 Call ok(y = "for4:", "y = " & y)
369
370 y = "for5:"
371 for x = 5 to 3 step true
372     y = y & " " & x
373 next
374 Call ok(y = "for5: 5 4 3", "y = " & y)
375
376 y = "for6:"
377 z = 4
378 for x = 5 to z step 3-4
379     y = y & " " & x
380     z = 0
381 next
382 Call ok(y = "for6: 5 4", "y = " & y)
383
384 y = "for7:"
385 z = 1
386 for x = 5 to 8 step z
387     y = y & " " & x
388     z = 2
389 next
390 Call ok(y = "for7: 5 6 7 8", "y = " & y)
391
392 y = "for8:"
393 for x = 5 to 8
394     y = y & " " & x
395     x = x+1
396 next
397 Call ok(y = "for8: 5 7", "y = " & y)
398
399 for x = 1.5 to 1
400     Call ok(false, "for..to called when unexpected")
401 next
402
403 for x = 1 to 100
404     exit for
405     Call ok(false, "exit for not escaped the loop?")
406 next
407
408 if false then
409 Sub testsub
410     x = true
411 End Sub
412 end if
413
414 x = false
415 Call testsub
416 Call ok(x, "x is false, testsub not called?")
417
418 Sub SubSetTrue(v)
419     Call ok(not v, "v is not true")
420     v = true
421 End Sub
422
423 x = false
424 SubSetTrue x
425 Call ok(x, "x was not set by SubSetTrue")
426
427 SubSetTrue false
428 Call ok(not false, "false is no longer false?")
429
430 Sub SubSetTrue2(ByRef v)
431     Call ok(not v, "v is not true")
432     v = true
433 End Sub
434
435 x = false
436 SubSetTrue2 x
437 Call ok(x, "x was not set by SubSetTrue")
438
439 Sub TestSubArgVal(ByVal v)
440     Call ok(not v, "v is not false")
441     v = true
442     Call ok(v, "v is not true?")
443 End Sub
444
445 x = false
446 Call TestSubArgVal(x)
447 Call ok(not x, "x is true after TestSubArgVal call?")
448
449 Sub TestSubMultiArgs(a,b,c,d,e)
450     Call ok(a=1, "a = " & a)
451     Call ok(b=2, "b = " & b)
452     Call ok(c=3, "c = " & c)
453     Call ok(d=4, "d = " & d)
454     Call ok(e=5, "e = " & e)
455 End Sub
456
457 Sub TestSubExit(ByRef a)
458     If a Then
459         Exit Sub
460     End If
461     Call ok(false, "Exit Sub not called?")
462 End Sub
463
464 Call TestSubExit(true)
465
466 TestSubMultiArgs 1, 2, 3, 4, 5
467 Call TestSubMultiArgs(1, 2, 3, 4, 5)
468
469 Sub TestSubLocalVal
470     x = false
471     Call ok(not x, "local x is not false?")
472     Dim x
473     Dim a,b, c
474 End Sub
475
476 x = true
477 y = true
478 Call TestSubLocalVal
479 Call ok(x, "global x is not true?")
480
481 Public Sub TestPublicSub
482 End Sub
483 Call TestPublicSub
484
485 Private Sub TestPrivateSub
486 End Sub
487 Call TestPrivateSub
488
489 if false then
490 Function testfunc
491     x = true
492 End Function
493 end if
494
495 x = false
496 Call TestFunc
497 Call ok(x, "x is false, testfunc not called?")
498
499 Function FuncSetTrue(v)
500     Call ok(not v, "v is not true")
501     v = true
502 End Function
503
504 x = false
505 FuncSetTrue x
506 Call ok(x, "x was not set by FuncSetTrue")
507
508 FuncSetTrue false
509 Call ok(not false, "false is no longer false?")
510
511 Function FuncSetTrue2(ByRef v)
512     Call ok(not v, "v is not true")
513     v = true
514 End Function
515
516 x = false
517 FuncSetTrue2 x
518 Call ok(x, "x was not set by FuncSetTrue")
519
520 Function TestFuncArgVal(ByVal v)
521     Call ok(not v, "v is not false")
522     v = true
523     Call ok(v, "v is not true?")
524 End Function
525
526 x = false
527 Call TestFuncArgVal(x)
528 Call ok(not x, "x is true after TestFuncArgVal call?")
529
530 Function TestFuncMultiArgs(a,b,c,d,e)
531     Call ok(a=1, "a = " & a)
532     Call ok(b=2, "b = " & b)
533     Call ok(c=3, "c = " & c)
534     Call ok(d=4, "d = " & d)
535     Call ok(e=5, "e = " & e)
536 End Function
537
538 TestFuncMultiArgs 1, 2, 3, 4, 5
539 Call TestFuncMultiArgs(1, 2, 3, 4, 5)
540
541 Function TestFuncLocalVal
542     x = false
543     Call ok(not x, "local x is not false?")
544     Dim x
545 End Function
546
547 x = true
548 y = true
549 Call TestFuncLocalVal
550 Call ok(x, "global x is not true?")
551
552 Function TestFuncExit(ByRef a)
553     If a Then
554         Exit Function
555     End If
556     Call ok(false, "Exit Function not called?")
557 End Function
558
559 Call TestFuncExit(true)
560
561 Sub SubParseTest
562 End Sub : x = false
563 Call SubParseTest
564
565 Function FuncParseTest
566 End Function : x = false
567
568 Function ReturnTrue
569      ReturnTrue = false
570      ReturnTrue = true
571 End Function
572
573 Call ok(ReturnTrue(), "ReturnTrue returned false?")
574
575 Function SetVal(ByRef x, ByVal v)
576     x = v
577     SetVal = x
578     Exit Function
579 End Function
580
581 x = false
582 ok SetVal(x, true), "SetVal returned false?"
583 Call ok(x, "x is not set to true by SetVal?")
584
585 Public Function TestPublicFunc
586 End Function
587 Call TestPublicFunc
588
589 Private Function TestPrivateFunc
590 End Function
591 Call TestPrivateFunc
592
593 ' Stop has an effect only in debugging mode
594 Stop
595
596 set x = testObj
597 Call ok(getVT(x) = "VT_DISPATCH*", "getVT(x=testObj) = " & getVT(x))
598
599 Dim obj
600 Set obj = New EmptyClass
601 Call ok(getVT(obj) = "VT_DISPATCH*", "getVT(obj) = " & getVT(obj))
602
603 Class EmptyClass
604 End Class
605
606 Set x = obj
607 Call ok(getVT(x) = "VT_DISPATCH*", "getVT(x) = " & getVT(x))
608
609 Class TestClass
610     Public publicProp
611
612     Private privateProp
613
614     Public Function publicFunction()
615         privateSub()
616         publicFunction = 4
617     End Function
618
619     Public Property Get gsProp()
620         gsProp = privateProp
621         funcCalled = "gsProp get"
622         exit property
623         Call ok(false, "exit property not returned?")
624     End Property
625
626     Public Default Property Get DefValGet
627         DefValGet = privateProp
628         funcCalled = "GetDefVal"
629     End Property
630
631     Public Property Let DefValGet(x)
632     End Property
633
634     Public publicProp2
635
636     Public Sub publicSub
637     End Sub
638
639     Public Property Let gsProp(val)
640         privateProp = val
641         funcCalled = "gsProp let"
642         exit property
643         Call ok(false, "exit property not returned?")
644     End Property
645
646     Public Property Set gsProp(val)
647         funcCalled = "gsProp set"
648         exit property
649         Call ok(false, "exit property not returned?")
650     End Property
651
652     Public Sub setPrivateProp(x)
653         privateProp = x
654     End Sub
655
656     Function getPrivateProp
657         getPrivateProp = privateProp
658     End Function
659
660     Private Sub privateSub
661     End Sub
662
663     Public Sub Class_Initialize
664         publicProp2 = 2
665         privateProp = true
666     End Sub
667 End Class
668
669 Call testDisp(new testClass)
670
671 Set obj = New TestClass
672
673 Call ok(obj.publicFunction = 4, "obj.publicFunction = " & obj.publicFunction)
674 Call ok(obj.publicFunction() = 4, "obj.publicFunction() = " & obj.publicFunction())
675
676 obj.publicSub()
677 Call obj.publicSub
678 Call obj.publicFunction()
679
680 Call ok(getVT(obj.publicProp) = "VT_EMPTY", "getVT(obj.publicProp) = " & getVT(obj.publicProp))
681 obj.publicProp = 3
682 Call ok(obj.publicProp = 3, "obj.publicProp = " & obj.publicProp)
683 obj.publicProp() = 3
684
685 Call ok(obj.getPrivateProp() = true, "obj.getPrivateProp() = " & obj.getPrivateProp())
686 Call obj.setPrivateProp(6)
687 Call ok(obj.getPrivateProp = 6, "obj.getPrivateProp = " & obj.getPrivateProp)
688
689 Dim funcCalled
690 funcCalled = ""
691 Call ok(obj.gsProp = 6, "obj.gsProp = " & obj.gsProp)
692 Call ok(funcCalled = "gsProp get", "funcCalled = " & funcCalled)
693 obj.gsProp = 3
694 Call ok(funcCalled = "gsProp let", "funcCalled = " & funcCalled)
695 Call ok(obj.getPrivateProp = 3, "obj.getPrivateProp = " & obj.getPrivateProp)
696 Set obj.gsProp = New testclass
697 Call ok(funcCalled = "gsProp set", "funcCalled = " & funcCalled)
698
699 x = obj
700 Call ok(x = 3, "(x = obj) = " & x)
701 Call ok(funcCalled = "GetDefVal", "funcCalled = " & funcCalled)
702 funcCalled = ""
703 Call ok(obj = 3, "(x = obj) = " & obj)
704 Call ok(funcCalled = "GetDefVal", "funcCalled = " & funcCalled)
705
706 Call obj.Class_Initialize
707 Call ok(obj.getPrivateProp() = true, "obj.getPrivateProp() = " & obj.getPrivateProp())
708
709 x = (New testclass).publicProp
710
711 Class TermTest
712     Public Sub Class_Terminate()
713         funcCalled = "terminate"
714     End Sub
715 End Class
716
717 Set obj = New TermTest
718 funcCalled = ""
719 Set obj = Nothing
720 Call ok(funcCalled = "terminate", "funcCalled = " & funcCalled)
721
722 Set obj = New TermTest
723 funcCalled = ""
724 Call obj.Class_Terminate
725 Call ok(funcCalled = "terminate", "funcCalled = " & funcCalled)
726 funcCalled = ""
727 Set obj = Nothing
728 Call ok(funcCalled = "terminate", "funcCalled = " & funcCalled)
729
730 Call (New testclass).publicSub()
731 Call (New testclass).publicSub
732
733 x = "following ':' is correct syntax" :
734 x = "following ':' is correct syntax" :: :
735 :: x = "also correct syntax"
736 rem another ugly way for comments
737 x = "rem as simplestatement" : rem rem comment
738 :
739
740 Set obj = new EmptyClass
741 Set x = obj
742 Set y = new EmptyClass
743
744 Call ok(obj is x, "obj is not x")
745 Call ok(x is obj, "x is not obj")
746 Call ok(not (obj is y), "obj is not y")
747 Call ok(not obj is y, "obj is not y")
748 Call ok(not (x is Nothing), "x is 1")
749 Call ok(Nothing is Nothing, "Nothing is not Nothing")
750 Call ok(x is obj and true, "x is obj and true is false")
751
752 Class TestMe
753     Public Sub Test(MyMe)
754         Call ok(Me is MyMe, "Me is not MyMe")
755     End Sub
756 End Class
757
758 Set obj = New TestMe
759 Call obj.test(obj)
760
761 Call ok(getVT(test) = "VT_DISPATCH", "getVT(test) = " & getVT(test))
762 Call ok(Me is Test, "Me is not Test")
763
764 Const c1 = 1, c2 = 2
765 Call ok(c1 = 1, "c1 = " & c1)
766 Call ok(getVT(c1) = "VT_I2", "getVT(c1) = " & getVT(c1))
767
768 if false then Const conststr = "str"
769 Call ok(conststr = "str", "conststr = " & conststr)
770 Call ok(getVT(conststr) = "VT_BSTR", "getVT(conststr) = " & getVT(conststr))
771 Call ok(conststr = "str", "conststr = " & conststr)
772
773 Sub ConstTestSub
774     Const funcconst = 1
775     Call ok(c1 = 1, "c1 = " & c1)
776     Call ok(funcconst = 1, "funcconst = " & funcconst)
777 End Sub
778
779 Call ConstTestSub
780 Dim funcconst
781
782 reportSuccess()