ntoskrnl.exe: Add KeQueryActiveProcessorCountEx() function.
[wine.git] / dlls / vbscript / tests / lang.vbs
blobc50b8bbe5981ddd3119b9a62bf46e6dd3ada1d98
2 ' Copyright 2011 Jacek Caban for CodeWeavers
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.
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.
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
19 OPTION EXPLICIT : : DIM W
21 dim x, y, z, e
22 Dim obj
24 call ok(true, "true is not true?")
25 ok true, "true is not true?"
26 call ok((true), "true is not true?")
28 ok not false, "not false but not true?"
29 ok not not true, "not not true but not true?"
31 Call ok(true = true, "true = true is false")
32 Call ok(false = false, "false = false is false")
33 Call ok(not (true = false), "true = false is true")
34 Call ok("x" = "x", """x"" = ""x"" is false")
35 Call ok(empty = empty, "empty = empty is false")
36 Call ok(empty = "", "empty = """" is false")
37 Call ok(0 = 0.0, "0 <> 0.0")
38 Call ok(16 = &h10&, "16 <> &h10&")
39 Call ok(010 = 10, "010 <> 10")
40 Call ok(10. = 10, "10. <> 10")
41 Call ok(&hffFFffFF& = -1, "&hffFFffFF& <> -1")
42 Call ok(&hffFFffFF& = -1, "&hffFFffFF& <> -1")
43 Call ok(34e5 = 3400000, "34e5 <> 3400000")
44 Call ok(34e+5 = 3400000, "34e+5 <> 3400000")
45 Call ok(56.789e5 = 5678900, "56.789e5 = 5678900")
46 Call ok(56.789e-2 = 0.56789, "56.789e-2 <> 0.56789")
47 Call ok(1e-94938484 = 0, "1e-... <> 0")
48 Call ok(34e0 = 34, "34e0 <> 34")
49 Call ok(34E1 = 340, "34E0 <> 340")
50 Call ok(--1 = 1, "--1 = " & --1)
51 Call ok(-empty = 0, "-empty = " & (-empty))
52 Call ok(true = -1, "! true = -1")
53 Call ok(false = 0, "false <> 0")
54 Call ok(&hff = 255, "&hff <> 255")
55 Call ok(&Hff = 255, "&Hff <> 255")
56 Call ok(&hffff = -1, "&hffff <> -1")
57 Call ok(&hfffe = -2, "&hfffe <> -2")
58 Call ok(&hffff& = 65535, "&hffff& <> -1")
59 Call ok(&hfffe& = 65534, "&hfffe& <> -2")
60 Call ok(&hffffffff& = -1, "&hffffffff& <> -1")
62 W = 5
63 Call ok(W = 5, "W = " & W & " expected " & 5)
65 x = "xx"
66 Call ok(x = "xx", "x = " & x & " expected ""xx""")
68 Call ok(true <> false, "true <> false is false")
69 Call ok(not (true <> true), "true <> true is true")
70 Call ok(not ("x" <> "x"), """x"" <> ""x"" is true")
71 Call ok(not (empty <> empty), "empty <> empty is true")
72 Call ok(x <> "x", "x = ""x""")
73 Call ok("true" <> true, """true"" = true is true")
75 Call ok("" = true = false, """"" = true = false is false")
76 Call ok(not(false = true = ""), "false = true = """" is true")
77 Call ok(not (false = false <> false = false), "false = false <> false = false is true")
78 Call ok(not ("" <> false = false), """"" <> false = false is true")
80 Call ok(getVT(false) = "VT_BOOL", "getVT(false) is not VT_BOOL")
81 Call ok(getVT(true) = "VT_BOOL", "getVT(true) is not VT_BOOL")
82 Call ok(getVT("") = "VT_BSTR", "getVT("""") is not VT_BSTR")
83 Call ok(getVT("test") = "VT_BSTR", "getVT(""test"") is not VT_BSTR")
84 Call ok(getVT(Empty) = "VT_EMPTY", "getVT(Empty) is not VT_EMPTY")
85 Call ok(getVT(null) = "VT_NULL", "getVT(null) is not VT_NULL")
86 Call ok(getVT(0) = "VT_I2", "getVT(0) is not VT_I2")
87 Call ok(getVT(1) = "VT_I2", "getVT(1) is not VT_I2")
88 Call ok(getVT(0.5) = "VT_R8", "getVT(0.5) is not VT_R8")
89 Call ok(getVT(0.0) = "VT_R8", "getVT(0.0) is not VT_R8")
90 Call ok(getVT(2147483647) = "VT_I4", "getVT(2147483647) is not VT_I4")
91 Call ok(getVT(2147483648) = "VT_R8", "getVT(2147483648) is not VT_R8")
92 Call ok(getVT(&h10&) = "VT_I2", "getVT(&h10&) is not VT_I2")
93 Call ok(getVT(&h10000&) = "VT_I4", "getVT(&h10000&) is not VT_I4")
94 Call ok(getVT(&H10000&) = "VT_I4", "getVT(&H10000&) is not VT_I4")
95 Call ok(getVT(&hffFFffFF&) = "VT_I2", "getVT(&hffFFffFF&) is not VT_I2")
96 Call ok(getVT(&hffFFffFE&) = "VT_I2", "getVT(&hffFFffFE &) is not VT_I2")
97 Call ok(getVT(&hffF&) = "VT_I2", "getVT(&hffFF&) is not VT_I2")
98 Call ok(getVT(&hffFF&) = "VT_I4", "getVT(&hffFF&) is not VT_I4")
99 Call ok(getVT(1e2) = "VT_R8", "getVT(1e2) is not VT_R8")
100 Call ok(getVT(1e0) = "VT_R8", "getVT(1e0) is not VT_R8")
101 Call ok(getVT(0.1e2) = "VT_R8", "getVT(0.1e2) is not VT_R8")
102 Call ok(getVT(1 & 100000) = "VT_BSTR", "getVT(1 & 100000) is not VT_BSTR")
103 Call ok(getVT(-empty) = "VT_I2", "getVT(-empty) = " & getVT(-empty))
104 Call ok(getVT(-null) = "VT_NULL", "getVT(-null) = " & getVT(-null))
105 Call ok(getVT(y) = "VT_EMPTY*", "getVT(y) = " & getVT(y))
106 Call ok(getVT(nothing) = "VT_DISPATCH", "getVT(nothing) = " & getVT(nothing))
107 set x = nothing
108 Call ok(getVT(x) = "VT_DISPATCH*", "getVT(x=nothing) = " & getVT(x))
109 x = true
110 Call ok(getVT(x) = "VT_BOOL*", "getVT(x) = " & getVT(x))
111 Call ok(getVT(false or true) = "VT_BOOL", "getVT(false) is not VT_BOOL")
112 x = "x"
113 Call ok(getVT(x) = "VT_BSTR*", "getVT(x) is not VT_BSTR*")
114 x = 0.0
115 Call ok(getVT(x) = "VT_R8*", "getVT(x) = " & getVT(x))
117 Call ok(isNullDisp(nothing), "nothing is not nulldisp?")
119 x = "xx"
120 Call ok("ab" & "cd" = "abcd", """ab"" & ""cd"" <> ""abcd""")
121 Call ok("ab " & null = "ab ", """ab"" & null = " & ("ab " & null))
122 Call ok("ab " & empty = "ab ", """ab"" & empty = " & ("ab " & empty))
123 Call ok(1 & 100000 = "1100000", "1 & 100000 = " & (1 & 100000))
124 Call ok("ab" & x = "abxx", """ab"" & x = " & ("ab"&x))
126 if(isEnglishLang) then
127 Call ok("" & true = "True", """"" & true = " & true)
128 Call ok(true & false = "TrueFalse", "true & false = " & (true & false))
129 end if
131 call ok(true and true, "true and true is not true")
132 call ok(true and not false, "true and not false is not true")
133 call ok(not (false and true), "not (false and true) is not true")
134 call ok(getVT(null and true) = "VT_NULL", "getVT(null and true) = " & getVT(null and true))
136 call ok(false or true, "false or uie is false?")
137 call ok(not (false or false), "false or false is not false?")
138 call ok(false and false or true, "false and false or true is false?")
139 call ok(true or false and false, "true or false and false is false?")
140 call ok(null or true, "null or true is false")
142 call ok(true xor false, "true xor false is false?")
143 call ok(not (false xor false), "false xor false is true?")
144 call ok(not (true or false xor true), "true or false xor true is true?")
145 call ok(not (true xor false or true), "true xor false or true is true?")
147 call ok(false eqv false, "false does not equal false?")
148 call ok(not (false eqv true), "false equals true?")
149 call ok(getVT(false eqv null) = "VT_NULL", "getVT(false eqv null) = " & getVT(false eqv null))
151 call ok(true imp true, "true does not imp true?")
152 call ok(false imp false, "false does not imp false?")
153 call ok(not (true imp false), "true imp false?")
154 call ok(false imp null, "false imp null is false?")
156 Call ok(2 >= 1, "! 2 >= 1")
157 Call ok(2 >= 2, "! 2 >= 2")
158 Call ok(not(true >= 2), "true >= 2 ?")
159 Call ok(2 > 1, "! 2 > 1")
160 Call ok(false > true, "! false < true")
161 Call ok(0 > true, "! 0 > true")
162 Call ok(not (true > 0), "true > 0")
163 Call ok(not (0 > 1 = 1), "0 > 1 = 1")
164 Call ok(1 < 2, "! 1 < 2")
165 Call ok(1 = 1 < 0, "! 1 = 1 < 0")
166 Call ok(1 <= 2, "! 1 <= 2")
167 Call ok(2 <= 2, "! 2 <= 2")
169 Call ok(isNull(0 = null), "'(0 = null)' is not null")
170 Call ok(isNull(null = 1), "'(null = 1)' is not null")
171 Call ok(isNull(0 > null), "'(0 > null)' is not null")
172 Call ok(isNull(null > 1), "'(null > 1)' is not null")
173 Call ok(isNull(0 < null), "'(0 < null)' is not null")
174 Call ok(isNull(null < 1), "'(null < 1)' is not null")
175 Call ok(isNull(0 <> null), "'(0 <> null)' is not null")
176 Call ok(isNull(null <> 1), "'(null <> 1)' is not null")
177 Call ok(isNull(0 >= null), "'(0 >= null)' is not null")
178 Call ok(isNull(null >= 1), "'(null >= 1)' is not null")
179 Call ok(isNull(0 <= null), "'(0 <= null)' is not null")
180 Call ok(isNull(null <= 1), "'(null <= 1)' is not null")
182 x = 3
183 Call ok(2+2 = 4, "2+2 = " & (2+2))
184 Call ok(false + 6 + true = 5, "false + 6 + true <> 5")
185 Call ok(getVT(2+null) = "VT_NULL", "getVT(2+null) = " & getVT(2+null))
186 Call ok(2+empty = 2, "2+empty = " & (2+empty))
187 Call ok(x+x = 6, "x+x = " & (x+x))
189 Call ok(5-1 = 4, "5-1 = " & (5-1))
190 Call ok(3+5-true = 9, "3+5-true <> 9")
191 Call ok(getVT(2-null) = "VT_NULL", "getVT(2-null) = " & getVT(2-null))
192 Call ok(2-empty = 2, "2-empty = " & (2-empty))
193 Call ok(2-x = -1, "2-x = " & (2-x))
195 Call ok(9 Mod 6 = 3, "9 Mod 6 = " & (9 Mod 6))
196 Call ok(11.6 Mod 5.5 = False, "11.6 Mod 5.5 = " & (11.6 Mod 5.5 = 0.6))
197 Call ok(7 Mod 4+2 = 5, "7 Mod 4+2 <> 5")
198 Call ok(getVT(2 mod null) = "VT_NULL", "getVT(2 mod null) = " & getVT(2 mod null))
199 Call ok(getVT(null mod 2) = "VT_NULL", "getVT(null mod 2) = " & getVT(null mod 2))
200 'FIXME: Call ok(empty mod 2 = 0, "empty mod 2 = " & (empty mod 2))
202 Call ok(5 \ 2 = 2, "5 \ 2 = " & (5\2))
203 Call ok(4.6 \ 1.5 = 2, "4.6 \ 1.5 = " & (4.6\1.5))
204 Call ok(4.6 \ 1.49 = 5, "4.6 \ 1.49 = " & (4.6\1.49))
205 Call ok(2+3\4 = 2, "2+3\4 = " & (2+3\4))
207 Call ok(2*3 = 6, "2*3 = " & (2*3))
208 Call ok(3/2 = 1.5, "3/2 = " & (3/2))
209 Call ok(5\4/2 = 2, "5\4/2 = " & (5\2/1))
210 Call ok(12/3\2 = 2, "12/3\2 = " & (12/3\2))
211 Call ok(5/1000000 = 0.000005, "5/1000000 = " & (5/1000000))
213 Call ok(2^3 = 8, "2^3 = " & (2^3))
214 Call ok(2^3^2 = 64, "2^3^2 = " & (2^3^2))
215 Call ok(-3^2 = 9, "-3^2 = " & (-3^2))
216 Call ok(2*3^2 = 18, "2*3^2 = " & (2*3^2))
218 x =_
223 x = 3
225 if true then y = true : x = y
226 ok x, "x is false"
228 x = true : if false then x = false
229 ok x, "x is false, if false called?"
231 if not false then x = true
232 ok x, "x is false, if not false not called?"
234 if not false then x = "test" : x = true
235 ok x, "x is false, if not false not called?"
237 if false then x = y : call ok(false, "if false .. : called")
239 if false then x = y : call ok(false, "if false .. : called") else x = "else"
240 Call ok(x = "else", "else not called?")
242 if true then x = y else y = x : Call ok(false, "in else?")
244 if false then :
246 if false then x = y : if true then call ok(false, "embedded if called")
248 if false then x=1 else x=2 end if
249 if true then x=1 end if
251 x = false
252 if false then x = true : x = true
253 Call ok(x = false, "x <> false")
255 if false then
256 ok false, "if false called"
257 end if
259 x = true
260 if x then
261 x = false
262 end if
263 Call ok(not x, "x is false, if not evaluated?")
265 x = false
266 If false Then
267 Call ok(false, "inside if false")
268 Else
269 x = true
270 End If
271 Call ok(x, "else not called?")
273 x = false
274 If false Then
275 Call ok(false, "inside if false")
276 ElseIf not True Then
277 Call ok(false, "inside elseif not true")
278 Else
279 x = true
280 End If
281 Call ok(x, "else not called?")
283 x = false
284 If false Then
285 Call ok(false, "inside if false")
286 x = 1
287 y = 10+x
288 ElseIf not False Then
289 x = true
290 Else
291 Call ok(false, "inside else not true")
292 End If
293 Call ok(x, "elseif not called?")
295 x = false
296 If false Then
297 Call ok(false, "inside if false")
298 ElseIf not False Then
299 x = true
300 End If
301 Call ok(x, "elseif not called?")
303 x = false
304 if 1 then x = true
305 Call ok(x, "if 1 not run?")
307 x = false
308 if &h10000& then x = true
309 Call ok(x, "if &h10000& not run?")
311 x = false
312 y = false
313 while not (x and y)
314 if x then
315 y = true
316 end if
317 x = true
318 wend
319 call ok((x and y), "x or y is false after while")
321 if false then
322 ' empty body
323 end if
325 if false then
326 x = false
327 elseif true then
328 ' empty body
329 end if
331 if false then
332 x = false
333 else
334 ' empty body
335 end if
337 while false
338 wend
340 if empty then
341 ok false, "if empty executed"
342 end if
344 while empty
345 ok false, "while empty executed"
346 wend
348 x = 0
349 WHILE x < 3 : x = x + 1
350 Wend
351 Call ok(x = 3, "x not equal to 3")
353 z = 2
354 while z > -4 :
357 z = z -2
358 wend
360 x = false
361 y = false
362 do while not (x and y)
363 if x then
364 y = true
365 end if
366 x = true
367 loop
368 call ok((x and y), "x or y is false after while")
370 do while false
371 loop
373 do while true
374 exit do
375 ok false, "exit do didn't work"
376 loop
378 x = 0
379 Do While x < 2 : x = x + 1
380 Loop
381 Call ok(x = 2, "x not equal to 2")
383 x = 0
384 Do While x >= -2 :
385 x = x - 1
386 Loop
387 Call ok(x = -3, "x not equal to -3")
389 x = false
390 y = false
391 do until x and y
392 if x then
393 y = true
394 end if
395 x = true
396 loop
397 call ok((x and y), "x or y is false after do until")
399 do until true
400 loop
402 do until false
403 exit do
404 ok false, "exit do didn't work"
405 loop
407 x = 0
408 Do: :: x = x + 2
409 Loop Until x = 4
410 Call ok(x = 4, "x not equal to 4")
412 x = 5
413 Do: :
415 : x = x * 2
416 Loop Until x = 40
417 Call ok(x = 40, "x not equal to 40")
420 x = false
422 if x then exit do
423 x = true
424 loop
425 call ok(x, "x is false after do..loop?")
427 x = 0
428 Do :If x = 6 Then
429 Exit Do
430 End If
431 x = x + 3
432 Loop
433 Call ok(x = 6, "x not equal to 6")
435 x = false
436 y = false
438 if x then
439 y = true
440 end if
441 x = true
442 loop until x and y
443 call ok((x and y), "x or y is false after while")
446 loop until true
449 exit do
450 ok false, "exit do didn't work"
451 loop until false
453 x = false
454 y = false
456 if x then
457 y = true
458 end if
459 x = true
460 loop while not (x and y)
461 call ok((x and y), "x or y is false after while")
464 loop while false
467 exit do
468 ok false, "exit do didn't work"
469 loop while true
471 y = "for1:"
472 for x = 5 to 8
473 y = y & " " & x
474 next
475 Call ok(y = "for1: 5 6 7 8", "y = " & y)
477 y = "for2:"
478 for x = 5 to 8 step 2
479 y = y & " " & x
480 next
481 Call ok(y = "for2: 5 7", "y = " & y)
483 y = "for3:"
484 x = 2
485 for x = x+3 to 8
486 y = y & " " & x
487 next
488 Call ok(y = "for3: 5 6 7 8", "y = " & y)
490 y = "for4:"
491 for x = 5 to 4
492 y = y & " " & x
493 next
494 Call ok(y = "for4:", "y = " & y)
496 y = "for5:"
497 for x = 5 to 3 step true
498 y = y & " " & x
499 next
500 Call ok(y = "for5: 5 4 3", "y = " & y)
502 y = "for6:"
503 z = 4
504 for x = 5 to z step 3-4
505 y = y & " " & x
506 z = 0
507 next
508 Call ok(y = "for6: 5 4", "y = " & y)
510 y = "for7:"
511 z = 1
512 for x = 5 to 8 step z
513 y = y & " " & x
514 z = 2
515 next
516 Call ok(y = "for7: 5 6 7 8", "y = " & y)
518 z = 0
519 For x = 10 To 18 Step 2 : : z = z + 1
520 Next
521 Call ok(z = 5, "z not equal to 5")
523 y = "for8:"
524 for x = 5 to 8
525 y = y & " " & x
526 x = x+1
527 next
528 Call ok(y = "for8: 5 7", "y = " & y)
530 for x = 1.5 to 1
531 Call ok(false, "for..to called when unexpected")
532 next
534 for x = 1 to 100
535 exit for
536 Call ok(false, "exit for not escaped the loop?")
537 next
539 for x = 1 to 5 :
541 : :exit for
542 Call ok(false, "exit for not escaped the loop?")
543 next
545 do while true
546 for x = 1 to 100
547 exit do
548 next
549 loop
551 if null then call ok(false, "if null evaluated")
553 while null
554 call ok(false, "while null evaluated")
555 wend
557 Call collectionObj.reset()
558 y = 0
559 for each x in collectionObj :
561 :y = y + 3
562 next
563 Call ok(y = 9, "y = " & y)
565 Call collectionObj.reset()
566 y = 0
567 x = 10
568 z = 0
569 for each x in collectionObj : z = z + 2
570 y = y+1
571 Call ok(x = y, "x <> y")
572 next
573 Call ok(y = 3, "y = " & y)
574 Call ok(z = 6, "z = " & z)
575 Call ok(getVT(x) = "VT_EMPTY*", "getVT(x) = " & getVT(x))
577 Call collectionObj.reset()
578 y = false
579 for each x in collectionObj
580 if x = 2 then exit for
581 y = 1
582 next
583 Call ok(y = 1, "y = " & y)
584 Call ok(x = 2, "x = " & x)
586 Set obj = collectionObj
587 Call obj.reset()
588 y = 0
589 x = 10
590 for each x in obj
591 y = y+1
592 Call ok(x = y, "x <> y")
593 next
594 Call ok(y = 3, "y = " & y)
595 Call ok(getVT(x) = "VT_EMPTY*", "getVT(x) = " & getVT(x))
597 x = false
598 select case 3
599 case 2
600 Call ok(false, "unexpected case")
601 case 2
602 Call ok(false, "unexpected case")
603 case 4
604 Call ok(false, "unexpected case")
605 case "test"
606 case "another case"
607 Call ok(false, "unexpected case")
608 case 0, false, 2+1, 10
609 x = true
610 case ok(false, "unexpected case")
611 Call ok(false, "unexpected case")
612 case else
613 Call ok(false, "unexpected case")
614 end select
615 Call ok(x, "wrong case")
617 x = false
618 select case 3
619 case 3
620 x = true
621 end select
622 Call ok(x, "wrong case")
624 x = false
625 select case 2+2
626 case 3
627 Call ok(false, "unexpected case")
628 case else
629 x = true
630 end select
631 Call ok(x, "wrong case")
633 y = "3"
634 x = false
635 select case y
636 case "3"
637 x = true
638 case 3
639 Call ok(false, "unexpected case")
640 end select
641 Call ok(x, "wrong case")
643 select case 0
644 case 1
645 Call ok(false, "unexpected case")
646 case "2"
647 Call ok(false, "unexpected case")
648 end select
650 select case 0
651 end select
653 x = false
654 select case 2
655 case 3,1,2,4: x = true
656 case 5,6,7
657 Call ok(false, "unexpected case")
658 end select
659 Call ok(x, "wrong case")
661 x = false
662 select case 2: case 5,6,7: Call ok(false, "unexpected case")
663 case 2,1,2,4
664 x = true
665 case else: Call ok(false, "unexpected case else")
666 end select
667 Call ok(x, "wrong case")
669 x = False
670 select case 1 :
672 :case 3, 4 :
675 case 5
677 Call ok(false, "unexpected case") :
678 Case Else:
680 x = True
681 end select
682 Call ok(x, "wrong case")
684 if false then
685 Sub testsub
686 x = true
687 End Sub
688 end if
690 x = false
691 Call testsub
692 Call ok(x, "x is false, testsub not called?")
694 Sub SubSetTrue(v)
695 Call ok(not v, "v is not true")
696 v = true
697 End Sub
699 x = false
700 SubSetTrue x
701 Call ok(x, "x was not set by SubSetTrue")
703 SubSetTrue false
704 Call ok(not false, "false is no longer false?")
706 Sub SubSetTrue2(ByRef v)
707 Call ok(not v, "v is not true")
708 v = true
709 End Sub
711 x = false
712 SubSetTrue2 x
713 Call ok(x, "x was not set by SubSetTrue")
715 Sub TestSubArgVal(ByVal v)
716 Call ok(not v, "v is not false")
717 v = true
718 Call ok(v, "v is not true?")
719 End Sub
721 x = false
722 Call TestSubArgVal(x)
723 Call ok(not x, "x is true after TestSubArgVal call?")
725 Sub TestSubMultiArgs(a,b,c,d,e)
726 Call ok(a=1, "a = " & a)
727 Call ok(b=2, "b = " & b)
728 Call ok(c=3, "c = " & c)
729 Call ok(d=4, "d = " & d)
730 Call ok(e=5, "e = " & e)
731 End Sub
733 Sub TestSubExit(ByRef a)
734 If a Then
735 Exit Sub
736 End If
737 Call ok(false, "Exit Sub not called?")
738 End Sub
740 Call TestSubExit(true)
742 Sub TestSubExit2
743 for x = 1 to 100
744 Exit Sub
745 next
746 End Sub
747 Call TestSubExit2
749 TestSubMultiArgs 1, 2, 3, 4, 5
750 Call TestSubMultiArgs(1, 2, 3, 4, 5)
752 Sub TestSubLocalVal
753 x = false
754 Call ok(not x, "local x is not false?")
755 Dim x
756 Dim a,b, c
757 End Sub
759 x = true
760 y = true
761 Call TestSubLocalVal
762 Call ok(x, "global x is not true?")
764 Public Sub TestPublicSub
765 End Sub
766 Call TestPublicSub
768 Private Sub TestPrivateSub
769 End Sub
770 Call TestPrivateSub
772 Public Sub TestSeparatorSub : :
774 End Sub
775 Call TestSeparatorSub
777 if false then
778 Function testfunc
779 x = true
780 End Function
781 end if
783 x = false
784 Call TestFunc
785 Call ok(x, "x is false, testfunc not called?")
787 Function FuncSetTrue(v)
788 Call ok(not v, "v is not true")
789 v = true
790 End Function
792 x = false
793 FuncSetTrue x
794 Call ok(x, "x was not set by FuncSetTrue")
796 FuncSetTrue false
797 Call ok(not false, "false is no longer false?")
799 Function FuncSetTrue2(ByRef v)
800 Call ok(not v, "v is not true")
801 v = true
802 End Function
804 x = false
805 FuncSetTrue2 x
806 Call ok(x, "x was not set by FuncSetTrue")
808 Function TestFuncArgVal(ByVal v)
809 Call ok(not v, "v is not false")
810 v = true
811 Call ok(v, "v is not true?")
812 End Function
814 x = false
815 Call TestFuncArgVal(x)
816 Call ok(not x, "x is true after TestFuncArgVal call?")
818 Function TestFuncMultiArgs(a,b,c,d,e)
819 Call ok(a=1, "a = " & a)
820 Call ok(b=2, "b = " & b)
821 Call ok(c=3, "c = " & c)
822 Call ok(d=4, "d = " & d)
823 Call ok(e=5, "e = " & e)
824 End Function
826 TestFuncMultiArgs 1, 2, 3, 4, 5
827 Call TestFuncMultiArgs(1, 2, 3, 4, 5)
829 Function TestFuncLocalVal
830 x = false
831 Call ok(not x, "local x is not false?")
832 Dim x
833 End Function
835 x = true
836 y = true
837 Call TestFuncLocalVal
838 Call ok(x, "global x is not true?")
840 Function TestFuncExit(ByRef a)
841 If a Then
842 Exit Function
843 End If
844 Call ok(false, "Exit Function not called?")
845 End Function
847 Call TestFuncExit(true)
849 Function TestFuncExit2(ByRef a)
850 For x = 1 to 100
851 For y = 1 to 100
852 Exit Function
853 Next
854 Next
855 Call ok(false, "Exit Function not called?")
856 End Function
858 Call TestFuncExit2(true)
860 Sub SubParseTest
861 End Sub : x = false
862 Call SubParseTest
864 Function FuncParseTest
865 End Function : x = false
867 Function ReturnTrue
868 ReturnTrue = false
869 ReturnTrue = true
870 End Function
872 Call ok(ReturnTrue(), "ReturnTrue returned false?")
874 Function SetVal(ByRef x, ByVal v)
875 x = v
876 SetVal = x
877 Exit Function
878 End Function
880 x = false
881 ok SetVal(x, true), "SetVal returned false?"
882 Call ok(x, "x is not set to true by SetVal?")
884 Public Function TestPublicFunc
885 End Function
886 Call TestPublicFunc
888 Private Function TestPrivateFunc
889 End Function
890 Call TestPrivateFunc
892 Public Function TestSepFunc(ByVal a) : :
893 : TestSepFunc = a
894 End Function
895 Call ok(TestSepFunc(1) = 1, "Function did not return 1")
897 ok duplicatedfunc() = 2, "duplicatedfunc = " & duplicatedfunc()
899 function duplicatedfunc
900 ok false, "duplicatedfunc called"
901 end function
903 sub duplicatedfunc
904 ok false, "duplicatedfunc called"
905 end sub
907 function duplicatedfunc
908 duplicatedfunc = 2
909 end function
911 ok duplicatedfunc() = 2, "duplicatedfunc = " & duplicatedfunc()
913 ' Stop has an effect only in debugging mode
914 Stop
916 set x = testObj
917 Call ok(getVT(x) = "VT_DISPATCH*", "getVT(x=testObj) = " & getVT(x))
919 Set obj = New EmptyClass
920 Call ok(getVT(obj) = "VT_DISPATCH*", "getVT(obj) = " & getVT(obj))
922 Class EmptyClass
923 End Class
925 Set x = obj
926 Call ok(getVT(x) = "VT_DISPATCH*", "getVT(x) = " & getVT(x))
928 Class TestClass
929 Public publicProp
931 Private privateProp
933 Public Function publicFunction()
934 privateSub()
935 publicFunction = 4
936 End Function
938 Public Property Get gsProp()
939 gsProp = privateProp
940 funcCalled = "gsProp get"
941 exit property
942 Call ok(false, "exit property not returned?")
943 End Property
945 Public Default Property Get DefValGet
946 DefValGet = privateProp
947 funcCalled = "GetDefVal"
948 End Property
950 Public Property Let DefValGet(x)
951 End Property
953 Public publicProp2
955 Public Sub publicSub
956 End Sub
958 Public Property Let gsProp(val)
959 privateProp = val
960 funcCalled = "gsProp let"
961 exit property
962 Call ok(false, "exit property not returned?")
963 End Property
965 Public Property Set gsProp(val)
966 funcCalled = "gsProp set"
967 exit property
968 Call ok(false, "exit property not returned?")
969 End Property
971 Public Sub setPrivateProp(x)
972 privateProp = x
973 End Sub
975 Function getPrivateProp
976 getPrivateProp = privateProp
977 End Function
979 Private Sub privateSub
980 End Sub
982 Public Sub Class_Initialize
983 publicProp2 = 2
984 privateProp = true
985 Call ok(getVT(privateProp) = "VT_BOOL*", "getVT(privateProp) = " & getVT(privateProp))
986 Call ok(getVT(publicProp2) = "VT_I2*", "getVT(publicProp2) = " & getVT(publicProp2))
987 Call ok(getVT(Me.publicProp2) = "VT_I2", "getVT(Me.publicProp2) = " & getVT(Me.publicProp2))
988 End Sub
990 Property Get gsGetProp(x)
991 gsGetProp = x
992 End Property
993 End Class
995 Call testDisp(new testClass)
997 Set obj = New TestClass
999 Call ok(obj.publicFunction = 4, "obj.publicFunction = " & obj.publicFunction)
1000 Call ok(obj.publicFunction() = 4, "obj.publicFunction() = " & obj.publicFunction())
1002 obj.publicSub()
1003 Call obj.publicSub
1004 Call obj.publicFunction()
1006 Call ok(getVT(obj.publicProp) = "VT_EMPTY", "getVT(obj.publicProp) = " & getVT(obj.publicProp))
1007 obj.publicProp = 3
1008 Call ok(getVT(obj.publicProp) = "VT_I2", "getVT(obj.publicProp) = " & getVT(obj.publicProp))
1009 Call ok(obj.publicProp = 3, "obj.publicProp = " & obj.publicProp)
1010 obj.publicProp() = 3
1012 Call ok(obj.getPrivateProp() = true, "obj.getPrivateProp() = " & obj.getPrivateProp())
1013 Call obj.setPrivateProp(6)
1014 Call ok(obj.getPrivateProp = 6, "obj.getPrivateProp = " & obj.getPrivateProp)
1016 Dim funcCalled
1017 funcCalled = ""
1018 Call ok(obj.gsProp = 6, "obj.gsProp = " & obj.gsProp)
1019 Call ok(funcCalled = "gsProp get", "funcCalled = " & funcCalled)
1020 obj.gsProp = 3
1021 Call ok(funcCalled = "gsProp let", "funcCalled = " & funcCalled)
1022 Call ok(obj.getPrivateProp = 3, "obj.getPrivateProp = " & obj.getPrivateProp)
1023 Set obj.gsProp = New testclass
1024 Call ok(funcCalled = "gsProp set", "funcCalled = " & funcCalled)
1026 x = obj
1027 Call ok(x = 3, "(x = obj) = " & x)
1028 Call ok(funcCalled = "GetDefVal", "funcCalled = " & funcCalled)
1029 funcCalled = ""
1030 Call ok(obj = 3, "(x = obj) = " & obj)
1031 Call ok(funcCalled = "GetDefVal", "funcCalled = " & funcCalled)
1033 Call obj.Class_Initialize
1034 Call ok(obj.getPrivateProp() = true, "obj.getPrivateProp() = " & obj.getPrivateProp())
1036 x = (New testclass).publicProp
1038 Class TermTest
1039 Public Sub Class_Terminate()
1040 funcCalled = "terminate"
1041 End Sub
1042 End Class
1044 Set obj = New TermTest
1045 funcCalled = ""
1046 Set obj = Nothing
1047 Call ok(funcCalled = "terminate", "funcCalled = " & funcCalled)
1049 Set obj = New TermTest
1050 funcCalled = ""
1051 Call obj.Class_Terminate
1052 Call ok(funcCalled = "terminate", "funcCalled = " & funcCalled)
1053 funcCalled = ""
1054 Set obj = Nothing
1055 Call ok(funcCalled = "terminate", "funcCalled = " & funcCalled)
1057 Call (New testclass).publicSub()
1058 Call (New testclass).publicSub
1060 class PropTest
1061 property get prop0()
1062 prop0 = 1
1063 end property
1065 property get prop1(x)
1066 prop1 = x+1
1067 end property
1069 property get prop2(x, y)
1070 prop2 = x+y
1071 end property
1072 end class
1074 set obj = new PropTest
1076 call ok(obj.prop0 = 1, "obj.prop0 = " & obj.prop0)
1077 call ok(obj.prop1(3) = 4, "obj.prop1(3) = " & obj.prop1(3))
1078 call ok(obj.prop2(3,4) = 7, "obj.prop2(3,4) = " & obj.prop2(3,4))
1079 call obj.prop0()
1080 call obj.prop1(2)
1081 call obj.prop2(3,4)
1083 x = "following ':' is correct syntax" :
1084 x = "following ':' is correct syntax" :: :
1085 :: x = "also correct syntax"
1086 rem another ugly way for comments
1087 x = "rem as simplestatement" : rem rem comment
1090 Set obj = new EmptyClass
1091 Set x = obj
1092 Set y = new EmptyClass
1094 Call ok(obj is x, "obj is not x")
1095 Call ok(x is obj, "x is not obj")
1096 Call ok(not (obj is y), "obj is not y")
1097 Call ok(not obj is y, "obj is not y")
1098 Call ok(not (x is Nothing), "x is 1")
1099 Call ok(Nothing is Nothing, "Nothing is not Nothing")
1100 Call ok(x is obj and true, "x is obj and true is false")
1102 Class TestMe
1103 Public Sub Test(MyMe)
1104 Call ok(Me is MyMe, "Me is not MyMe")
1105 End Sub
1106 End Class
1108 Set obj = New TestMe
1109 Call obj.test(obj)
1111 Call ok(getVT(test) = "VT_DISPATCH", "getVT(test) = " & getVT(test))
1112 Call ok(Me is Test, "Me is not Test")
1114 Const c1 = 1, c2 = 2, c3 = -3
1115 Call ok(c1 = 1, "c1 = " & c1)
1116 Call ok(getVT(c1) = "VT_I2", "getVT(c1) = " & getVT(c1))
1117 Call ok(c3 = -3, "c3 = " & c3)
1118 Call ok(getVT(c3) = "VT_I2", "getVT(c3) = " & getVT(c3))
1120 Const cb = True, cs = "test", cnull = null
1121 Call ok(cb, "cb = " & cb)
1122 Call ok(getVT(cb) = "VT_BOOL", "getVT(cb) = " & getVT(cb))
1123 Call ok(cs = "test", "cs = " & cs)
1124 Call ok(getVT(cs) = "VT_BSTR", "getVT(cs) = " & getVT(cs))
1125 Call ok(isNull(cnull), "cnull = " & cnull)
1126 Call ok(getVT(cnull) = "VT_NULL", "getVT(cnull) = " & getVT(cnull))
1128 Call ok(+1 = 1, "+1 != 1")
1129 Call ok(+true = true, "+1 != 1")
1130 Call ok(getVT(+true) = "VT_BOOL", "getVT(+true) = " & getVT(+true))
1131 Call ok(+"true" = "true", """+true"" != true")
1132 Call ok(getVT(+"true") = "VT_BSTR", "getVT(+""true"") = " & getVT(+"true"))
1133 Call ok(+obj is obj, "+obj != obj")
1134 Call ok(+--+-+1 = -1, "+--+-+1 != -1")
1136 if false then Const conststr = "str"
1137 Call ok(conststr = "str", "conststr = " & conststr)
1138 Call ok(getVT(conststr) = "VT_BSTR", "getVT(conststr) = " & getVT(conststr))
1139 Call ok(conststr = "str", "conststr = " & conststr)
1141 Sub ConstTestSub
1142 Const funcconst = 1
1143 Call ok(c1 = 1, "c1 = " & c1)
1144 Call ok(funcconst = 1, "funcconst = " & funcconst)
1145 End Sub
1147 Call ConstTestSub
1148 Dim funcconst
1150 ' Property may be used as an identifier (although it's a keyword)
1151 Sub TestProperty
1152 Dim Property
1153 PROPERTY = true
1154 Call ok(property, "property = " & property)
1156 for property = 1 to 2
1157 next
1158 End Sub
1160 Call TestProperty
1162 Class Property
1163 Public Sub Property()
1164 End Sub
1166 Sub Test(byref property)
1167 End Sub
1168 End Class
1170 Class Property2
1171 Function Property()
1172 End Function
1174 Sub Test(property)
1175 End Sub
1177 Sub Test2(byval property)
1178 End Sub
1179 End Class
1181 Class SeparatorTest : : Dim varTest1
1183 Private Sub Class_Initialize : varTest1 = 1
1184 End Sub ::
1186 Property Get Test1() :
1187 Test1 = varTest1
1188 End Property ::
1190 Property Let Test1(a) :
1191 varTest1 = a
1192 End Property :
1194 Public Function AddToTest1(ByVal a) :: :
1195 varTest1 = varTest1 + a
1196 AddToTest1 = varTest1
1197 End Function : End Class : :: Set obj = New SeparatorTest
1199 Call ok(obj.Test1 = 1, "obj.Test1 is not 1")
1200 obj.Test1 = 6
1201 Call ok(obj.Test1 = 6, "obj.Test1 is not 6")
1202 obj.AddToTest1(5)
1203 Call ok(obj.Test1 = 11, "obj.Test1 is not 11")
1205 set obj = unkObj
1206 set x = obj
1207 call ok(getVT(obj) = "VT_UNKNOWN*", "getVT(obj) = " & getVT(obj))
1208 call ok(getVT(x) = "VT_UNKNOWN*", "getVT(x) = " & getVT(x))
1209 call ok(getVT(unkObj) = "VT_UNKNOWN", "getVT(unkObj) = " & getVT(unkObj))
1210 call ok(obj is unkObj, "obj is not unkObj")
1212 ' Array tests
1214 Call ok(getVT(arr) = "VT_EMPTY*", "getVT(arr) = " & getVT(arr))
1216 Dim arr(3)
1217 Dim arr2(4,3), arr3(5,4,3), arr0(0), noarr()
1219 Call ok(getVT(arr) = "VT_ARRAY|VT_BYREF|VT_VARIANT*", "getVT(arr) = " & getVT(arr))
1220 Call ok(getVT(arr2) = "VT_ARRAY|VT_BYREF|VT_VARIANT*", "getVT(arr2) = " & getVT(arr2))
1221 Call ok(getVT(arr0) = "VT_ARRAY|VT_BYREF|VT_VARIANT*", "getVT(arr0) = " & getVT(arr0))
1222 Call ok(getVT(noarr) = "VT_ARRAY|VT_BYREF|VT_VARIANT*", "getVT(noarr) = " & getVT(noarr))
1224 Call testArray(1, arr)
1225 Call testArray(2, arr2)
1226 Call testArray(3, arr3)
1227 Call testArray(0, arr0)
1228 Call testArray(-1, noarr)
1230 Call ok(getVT(arr(1)) = "VT_EMPTY*", "getVT(arr(1)) = " & getVT(arr(1)))
1231 Call ok(getVT(arr2(1,2)) = "VT_EMPTY*", "getVT(arr2(1,2)) = " & getVT(arr2(1,2)))
1232 Call ok(getVT(arr3(1,2,2)) = "VT_EMPTY*", "getVT(arr3(1,2,3)) = " & getVT(arr3(1,2,2)))
1233 Call ok(getVT(arr(0)) = "VT_EMPTY*", "getVT(arr(0)) = " & getVT(arr(0)))
1234 Call ok(getVT(arr(3)) = "VT_EMPTY*", "getVT(arr(3)) = " & getVT(arr(3)))
1235 Call ok(getVT(arr0(0)) = "VT_EMPTY*", "getVT(arr0(0)) = " & getVT(arr0(0)))
1237 arr(2) = 3
1238 Call ok(arr(2) = 3, "arr(2) = " & arr(2))
1239 Call ok(getVT(arr(2)) = "VT_I2*", "getVT(arr(2)) = " & getVT(arr(2)))
1241 arr3(3,2,1) = 1
1242 arr3(1,2,3) = 2
1243 Call ok(arr3(3,2,1) = 1, "arr3(3,2,1) = " & arr3(3,2,1))
1244 Call ok(arr3(1,2,3) = 2, "arr3(1,2,3) = " & arr3(1,2,3))
1245 arr2(4,3) = 1
1246 Call ok(arr2(4,3) = 1, "arr2(4,3) = " & arr2(4,3))
1248 x = arr3
1249 Call ok(x(3,2,1) = 1, "x(3,2,1) = " & x(3,2,1))
1251 Function getarr()
1252 Dim arr(3)
1253 arr(2) = 2
1254 getarr = arr
1255 arr(3) = 3
1256 End Function
1258 x = getarr()
1259 Call ok(getVT(x) = "VT_ARRAY|VT_VARIANT*", "getVT(x) = " & getVT(x))
1260 Call ok(x(2) = 2, "x(2) = " & x(2))
1261 Call ok(getVT(x(3)) = "VT_EMPTY*", "getVT(x(3)) = " & getVT(x(3)))
1263 x(1) = 1
1264 Call ok(x(1) = 1, "x(1) = " & x(1))
1265 x = getarr()
1266 Call ok(getVT(x(1)) = "VT_EMPTY*", "getVT(x(1)) = " & getVT(x(1)))
1267 Call ok(x(2) = 2, "x(2) = " & x(2))
1269 x(1) = 1
1270 y = x
1271 x(1) = 2
1272 Call ok(y(1) = 1, "y(1) = " & y(1))
1274 for x=1 to 1
1275 Dim forarr(3)
1276 if x=1 then
1277 Call ok(getVT(forarr(1)) = "VT_EMPTY*", "getVT(forarr(1)) = " & getVT(forarr(1)))
1278 else
1279 Call ok(forarr(1) = x, "forarr(1) = " & forarr(1))
1280 end if
1281 forarr(1) = x+1
1282 next
1285 Call ok(forarr(x) = 2, "forarr(x) = " & forarr(x))
1287 sub accessArr()
1288 ok arr(1) = 1, "arr(1) = " & arr(1)
1289 arr(1) = 2
1290 end sub
1291 arr(1) = 1
1292 call accessArr
1293 ok arr(1) = 2, "arr(1) = " & arr(1)
1295 sub accessArr2(x,y)
1296 ok arr2(x,y) = 1, "arr2(x,y) = " & arr2(x,y)
1297 x = arr2(x,y)
1298 arr2(x,y) = 2
1299 end sub
1300 arr2(1,2) = 1
1301 call accessArr2(1, 2)
1302 ok arr2(1,2) = 2, "arr2(1,2) = " & arr2(1,2)
1304 x = Array(Array(3))
1305 call ok(x(0)(0) = 3, "x(0)(0) = " & x(0)(0))
1307 function seta0(arr)
1308 arr(0) = 2
1309 seta0 = 1
1310 end function
1312 x = Array(1)
1313 seta0 x
1314 ok x(0) = 2, "x(0) = " & x(0)
1316 x = Array(1)
1317 seta0 (x)
1318 ok x(0) = 1, "x(0) = " & x(0)
1320 x = Array(1)
1321 call (((seta0))) ((x))
1322 ok x(0) = 1, "x(0) = " & x(0)
1324 x = Array(1)
1325 call (((seta0))) (x)
1326 ok x(0) = 2, "x(0) = " & x(0)
1328 x = Array(Array(3))
1329 seta0 x(0)
1330 call ok(x(0)(0) = 2, "x(0)(0) = " & x(0)(0))
1332 x = Array(Array(3))
1333 seta0 (x(0))
1334 call ok(x(0)(0) = 3, "x(0)(0) = " & x(0)(0))
1336 y = (seta0)(x)
1337 ok y = 1, "y = " & y
1339 y = ((x))(0)
1340 ok y = 2, "y = " & y
1342 sub changearg(x)
1343 x = 2
1344 end sub
1346 x = Array(1)
1347 changearg x(0)
1348 ok x(0) = 2, "x(0) = " & x(0)
1349 ok getVT(x) = "VT_ARRAY|VT_VARIANT*", "getVT(x) after redim = " & getVT(x)
1351 x = Array(1)
1352 changearg (x(0))
1353 ok x(0) = 1, "x(0) = " & x(0)
1355 x = Array(1)
1356 redim x(4)
1357 ok ubound(x) = 4, "ubound(x) = " & ubound(x)
1358 ok x(0) = empty, "x(0) = " & x(0)
1360 x = 1
1361 redim x(3)
1362 ok ubound(x) = 3, "ubound(x) = " & ubound(x)
1364 x = Array(1, 2)
1365 redim x(-1)
1366 ok lbound(x) = 0, "lbound(x) = " & lbound(x)
1367 ok ubound(x) = -1, "ubound(x) = " & ubound(x)
1369 redim x(3, 2)
1370 ok ubound(x) = 3, "ubound(x) = " & ubound(x)
1371 ok ubound(x, 1) = 3, "ubound(x, 1) = " & ubound(x, 1)
1372 ok ubound(x, 2) = 2, "ubound(x, 2) = " & ubound(x, 2) & " expected 2"
1374 dim staticarray(4)
1375 on error resume next
1376 redim staticarray(3)
1377 e = err.number
1378 on error goto 0
1379 todo_wine_ok e = 10, "e = " & e
1381 Class ArrClass
1382 Dim classarr(3)
1383 Dim classnoarr()
1384 Dim var
1386 Private Sub Class_Initialize
1387 Call ok(getVT(classarr) = "VT_ARRAY|VT_BYREF|VT_VARIANT*", "getVT(classarr) = " & getVT(classarr))
1388 Call testArray(-1, classnoarr)
1389 classarr(0) = 1
1390 classarr(1) = 2
1391 classarr(2) = 3
1392 classarr(3) = 4
1393 End Sub
1395 Public Sub testVarVT
1396 Call ok(getVT(var) = "VT_ARRAY|VT_VARIANT*", "getVT(var) = " & getVT(var))
1397 End Sub
1398 End Class
1400 Set obj = new ArrClass
1401 Call ok(getVT(obj.classarr) = "VT_ARRAY|VT_VARIANT", "getVT(obj.classarr) = " & getVT(obj.classarr))
1402 'todo_wine Call ok(obj.classarr(1) = 2, "obj.classarr(1) = " & obj.classarr(1))
1404 obj.var = arr
1405 Call ok(getVT(obj.var) = "VT_ARRAY|VT_VARIANT", "getVT(obj.var) = " & getVT(obj.var))
1406 Call obj.testVarVT
1408 Sub arrarg(byref refarr, byval valarr, byref refarr2, byval valarr2)
1409 Call ok(getVT(refarr) = "VT_ARRAY|VT_BYREF|VT_VARIANT*", "getVT(refarr) = " & getVT(refarr))
1410 Call ok(getVT(valarr) = "VT_ARRAY|VT_VARIANT*", "getVT(valarr) = " & getVT(valarr))
1411 Call ok(getVT(refarr2) = "VT_ARRAY|VT_VARIANT*", "getVT(refarr2) = " & getVT(refarr2))
1412 Call ok(getVT(valarr2) = "VT_ARRAY|VT_VARIANT*", "getVT(valarr2) = " & getVT(valarr2))
1413 End Sub
1415 Call arrarg(arr, arr, obj.classarr, obj.classarr)
1417 Sub arrarg2(byref refarr(), byval valarr(), byref refarr2(), byval valarr2())
1418 Call ok(getVT(refarr) = "VT_ARRAY|VT_BYREF|VT_VARIANT*", "getVT(refarr) = " & getVT(refarr))
1419 Call ok(getVT(valarr) = "VT_ARRAY|VT_VARIANT*", "getVT(valarr) = " & getVT(valarr))
1420 Call ok(getVT(refarr2) = "VT_ARRAY|VT_VARIANT*", "getVT(refarr2) = " & getVT(refarr2))
1421 Call ok(getVT(valarr2) = "VT_ARRAY|VT_VARIANT*", "getVT(valarr2) = " & getVT(valarr2))
1422 End Sub
1424 Call arrarg2(arr, arr, obj.classarr, obj.classarr)
1426 Sub testarrarg(arg(), vt)
1427 Call ok(getVT(arg) = vt, "getVT() = " & getVT(arg) & " expected " & vt)
1428 End Sub
1430 Call testarrarg(1, "VT_I2*")
1431 Call testarrarg(false, "VT_BOOL*")
1432 Call testarrarg(Empty, "VT_EMPTY*")
1434 Sub modifyarr(arr)
1435 Call ok(arr(0) = "not modified", "arr(0) = " & arr(0))
1436 arr(0) = "modified"
1437 End Sub
1439 arr(0) = "not modified"
1440 Call modifyarr(arr)
1441 Call ok(arr(0) = "modified", "arr(0) = " & arr(0))
1443 arr(0) = "not modified"
1444 modifyarr(arr)
1445 Call ok(arr(0) = "not modified", "arr(0) = " & arr(0))
1447 for x = 0 to UBound(arr)
1448 arr(x) = x
1449 next
1450 y = 0
1451 for each x in arr
1452 Call ok(x = y, "x = " & x & ", expected " & y)
1453 Call ok(arr(y) = y, "arr(" & y & ") = " & arr(y))
1454 arr(y) = 1
1455 x = 1
1456 y = y+1
1457 next
1458 Call ok(y = 4, "y = " & y & " after array enumeration")
1460 for x=0 to UBound(arr2, 1)
1461 for y=0 to UBound(arr2, 2)
1462 arr2(x, y) = x + y*(UBound(arr2, 1)+1)
1463 next
1464 next
1465 y = 0
1466 for each x in arr2
1467 Call ok(x = y, "x = " & x & ", expected " & y)
1468 y = y+1
1469 next
1470 Call ok(y = 20, "y = " & y & " after array enumeration")
1472 for each x in noarr
1473 Call ok(false, "Empty array contains: " & x)
1474 next
1476 ' It's allowed to declare non-builtin RegExp class...
1477 class RegExp
1478 public property get Global()
1479 Call ok(false, "Global called")
1480 Global = "fail"
1481 end property
1482 end class
1484 ' ...but there is no way to use it because builtin instance is always created
1485 set x = new RegExp
1486 Call ok(x.Global = false, "x.Global = " & x.Global)
1488 sub test_nothing_errors
1489 dim x
1490 on error resume next
1492 x = 1
1493 err.clear
1494 x = nothing
1495 call ok(err.number = 91, "err.number = " & err.number)
1496 call ok(x = 1, "x = " & x)
1498 err.clear
1499 x = not nothing
1500 call ok(err.number = 91, "err.number = " & err.number)
1501 call ok(x = 1, "x = " & x)
1503 err.clear
1504 x = "" & nothing
1505 call ok(err.number = 91, "err.number = " & err.number)
1506 call ok(x = 1, "x = " & x)
1507 end sub
1508 call test_nothing_errors()
1510 sub test_identifiers
1511 ' test keywords that can also be a declared identifier
1512 Dim default
1513 default = "xx"
1514 Call ok(default = "xx", "default = " & default & " expected ""xx""")
1516 Dim error
1517 error = "xx"
1518 Call ok(error = "xx", "error = " & error & " expected ""xx""")
1520 Dim explicit
1521 explicit = "xx"
1522 Call ok(explicit = "xx", "explicit = " & explicit & " expected ""xx""")
1524 Dim step
1525 step = "xx"
1526 Call ok(step = "xx", "step = " & step & " expected ""xx""")
1527 end sub
1528 call test_identifiers()
1530 sub test_dotIdentifiers
1531 ' test keywords that can also be an identifier after a dot
1532 Call ok(testObj.rem = 10, "testObj.rem = " & testObj.rem & " expected 10")
1533 Call ok(testObj.true = 10, "testObj.true = " & testObj.true & " expected 10")
1534 Call ok(testObj.false = 10, "testObj.false = " & testObj.false & " expected 10")
1535 Call ok(testObj.not = 10, "testObj.not = " & testObj.not & " expected 10")
1536 Call ok(testObj.and = 10, "testObj.and = " & testObj.and & " expected 10")
1537 Call ok(testObj.or = 10, "testObj.or = " & testObj.or & " expected 10")
1538 Call ok(testObj.xor = 10, "testObj.xor = " & testObj.xor & " expected 10")
1539 Call ok(testObj.eqv = 10, "testObj.eqv = " & testObj.eqv & " expected 10")
1540 Call ok(testObj.imp = 10, "testObj.imp = " & testObj.imp & " expected 10")
1541 Call ok(testObj.is = 10, "testObj.is = " & testObj.is & " expected 10")
1542 Call ok(testObj.mod = 10, "testObj.mod = " & testObj.mod & " expected 10")
1543 Call ok(testObj.call = 10, "testObj.call = " & testObj.call & " expected 10")
1544 Call ok(testObj.dim = 10, "testObj.dim = " & testObj.dim & " expected 10")
1545 Call ok(testObj.sub = 10, "testObj.sub = " & testObj.sub & " expected 10")
1546 Call ok(testObj.function = 10, "testObj.function = " & testObj.function & " expected 10")
1547 Call ok(testObj.get = 10, "testObj.get = " & testObj.get & " expected 10")
1548 Call ok(testObj.let = 10, "testObj.let = " & testObj.let & " expected 10")
1549 Call ok(testObj.const = 10, "testObj.const = " & testObj.const & " expected 10")
1550 Call ok(testObj.if = 10, "testObj.if = " & testObj.if & " expected 10")
1551 Call ok(testObj.else = 10, "testObj.else = " & testObj.else & " expected 10")
1552 Call ok(testObj.elseif = 10, "testObj.elseif = " & testObj.elseif & " expected 10")
1553 Call ok(testObj.end = 10, "testObj.end = " & testObj.end & " expected 10")
1554 Call ok(testObj.then = 10, "testObj.then = " & testObj.then & " expected 10")
1555 Call ok(testObj.exit = 10, "testObj.exit = " & testObj.exit & " expected 10")
1556 Call ok(testObj.while = 10, "testObj.while = " & testObj.while & " expected 10")
1557 Call ok(testObj.wend = 10, "testObj.wend = " & testObj.wend & " expected 10")
1558 Call ok(testObj.do = 10, "testObj.do = " & testObj.do & " expected 10")
1559 Call ok(testObj.loop = 10, "testObj.loop = " & testObj.loop & " expected 10")
1560 Call ok(testObj.until = 10, "testObj.until = " & testObj.until & " expected 10")
1561 Call ok(testObj.for = 10, "testObj.for = " & testObj.for & " expected 10")
1562 Call ok(testObj.to = 10, "testObj.to = " & testObj.to & " expected 10")
1563 Call ok(testObj.each = 10, "testObj.each = " & testObj.each & " expected 10")
1564 Call ok(testObj.in = 10, "testObj.in = " & testObj.in & " expected 10")
1565 Call ok(testObj.select = 10, "testObj.select = " & testObj.select & " expected 10")
1566 Call ok(testObj.case = 10, "testObj.case = " & testObj.case & " expected 10")
1567 Call ok(testObj.byref = 10, "testObj.byref = " & testObj.byref & " expected 10")
1568 Call ok(testObj.byval = 10, "testObj.byval = " & testObj.byval & " expected 10")
1569 Call ok(testObj.option = 10, "testObj.option = " & testObj.option & " expected 10")
1570 Call ok(testObj.nothing = 10, "testObj.nothing = " & testObj.nothing & " expected 10")
1571 Call ok(testObj.empty = 10, "testObj.empty = " & testObj.empty & " expected 10")
1572 Call ok(testObj.null = 10, "testObj.null = " & testObj.null & " expected 10")
1573 Call ok(testObj.class = 10, "testObj.class = " & testObj.class & " expected 10")
1574 Call ok(testObj.set = 10, "testObj.set = " & testObj.set & " expected 10")
1575 Call ok(testObj.new = 10, "testObj.new = " & testObj.new & " expected 10")
1576 Call ok(testObj.public = 10, "testObj.public = " & testObj.public & " expected 10")
1577 Call ok(testObj.private = 10, "testObj.private = " & testObj.private & " expected 10")
1578 Call ok(testObj.next = 10, "testObj.next = " & testObj.next & " expected 10")
1579 Call ok(testObj.on = 10, "testObj.on = " & testObj.on & " expected 10")
1580 Call ok(testObj.resume = 10, "testObj.resume = " & testObj.resume & " expected 10")
1581 Call ok(testObj.goto = 10, "testObj.goto = " & testObj.goto & " expected 10")
1582 Call ok(testObj.with = 10, "testObj.with = " & testObj.with & " expected 10")
1583 Call ok(testObj.redim = 10, "testObj.redim = " & testObj.redim & " expected 10")
1584 Call ok(testObj.preserve = 10, "testObj.preserve = " & testObj.preserve & " expected 10")
1585 Call ok(testObj.property = 10, "testObj.property = " & testObj.property & " expected 10")
1586 Call ok(testObj.me = 10, "testObj.me = " & testObj.me & " expected 10")
1587 Call ok(testObj.stop = 10, "testObj.stop = " & testObj.stop & " expected 10")
1588 end sub
1589 call test_dotIdentifiers
1591 ' Test End statements not required to be preceded by a newline or separator
1592 Sub EndTestSub
1593 x = 1 End Sub
1595 Sub EndTestSubWithCall
1596 x = 1
1597 Call ok(x = 1, "x = " & x)End Sub
1598 Call EndTestSubWithCall()
1600 Function EndTestFunc(x)
1601 Call ok(x > 0, "x = " & x)End Function
1602 EndTestFunc(1)
1604 Class EndTestClassWithStorageId
1605 Public x End Class
1607 Class EndTestClassWithDim
1608 Dim x End Class
1610 Class EndTestClassWithFunc
1611 Function test(ByVal x)
1612 x = 0 End Function End Class
1614 Class EndTestClassWithProperty
1615 Public x
1616 Public default Property Get defprop
1617 defprop = x End Property End Class
1619 class TestPropSyntax
1620 public prop
1622 function getProp()
1623 set getProp = prop
1624 end function
1626 public default property get def()
1627 def = ""
1628 end property
1629 end class
1631 set x = new TestPropSyntax
1632 set x.prop = new TestPropSyntax
1633 set x.prop.prop = new TestPropSyntax
1634 x.prop.prop.prop = 2
1635 call ok(x.getProp().getProp.prop = 2, "x.getProp().getProp.prop = " & x.getProp().getProp.prop)
1636 x.getprop.getprop().prop = 3
1637 call ok(x.getProp.prop.prop = 3, "x.getProp.prop.prop = " & x.getProp.prop.prop)
1638 set x.getprop.getprop().prop = new emptyclass
1639 set obj = new emptyclass
1640 set x.getprop.getprop().prop = obj
1641 call ok(x.getprop.getprop().prop is obj, "x.getprop.getprop().prop is not obj (emptyclass)")
1643 ok getVT(x) = "VT_DISPATCH*", "getVT(x) = " & getVT(x)
1644 todo_wine_ok getVT(x()) = "VT_BSTR", "getVT(x()) = " & getVT(x())
1646 with nothing
1647 end with
1649 set x = new TestPropSyntax
1650 with x
1651 .prop = 1
1652 ok .prop = 1, ".prop = "&.prop
1653 end with
1654 ok x.prop = 1, "x.prop = " & x.prop
1656 with new TestPropSyntax
1657 .prop = 1
1658 ok .prop = 1, ".prop = "&.prop
1659 end with
1661 function testsetresult(x, y)
1662 set testsetresult = new TestPropSyntax
1663 testsetresult.prop = x
1664 y = testsetresult.prop + 1
1665 end function
1667 set x = testsetresult(1, 2)
1668 ok x.prop = 1, "x.prop = " & x.prop
1670 set arr(0) = new TestPropSyntax
1671 arr(0).prop = 1
1672 ok arr(0).prop = 1, "arr(0) = " & arr(0).prop
1674 function f2(x,y)
1675 end function
1677 f2 1 = 1, 2
1679 function f1(x)
1680 ok x = true, "x = " & x
1681 end function
1683 f1 1 = 1
1684 f1 1 = (1)
1685 f1 not 1 = 0
1687 arr (0) = 2 xor -2
1689 reportSuccess()