wininet: Access request object directly in WININET_SetAuthorization.
[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 x=1 else x=2 end if
213
214 if false then
215     ok false, "if false called"
216 end if
217
218 x = true
219 if x then
220     x = false
221 end if
222 Call ok(not x, "x is false, if not evaluated?")
223
224 x = false
225 If false Then
226    Call ok(false, "inside if false")
227 Else
228    x = true
229 End If
230 Call ok(x, "else not called?")
231
232 x = false
233 If false Then
234    Call ok(false, "inside if false")
235 ElseIf not True Then
236    Call ok(false, "inside elseif not true")
237 Else
238    x = true
239 End If
240 Call ok(x, "else not called?")
241
242 x = false
243 If false Then
244    Call ok(false, "inside if false")
245    x = 1
246    y = 10+x
247 ElseIf not False Then
248    x = true
249 Else
250    Call ok(false, "inside else not true")
251 End If
252 Call ok(x, "elseif not called?")
253
254 x = false
255 If false Then
256    Call ok(false, "inside if false")
257 ElseIf not False Then
258    x = true
259 End If
260 Call ok(x, "elseif not called?")
261
262 x = false
263 if 1 then x = true
264 Call ok(x, "if 1 not run?")
265
266 x = false
267 if &h10000& then x = true
268 Call ok(x, "if &h10000& not run?")
269
270 x = false
271 y = false
272 while not (x and y)
273     if x then
274         y = true
275     end if
276     x = true
277 wend
278 call ok((x and y), "x or y is false after while")
279
280 while false
281 wend
282
283 x = false
284 y = false
285 do while not (x and y)
286     if x then
287         y = true
288     end if
289     x = true
290 loop
291 call ok((x and y), "x or y is false after while")
292
293 do while false
294 loop
295
296 do while true
297     exit do
298     ok false, "exit do didn't work"
299 loop
300
301 x = false
302 y = false
303 do until x and y
304     if x then
305         y = true
306     end if
307     x = true
308 loop
309 call ok((x and y), "x or y is false after do until")
310
311 do until true
312 loop
313
314 do until false
315     exit do
316     ok false, "exit do didn't work"
317 loop
318
319 x = false
320 y = false
321 do
322     if x then
323         y = true
324     end if
325     x = true
326 loop until x and y
327 call ok((x and y), "x or y is false after while")
328
329 do
330 loop until true
331
332 do
333     exit do
334     ok false, "exit do didn't work"
335 loop until false
336
337 x = false
338 y = false
339 do
340     if x then
341         y = true
342     end if
343     x = true
344 loop while not (x and y)
345 call ok((x and y), "x or y is false after while")
346
347 do
348 loop while false
349
350 do
351     exit do
352     ok false, "exit do didn't work"
353 loop while true
354
355 y = "for1:"
356 for x = 5 to 8
357     y = y & " " & x
358 next
359 Call ok(y = "for1: 5 6 7 8", "y = " & y)
360
361 y = "for2:"
362 for x = 5 to 8 step 2
363     y = y & " " & x
364 next
365 Call ok(y = "for2: 5 7", "y = " & y)
366
367 y = "for3:"
368 x = 2
369 for x = x+3 to 8
370     y = y & " " & x
371 next
372 Call ok(y = "for3: 5 6 7 8", "y = " & y)
373
374 y = "for4:"
375 for x = 5 to 4
376     y = y & " " & x
377 next
378 Call ok(y = "for4:", "y = " & y)
379
380 y = "for5:"
381 for x = 5 to 3 step true
382     y = y & " " & x
383 next
384 Call ok(y = "for5: 5 4 3", "y = " & y)
385
386 y = "for6:"
387 z = 4
388 for x = 5 to z step 3-4
389     y = y & " " & x
390     z = 0
391 next
392 Call ok(y = "for6: 5 4", "y = " & y)
393
394 y = "for7:"
395 z = 1
396 for x = 5 to 8 step z
397     y = y & " " & x
398     z = 2
399 next
400 Call ok(y = "for7: 5 6 7 8", "y = " & y)
401
402 y = "for8:"
403 for x = 5 to 8
404     y = y & " " & x
405     x = x+1
406 next
407 Call ok(y = "for8: 5 7", "y = " & y)
408
409 for x = 1.5 to 1
410     Call ok(false, "for..to called when unexpected")
411 next
412
413 for x = 1 to 100
414     exit for
415     Call ok(false, "exit for not escaped the loop?")
416 next
417
418 if false then
419 Sub testsub
420     x = true
421 End Sub
422 end if
423
424 x = false
425 Call testsub
426 Call ok(x, "x is false, testsub not called?")
427
428 Sub SubSetTrue(v)
429     Call ok(not v, "v is not true")
430     v = true
431 End Sub
432
433 x = false
434 SubSetTrue x
435 Call ok(x, "x was not set by SubSetTrue")
436
437 SubSetTrue false
438 Call ok(not false, "false is no longer false?")
439
440 Sub SubSetTrue2(ByRef v)
441     Call ok(not v, "v is not true")
442     v = true
443 End Sub
444
445 x = false
446 SubSetTrue2 x
447 Call ok(x, "x was not set by SubSetTrue")
448
449 Sub TestSubArgVal(ByVal v)
450     Call ok(not v, "v is not false")
451     v = true
452     Call ok(v, "v is not true?")
453 End Sub
454
455 x = false
456 Call TestSubArgVal(x)
457 Call ok(not x, "x is true after TestSubArgVal call?")
458
459 Sub TestSubMultiArgs(a,b,c,d,e)
460     Call ok(a=1, "a = " & a)
461     Call ok(b=2, "b = " & b)
462     Call ok(c=3, "c = " & c)
463     Call ok(d=4, "d = " & d)
464     Call ok(e=5, "e = " & e)
465 End Sub
466
467 Sub TestSubExit(ByRef a)
468     If a Then
469         Exit Sub
470     End If
471     Call ok(false, "Exit Sub not called?")
472 End Sub
473
474 Call TestSubExit(true)
475
476 TestSubMultiArgs 1, 2, 3, 4, 5
477 Call TestSubMultiArgs(1, 2, 3, 4, 5)
478
479 Sub TestSubLocalVal
480     x = false
481     Call ok(not x, "local x is not false?")
482     Dim x
483     Dim a,b, c
484 End Sub
485
486 x = true
487 y = true
488 Call TestSubLocalVal
489 Call ok(x, "global x is not true?")
490
491 Public Sub TestPublicSub
492 End Sub
493 Call TestPublicSub
494
495 Private Sub TestPrivateSub
496 End Sub
497 Call TestPrivateSub
498
499 if false then
500 Function testfunc
501     x = true
502 End Function
503 end if
504
505 x = false
506 Call TestFunc
507 Call ok(x, "x is false, testfunc not called?")
508
509 Function FuncSetTrue(v)
510     Call ok(not v, "v is not true")
511     v = true
512 End Function
513
514 x = false
515 FuncSetTrue x
516 Call ok(x, "x was not set by FuncSetTrue")
517
518 FuncSetTrue false
519 Call ok(not false, "false is no longer false?")
520
521 Function FuncSetTrue2(ByRef v)
522     Call ok(not v, "v is not true")
523     v = true
524 End Function
525
526 x = false
527 FuncSetTrue2 x
528 Call ok(x, "x was not set by FuncSetTrue")
529
530 Function TestFuncArgVal(ByVal v)
531     Call ok(not v, "v is not false")
532     v = true
533     Call ok(v, "v is not true?")
534 End Function
535
536 x = false
537 Call TestFuncArgVal(x)
538 Call ok(not x, "x is true after TestFuncArgVal call?")
539
540 Function TestFuncMultiArgs(a,b,c,d,e)
541     Call ok(a=1, "a = " & a)
542     Call ok(b=2, "b = " & b)
543     Call ok(c=3, "c = " & c)
544     Call ok(d=4, "d = " & d)
545     Call ok(e=5, "e = " & e)
546 End Function
547
548 TestFuncMultiArgs 1, 2, 3, 4, 5
549 Call TestFuncMultiArgs(1, 2, 3, 4, 5)
550
551 Function TestFuncLocalVal
552     x = false
553     Call ok(not x, "local x is not false?")
554     Dim x
555 End Function
556
557 x = true
558 y = true
559 Call TestFuncLocalVal
560 Call ok(x, "global x is not true?")
561
562 Function TestFuncExit(ByRef a)
563     If a Then
564         Exit Function
565     End If
566     Call ok(false, "Exit Function not called?")
567 End Function
568
569 Call TestFuncExit(true)
570
571 Sub SubParseTest
572 End Sub : x = false
573 Call SubParseTest
574
575 Function FuncParseTest
576 End Function : x = false
577
578 Function ReturnTrue
579      ReturnTrue = false
580      ReturnTrue = true
581 End Function
582
583 Call ok(ReturnTrue(), "ReturnTrue returned false?")
584
585 Function SetVal(ByRef x, ByVal v)
586     x = v
587     SetVal = x
588     Exit Function
589 End Function
590
591 x = false
592 ok SetVal(x, true), "SetVal returned false?"
593 Call ok(x, "x is not set to true by SetVal?")
594
595 Public Function TestPublicFunc
596 End Function
597 Call TestPublicFunc
598
599 Private Function TestPrivateFunc
600 End Function
601 Call TestPrivateFunc
602
603 ' Stop has an effect only in debugging mode
604 Stop
605
606 set x = testObj
607 Call ok(getVT(x) = "VT_DISPATCH*", "getVT(x=testObj) = " & getVT(x))
608
609 Dim obj
610 Set obj = New EmptyClass
611 Call ok(getVT(obj) = "VT_DISPATCH*", "getVT(obj) = " & getVT(obj))
612
613 Class EmptyClass
614 End Class
615
616 Set x = obj
617 Call ok(getVT(x) = "VT_DISPATCH*", "getVT(x) = " & getVT(x))
618
619 Class TestClass
620     Public publicProp
621
622     Private privateProp
623
624     Public Function publicFunction()
625         privateSub()
626         publicFunction = 4
627     End Function
628
629     Public Property Get gsProp()
630         gsProp = privateProp
631         funcCalled = "gsProp get"
632         exit property
633         Call ok(false, "exit property not returned?")
634     End Property
635
636     Public Default Property Get DefValGet
637         DefValGet = privateProp
638         funcCalled = "GetDefVal"
639     End Property
640
641     Public Property Let DefValGet(x)
642     End Property
643
644     Public publicProp2
645
646     Public Sub publicSub
647     End Sub
648
649     Public Property Let gsProp(val)
650         privateProp = val
651         funcCalled = "gsProp let"
652         exit property
653         Call ok(false, "exit property not returned?")
654     End Property
655
656     Public Property Set gsProp(val)
657         funcCalled = "gsProp set"
658         exit property
659         Call ok(false, "exit property not returned?")
660     End Property
661
662     Public Sub setPrivateProp(x)
663         privateProp = x
664     End Sub
665
666     Function getPrivateProp
667         getPrivateProp = privateProp
668     End Function
669
670     Private Sub privateSub
671     End Sub
672
673     Public Sub Class_Initialize
674         publicProp2 = 2
675         privateProp = true
676     End Sub
677 End Class
678
679 Call testDisp(new testClass)
680
681 Set obj = New TestClass
682
683 Call ok(obj.publicFunction = 4, "obj.publicFunction = " & obj.publicFunction)
684 Call ok(obj.publicFunction() = 4, "obj.publicFunction() = " & obj.publicFunction())
685
686 obj.publicSub()
687 Call obj.publicSub
688 Call obj.publicFunction()
689
690 Call ok(getVT(obj.publicProp) = "VT_EMPTY", "getVT(obj.publicProp) = " & getVT(obj.publicProp))
691 obj.publicProp = 3
692 Call ok(obj.publicProp = 3, "obj.publicProp = " & obj.publicProp)
693 obj.publicProp() = 3
694
695 Call ok(obj.getPrivateProp() = true, "obj.getPrivateProp() = " & obj.getPrivateProp())
696 Call obj.setPrivateProp(6)
697 Call ok(obj.getPrivateProp = 6, "obj.getPrivateProp = " & obj.getPrivateProp)
698
699 Dim funcCalled
700 funcCalled = ""
701 Call ok(obj.gsProp = 6, "obj.gsProp = " & obj.gsProp)
702 Call ok(funcCalled = "gsProp get", "funcCalled = " & funcCalled)
703 obj.gsProp = 3
704 Call ok(funcCalled = "gsProp let", "funcCalled = " & funcCalled)
705 Call ok(obj.getPrivateProp = 3, "obj.getPrivateProp = " & obj.getPrivateProp)
706 Set obj.gsProp = New testclass
707 Call ok(funcCalled = "gsProp set", "funcCalled = " & funcCalled)
708
709 x = obj
710 Call ok(x = 3, "(x = obj) = " & x)
711 Call ok(funcCalled = "GetDefVal", "funcCalled = " & funcCalled)
712 funcCalled = ""
713 Call ok(obj = 3, "(x = obj) = " & obj)
714 Call ok(funcCalled = "GetDefVal", "funcCalled = " & funcCalled)
715
716 Call obj.Class_Initialize
717 Call ok(obj.getPrivateProp() = true, "obj.getPrivateProp() = " & obj.getPrivateProp())
718
719 x = (New testclass).publicProp
720
721 Class TermTest
722     Public Sub Class_Terminate()
723         funcCalled = "terminate"
724     End Sub
725 End Class
726
727 Set obj = New TermTest
728 funcCalled = ""
729 Set obj = Nothing
730 Call ok(funcCalled = "terminate", "funcCalled = " & funcCalled)
731
732 Set obj = New TermTest
733 funcCalled = ""
734 Call obj.Class_Terminate
735 Call ok(funcCalled = "terminate", "funcCalled = " & funcCalled)
736 funcCalled = ""
737 Set obj = Nothing
738 Call ok(funcCalled = "terminate", "funcCalled = " & funcCalled)
739
740 Call (New testclass).publicSub()
741 Call (New testclass).publicSub
742
743 x = "following ':' is correct syntax" :
744 x = "following ':' is correct syntax" :: :
745 :: x = "also correct syntax"
746 rem another ugly way for comments
747 x = "rem as simplestatement" : rem rem comment
748 :
749
750 Set obj = new EmptyClass
751 Set x = obj
752 Set y = new EmptyClass
753
754 Call ok(obj is x, "obj is not x")
755 Call ok(x is obj, "x is not obj")
756 Call ok(not (obj is y), "obj is not y")
757 Call ok(not obj is y, "obj is not y")
758 Call ok(not (x is Nothing), "x is 1")
759 Call ok(Nothing is Nothing, "Nothing is not Nothing")
760 Call ok(x is obj and true, "x is obj and true is false")
761
762 Class TestMe
763     Public Sub Test(MyMe)
764         Call ok(Me is MyMe, "Me is not MyMe")
765     End Sub
766 End Class
767
768 Set obj = New TestMe
769 Call obj.test(obj)
770
771 Call ok(getVT(test) = "VT_DISPATCH", "getVT(test) = " & getVT(test))
772 Call ok(Me is Test, "Me is not Test")
773
774 Const c1 = 1, c2 = 2
775 Call ok(c1 = 1, "c1 = " & c1)
776 Call ok(getVT(c1) = "VT_I2", "getVT(c1) = " & getVT(c1))
777
778 if false then Const conststr = "str"
779 Call ok(conststr = "str", "conststr = " & conststr)
780 Call ok(getVT(conststr) = "VT_BSTR", "getVT(conststr) = " & getVT(conststr))
781 Call ok(conststr = "str", "conststr = " & conststr)
782
783 Sub ConstTestSub
784     Const funcconst = 1
785     Call ok(c1 = 1, "c1 = " & c1)
786     Call ok(funcconst = 1, "funcconst = " & funcconst)
787 End Sub
788
789 Call ConstTestSub
790 Dim funcconst
791
792 ' Property may be used as an identifier (although it's a keyword)
793 Sub TestProperty
794     Dim Property
795     PROPERTY = true
796     Call ok(property, "property = " & property)
797
798     for property = 1 to 2
799     next
800 End Sub
801
802 Call TestProperty
803
804 Class Property
805     Public Sub Property()
806     End Sub
807
808     Sub Test(byref property)
809     End Sub
810 End Class
811
812 Class Property2
813     Function Property()
814     End Function
815
816
817     Sub Test(property)
818     End Sub
819
820     Sub Test2(byval property)
821     End Sub
822 End Class
823
824 reportSuccess()