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
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(.5 = 0.5, ".5 <> 0.5")
51 Call ok(.5e1
= 5, ".5e1 <> 5")
52 Call ok(--1 = 1, "--1 = " & --1)
53 Call ok(-empty
= 0, "-empty = " & (-empty
))
54 Call ok(true = -1, "! true = -1")
55 Call ok(false = 0, "false <> 0")
56 Call ok(&hff
= 255, "&hff <> 255")
57 Call ok(&Hff
= 255, "&Hff <> 255")
58 Call ok(&hffff
= -1, "&hffff <> -1")
59 Call ok(&hfffe
= -2, "&hfffe <> -2")
60 Call ok(&hffff
& = 65535, "&hffff& <> -1")
61 Call ok(&hfffe
& = 65534, "&hfffe& <> -2")
62 Call ok(&hffffffff
& = -1, "&hffffffff& <> -1")
63 Call ok((&h01or
&h02
)=3,"&h01or&h02 <> 3")
66 Call ok(W
= 5, "W = " & W
& " expected " & 5)
69 Call ok(x
= "xx", "x = " & x
& " expected ""xx""")
71 Dim public1
: public1
= 42
72 Call ok(public1
= 42, "public1=" & public1
& " expected & " & 42)
73 Private priv1
: priv1
= 43
74 Call ok(priv1
= 43, "priv1=" & priv1
& " expected & " & 43)
75 Public pub1
: pub1
= 44
76 Call ok(pub1
= 44, "pub1=" & pub1
& " expected & " & 44)
78 Call ok(true <> false, "true <> false is false")
79 Call ok(not (true <> true), "true <> true is true")
80 Call ok(not ("x" <> "x"), """x"" <> ""x"" is true")
81 Call ok(not (empty
<> empty
), "empty <> empty is true")
82 Call ok(x
<> "x", "x = ""x""")
83 Call ok("true" <> true, """true"" = true is true")
85 Call ok("" = true = false, """"" = true = false is false")
86 Call ok(not(false = true = ""), "false = true = """" is true")
87 Call ok(not (false = false <> false = false), "false = false <> false = false is true")
88 Call ok(not ("" <> false = false), """"" <> false = false is true")
90 Call ok(getVT(false) = "VT_BOOL", "getVT(false) is not VT_BOOL")
91 Call ok(getVT(true) = "VT_BOOL", "getVT(true) is not VT_BOOL")
92 Call ok(getVT("") = "VT_BSTR", "getVT("""") is not VT_BSTR")
93 Call ok(getVT("test") = "VT_BSTR", "getVT(""test"") is not VT_BSTR")
94 Call ok(getVT(Empty
) = "VT_EMPTY", "getVT(Empty) is not VT_EMPTY")
95 Call ok(getVT(null
) = "VT_NULL", "getVT(null) is not VT_NULL")
96 Call ok(getVT(0) = "VT_I2", "getVT(0) is not VT_I2")
97 Call ok(getVT(1) = "VT_I2", "getVT(1) is not VT_I2")
98 Call ok(getVT(0.5) = "VT_R8", "getVT(0.5) is not VT_R8")
99 Call ok(getVT(.5) = "VT_R8", "getVT(.5) is not VT_R8")
100 Call ok(getVT(0.0) = "VT_R8", "getVT(0.0) is not VT_R8")
101 Call ok(getVT(2147483647) = "VT_I4", "getVT(2147483647) is not VT_I4")
102 Call ok(getVT(2147483648) = "VT_R8", "getVT(2147483648) is not VT_R8")
103 Call ok(getVT(&h10
&) = "VT_I2", "getVT(&h10&) is not VT_I2")
104 Call ok(getVT(&h10000
&) = "VT_I4", "getVT(&h10000&) is not VT_I4")
105 Call ok(getVT(&H10000
&) = "VT_I4", "getVT(&H10000&) is not VT_I4")
106 Call ok(getVT(&hffFFffFF
&) = "VT_I2", "getVT(&hffFFffFF&) is not VT_I2")
107 Call ok(getVT(&hffFFffFE
&) = "VT_I2", "getVT(&hffFFffFE &) is not VT_I2")
108 Call ok(getVT(&hffF
&) = "VT_I2", "getVT(&hffFF&) is not VT_I2")
109 Call ok(getVT(&hffFF
&) = "VT_I4", "getVT(&hffFF&) is not VT_I4")
110 Call ok(getVT(#
1/1/2011 #
) = "VT_DATE", "getVT(# 1/1/2011 #) is not VT_DATE")
111 Call ok(getVT(1e2
) = "VT_R8", "getVT(1e2) is not VT_R8")
112 Call ok(getVT(1e0
) = "VT_R8", "getVT(1e0) is not VT_R8")
113 Call ok(getVT(0.1e2
) = "VT_R8", "getVT(0.1e2) is not VT_R8")
114 Call ok(getVT(1 & 100000) = "VT_BSTR", "getVT(1 & 100000) is not VT_BSTR")
115 Call ok(getVT(-empty
) = "VT_I2", "getVT(-empty) = " & getVT(-empty
))
116 Call ok(getVT(-null
) = "VT_NULL", "getVT(-null) = " & getVT(-null
))
117 Call ok(getVT(y
) = "VT_EMPTY*", "getVT(y) = " & getVT(y
))
118 Call ok(getVT(nothing) = "VT_DISPATCH", "getVT(nothing) = " & getVT(nothing))
120 Call ok(getVT(x
) = "VT_DISPATCH*", "getVT(x=nothing) = " & getVT(x
))
122 Call ok(getVT(x
) = "VT_BOOL*", "getVT(x) = " & getVT(x
))
123 Call ok(getVT(false or true) = "VT_BOOL", "getVT(false) is not VT_BOOL")
125 Call ok(getVT(x
) = "VT_BSTR*", "getVT(x) is not VT_BSTR*")
127 Call ok(getVT(x
) = "VT_R8*", "getVT(x) = " & getVT(x
))
129 Call ok(isNullDisp(nothing), "nothing is not nulldisp?")
132 Call ok("ab" & "cd" = "abcd", """ab"" & ""cd"" <> ""abcd""")
133 Call ok("ab " & null
= "ab ", """ab"" & null = " & ("ab " & null
))
134 Call ok("ab " & empty
= "ab ", """ab"" & empty = " & ("ab " & empty
))
135 Call ok(1 & 100000 = "1100000", "1 & 100000 = " & (1 & 100000))
136 Call ok("ab" & x
= "abxx", """ab"" & x = " & ("ab"&x
))
138 if(isEnglishLang
) then
139 Call ok("" & true = "True", """"" & true = " & true)
140 Call ok(true & false = "TrueFalse", "true & false = " & (true & false))
143 call ok(true and true, "true and true is not true")
144 call ok(true and not false, "true and not false is not true")
145 call ok(not (false and true), "not (false and true) is not true")
146 call ok(getVT(null
and true) = "VT_NULL", "getVT(null and true) = " & getVT(null
and true))
148 call ok(false or true, "false or uie is false?")
149 call ok(not (false or false), "false or false is not false?")
150 call ok(false and false or true, "false and false or true is false?")
151 call ok(true or false and false, "true or false and false is false?")
152 call ok(null
or true, "null or true is false")
154 call ok(true xor
false, "true xor false is false?")
155 call ok(not (false xor
false), "false xor false is true?")
156 call ok(not (true or false xor
true), "true or false xor true is true?")
157 call ok(not (true xor
false or true), "true xor false or true is true?")
159 call ok(false eqv
false, "false does not equal false?")
160 call ok(not (false eqv
true), "false equals true?")
161 call ok(getVT(false eqv null
) = "VT_NULL", "getVT(false eqv null) = " & getVT(false eqv null
))
163 call ok(true imp
true, "true does not imp true?")
164 call ok(false imp
false, "false does not imp false?")
165 call ok(not (true imp
false), "true imp false?")
166 call ok(false imp null
, "false imp null is false?")
168 Call ok(2 >= 1, "! 2 >= 1")
169 Call ok(2 >= 2, "! 2 >= 2")
170 Call ok(not(true >= 2), "true >= 2 ?")
171 Call ok(2 > 1, "! 2 > 1")
172 Call ok(false > true, "! false < true")
173 Call ok(0 > true, "! 0 > true")
174 Call ok(not (true > 0), "true > 0")
175 Call ok(not (0 > 1 = 1), "0 > 1 = 1")
176 Call ok(1 < 2, "! 1 < 2")
177 Call ok(1 = 1 < 0, "! 1 = 1 < 0")
178 Call ok(1 <= 2, "! 1 <= 2")
179 Call ok(2 <= 2, "! 2 <= 2")
181 Call ok(isNull(0 = null
), "'(0 = null)' is not null")
182 Call ok(isNull(null
= 1), "'(null = 1)' is not null")
183 Call ok(isNull(0 > null
), "'(0 > null)' is not null")
184 Call ok(isNull(null
> 1), "'(null > 1)' is not null")
185 Call ok(isNull(0 < null
), "'(0 < null)' is not null")
186 Call ok(isNull(null
< 1), "'(null < 1)' is not null")
187 Call ok(isNull(0 <> null
), "'(0 <> null)' is not null")
188 Call ok(isNull(null
<> 1), "'(null <> 1)' is not null")
189 Call ok(isNull(0 >= null
), "'(0 >= null)' is not null")
190 Call ok(isNull(null
>= 1), "'(null >= 1)' is not null")
191 Call ok(isNull(0 <= null
), "'(0 <= null)' is not null")
192 Call ok(isNull(null
<= 1), "'(null <= 1)' is not null")
195 Call ok(2+2 = 4, "2+2 = " & (2+2))
196 Call ok(false + 6 + true = 5, "false + 6 + true <> 5")
197 Call ok(getVT(2+null
) = "VT_NULL", "getVT(2+null) = " & getVT(2+null
))
198 Call ok(2+empty
= 2, "2+empty = " & (2+empty
))
199 Call ok(x
+x
= 6, "x+x = " & (x
+x
))
201 Call ok(5-1 = 4, "5-1 = " & (5-1))
202 Call ok(3+5-true = 9, "3+5-true <> 9")
203 Call ok(getVT(2-null
) = "VT_NULL", "getVT(2-null) = " & getVT(2-null
))
204 Call ok(2-empty
= 2, "2-empty = " & (2-empty
))
205 Call ok(2-x
= -1, "2-x = " & (2-x
))
207 Call ok(9 Mod
6 = 3, "9 Mod 6 = " & (9 Mod
6))
208 Call ok(11.6 Mod
5.5 = False, "11.6 Mod 5.5 = " & (11.6 Mod
5.5 = 0.6))
209 Call ok(7 Mod
4+2 = 5, "7 Mod 4+2 <> 5")
210 Call ok(getVT(2 mod null
) = "VT_NULL", "getVT(2 mod null) = " & getVT(2 mod null
))
211 Call ok(getVT(null mod
2) = "VT_NULL", "getVT(null mod 2) = " & getVT(null mod
2))
212 'FIXME: Call ok(empty mod 2 = 0, "empty mod 2 = " & (empty mod 2))
214 Call ok(5 \
2 = 2, "5 \ 2 = " & (5\
2))
215 Call ok(4.6 \
1.5 = 2, "4.6 \ 1.5 = " & (4.6\
1.5))
216 Call ok(4.6 \
1.49 = 5, "4.6 \ 1.49 = " & (4.6\
1.49))
217 Call ok(2+3\
4 = 2, "2+3\4 = " & (2+3\
4))
219 Call ok(2*3 = 6, "2*3 = " & (2*3))
220 Call ok(3/2 = 1.5, "3/2 = " & (3/2))
221 Call ok(5\
4/2 = 2, "5\4/2 = " & (5\
2/1))
222 Call ok(12/3\
2 = 2, "12/3\2 = " & (12/3\
2))
223 Call ok(5/1000000 = 0.000005, "5/1000000 = " & (5/1000000))
225 Call ok(2^
3 = 8, "2^3 = " & (2^
3))
226 Call ok(2^
3^
2 = 64, "2^3^2 = " & (2^
3^
2))
227 Call ok(-3^
2 = 9, "-3^2 = " & (-3^
2))
228 Call ok(2*3^
2 = 18, "2*3^2 = " & (2*3^
2))
237 if true then y
= true : x
= y
240 x
= true : if false then x
= false
241 ok x
, "x is false, if false called?"
243 if not false then x
= true
244 ok x
, "x is false, if not false not called?"
246 if not false then x
= "test" : x
= true
247 ok x
, "x is false, if not false not called?"
249 if false then x
= y
: call ok(false, "if false .. : called")
251 if false then x
= y
: call ok(false, "if false .. : called") else x
= "else"
252 Call ok(x
= "else", "else not called?")
254 if true then x
= y
else y
= x
: Call ok(false, "in else?")
258 if false then x
= y
: if true then call ok(false, "embedded if called")
260 if false then x
=1 else x
=2 end if
261 if true then x
=1 end if
264 if false then x
= true : x
= true
265 Call ok(x
= false, "x <> false")
268 ok
false, "if false called"
275 Call ok(not x
, "x is false, if not evaluated?")
279 Call ok(false, "inside if false")
283 Call ok(x
, "else not called?")
287 Call ok(false, "inside if false")
289 Call ok(false, "inside elseif not true")
293 Call ok(x
, "else not called?")
297 Call ok(false, "inside if false")
300 ElseIf not False Then
303 Call ok(false, "inside else not true")
305 Call ok(x
, "elseif not called?")
309 Call ok(false, "inside if false")
310 ElseIf not False Then
313 Call ok(x
, "elseif not called?")
317 Call ok(x
, "if 1 not run?")
320 if &h10000
& then x
= true
321 Call ok(x
, "if &h10000& not run?")
331 call ok((x
and y
), "x or y is false after while")
353 ok
false, "if empty executed"
357 ok
false, "while empty executed"
362 ok
false, "if ""0"" executed"
366 Call ok(x
= 1, "if ""0"" else not executed")
372 ok
false, "if ""-1"" else executed"
374 Call ok(x
= 1, "if ""-1"" not executed")
377 WHILE x
< 3 : x
= x
+ 1 : Wend
378 Call ok(x
= 3, "x not equal to 3")
381 WHILE x
< 3 : x
= x
+ 1
383 Call ok(x
= 3, "x not equal to 3")
394 do while not (x
and y
)
400 call ok((x
and y
), "x or y is false after while")
405 do while false : loop
409 ok
false, "exit do didn't work"
413 Do While x
< 2 : x
= x
+ 1
415 Call ok(x
= 2, "x not equal to 2")
418 Do While x
< 2 : x
= x
+ 1: Loop
419 Call ok(x
= 2, "x not equal to 2")
425 Call ok(x
= -3, "x not equal to -3")
435 call ok((x
and y
), "x or y is false after do until")
442 ok
false, "exit do didn't work"
448 Call ok(x
= 4, "x not equal to 4")
451 Do: :: x
= x
+ 2 ::: : Loop Until x
= 4
452 Call ok(x
= 4, "x not equal to 4")
459 Call ok(x
= 40, "x not equal to 40")
467 call ok(x
, "x is false after do..loop?")
475 Call ok(x
= 6, "x not equal to 6")
485 call ok((x
and y
), "x or y is false after while")
492 ok
false, "exit do didn't work"
502 loop while not (x
and y
)
503 call ok((x
and y
), "x or y is false after while")
510 ok
false, "exit do didn't work"
517 Call ok(y
= "for1: 5 6 7 8", "y = " & y
)
520 for x
= 5 to 8 step
2
523 Call ok(y
= "for2: 5 7", "y = " & y
)
530 Call ok(y
= "for3: 5 6 7 8", "y = " & y
)
536 Call ok(y
= "for4:", "y = " & y
)
539 for x
= 5 to 3 step
true
542 Call ok(y
= "for5: 5 4 3", "y = " & y
)
546 for x
= 5 to z step
3-4
550 Call ok(y
= "for6: 5 4", "y = " & y
)
554 for x
= 5 to 8 step z
558 Call ok(y
= "for7: 5 6 7 8", "y = " & y
)
561 For x
= 10 To 18 Step
2 : : z
= z
+ 1
563 Call ok(z
= 5, "z not equal to 5")
570 Call ok(y
= "for8: 5 7", "y = " & y
)
573 Call ok(false, "for..to called when unexpected")
578 Call ok(false, "exit for not escaped the loop?")
584 Call ok(false, "exit for not escaped the loop?")
589 for x
=1 to 8:a1(x
)=x
-1:next
590 Call ok(a1(6) = 5, "colon used in for loop")
595 Call ok(a1(6) = 4, "colon used in for loop")
603 if null
then call ok(false, "if null evaluated")
606 call ok(false, "while null evaluated")
609 Call collectionObj
.reset()
611 for each x
in collectionObj
:
615 Call ok(y
= 9, "y = " & y
)
617 Call collectionObj
.reset()
621 for each x
in collectionObj
: z
= z
+ 2
623 Call ok(x
= y
, "x <> y")
625 Call ok(y
= 3, "y = " & y
)
626 Call ok(z
= 6, "z = " & z
)
627 Call ok(getVT(x
) = "VT_EMPTY*", "getVT(x) = " & getVT(x
))
629 Call collectionObj
.reset()
633 for each x
in collectionObj
: z
= z
+ 2 : y
= y
+1 ::
634 Call ok(x
= y
, "x <> y") : next
635 Call ok(y
= 3, "y = " & y
)
636 Call ok(z
= 6, "z = " & z
)
638 Call collectionObj
.reset()
640 for each x
in collectionObj
641 if x
= 2 then exit for
644 Call ok(y
= 1, "y = " & y
)
645 Call ok(x
= 2, "x = " & x
)
647 Set obj
= collectionObj
653 Call ok(x
= y
, "x <> y")
655 Call ok(y
= 3, "y = " & y
)
656 Call ok(getVT(x
) = "VT_EMPTY*", "getVT(x) = " & getVT(x
))
661 Call ok(false, "unexpected case")
663 Call ok(false, "unexpected case")
665 Call ok(false, "unexpected case")
668 Call ok(false, "unexpected case")
669 case 0, false, 2+1, 10
671 case ok(false, "unexpected case")
672 Call ok(false, "unexpected case")
674 Call ok(false, "unexpected case")
676 Call ok(x
, "wrong case")
683 Call ok(x
, "wrong case")
688 Call ok(false, "unexpected case")
692 Call ok(x
, "wrong case")
700 Call ok(false, "unexpected case")
702 Call ok(x
, "wrong case")
706 Call ok(false, "unexpected case")
708 Call ok(false, "unexpected case")
716 case 3,1,2,4: x
= true
718 Call ok(false, "unexpected case")
720 Call ok(x
, "wrong case")
723 select case 2: case 5,6,7: Call ok(false, "unexpected case")
726 case else: Call ok(false, "unexpected case else")
728 Call ok(x
, "wrong case")
738 Call ok(false, "unexpected case") :
743 Call ok(x
, "wrong case")
748 'empty else with comment test
751 select case 0 : case 1 : case else : end select
761 Call ok(x
, "x is false, testsub not called?")
764 Call ok(not v
, "v is not true")
770 Call ok(x
, "x was not set by SubSetTrue")
773 Call ok(not false, "false is no longer false?")
775 Sub SubSetTrue2(ByRef v
)
776 Call ok(not v
, "v is not true")
782 Call ok(x
, "x was not set by SubSetTrue")
784 Sub TestSubArgVal(ByVal v
)
785 Call ok(not v
, "v is not false")
787 Call ok(v
, "v is not true?")
791 Call TestSubArgVal(x
)
792 Call ok(not x
, "x is true after TestSubArgVal call?")
794 Sub TestSubMultiArgs(a
,b
,c
,d
,e
)
795 Call ok(a
=1, "a = " & a
)
796 Call ok(b
=2, "b = " & b
)
797 Call ok(c
=3, "c = " & c
)
798 Call ok(d
=4, "d = " & d
)
799 Call ok(e
=5, "e = " & e
)
802 Sub TestSubExit(ByRef a
)
806 Call ok(false, "Exit Sub not called?")
809 Call TestSubExit(true)
818 TestSubMultiArgs
1, 2, 3, 4, 5
819 Call TestSubMultiArgs(1, 2, 3, 4, 5)
823 Call ok(not x
, "local x is not false?")
831 Call ok(x
, "global x is not true?")
833 Public Sub TestPublicSub
837 Private Sub TestPrivateSub
841 Public Sub TestSeparatorSub
: :
844 Call TestSeparatorSub
854 Call ok(x
, "x is false, testfunc not called?")
856 Function FuncSetTrue(v
)
857 Call ok(not v
, "v is not true")
863 Call ok(x
, "x was not set by FuncSetTrue")
866 Call ok(not false, "false is no longer false?")
868 Function FuncSetTrue2(ByRef v
)
869 Call ok(not v
, "v is not true")
875 Call ok(x
, "x was not set by FuncSetTrue")
877 Function TestFuncArgVal(ByVal v
)
878 Call ok(not v
, "v is not false")
880 Call ok(v
, "v is not true?")
884 Call TestFuncArgVal(x
)
885 Call ok(not x
, "x is true after TestFuncArgVal call?")
887 Function TestFuncMultiArgs(a
,b
,c
,d
,e
)
888 Call ok(a
=1, "a = " & a
)
889 Call ok(b
=2, "b = " & b
)
890 Call ok(c
=3, "c = " & c
)
891 Call ok(d
=4, "d = " & d
)
892 Call ok(e
=5, "e = " & e
)
895 TestFuncMultiArgs
1, 2, 3, 4, 5
896 Call TestFuncMultiArgs(1, 2, 3, 4, 5)
898 Function TestFuncLocalVal
900 Call ok(not x
, "local x is not false?")
906 Call TestFuncLocalVal
907 Call ok(x
, "global x is not true?")
909 Function TestFuncExit(ByRef a
)
913 Call ok(false, "Exit Function not called?")
916 Call TestFuncExit(true)
918 Function TestFuncExit2(ByRef a
)
924 Call ok(false, "Exit Function not called?")
927 Call TestFuncExit2(true)
933 Function FuncParseTest
934 End Function : x
= false
941 Call ok(ReturnTrue(), "ReturnTrue returned false?")
943 Function SetVal(ByRef x
, ByVal v
)
950 ok
SetVal(x
, true), "SetVal returned false?"
951 Call ok(x
, "x is not set to true by SetVal?")
953 Public Function TestPublicFunc
957 Private Function TestPrivateFunc
961 Public Function TestSepFunc(ByVal a
) : :
964 Call ok(TestSepFunc(1) = 1, "Function did not return 1")
966 ok
duplicatedfunc() = 2, "duplicatedfunc = " & duplicatedfunc()
968 function duplicatedfunc
969 ok
false, "duplicatedfunc called"
973 ok
false, "duplicatedfunc called"
976 function duplicatedfunc
980 ok
duplicatedfunc() = 2, "duplicatedfunc = " & duplicatedfunc()
982 ' Stop has an effect only in debugging mode
986 Call ok(getVT(x
) = "VT_DISPATCH*", "getVT(x=testObj) = " & getVT(x
))
988 Set obj
= New EmptyClass
989 Call ok(getVT(obj
) = "VT_DISPATCH*", "getVT(obj) = " & getVT(obj
))
995 Call ok(getVT(x
) = "VT_DISPATCH*", "getVT(x) = " & getVT(x
))
1002 Public Function publicFunction()
1007 Public Property Get gsProp()
1008 gsProp
= privateProp
1009 funcCalled
= "gsProp get"
1011 Call ok(false, "exit property not returned?")
1014 Public Default
Property Get DefValGet
1015 DefValGet
= privateProp
1016 funcCalled
= "GetDefVal"
1019 Public Property Let DefValGet(x
)
1024 Public Sub publicSub
1027 Public Property Let gsProp(val
)
1029 funcCalled
= "gsProp let"
1031 Call ok(false, "exit property not returned?")
1034 Public Property Set gsProp(val
)
1035 funcCalled
= "gsProp set"
1037 Call ok(false, "exit property not returned?")
1040 Public Sub setPrivateProp(x
)
1044 Function getPrivateProp
1045 getPrivateProp
= privateProp
1048 Private Sub privateSub
1051 Public Sub Class_Initialize
1054 Call ok(getVT(privateProp
) = "VT_BOOL*", "getVT(privateProp) = " & getVT(privateProp
))
1055 Call ok(getVT(publicProp2
) = "VT_I2*", "getVT(publicProp2) = " & getVT(publicProp2
))
1056 Call ok(getVT(Me.publicProp2
) = "VT_I2", "getVT(Me.publicProp2) = " & getVT(Me.publicProp2
))
1059 Property Get gsGetProp(x
)
1064 Call testDisp(new testClass
)
1066 Set obj
= New TestClass
1068 Call ok(obj
.publicFunction
= 4, "obj.publicFunction = " & obj
.publicFunction
)
1069 Call ok(obj
.publicFunction() = 4, "obj.publicFunction() = " & obj
.publicFunction())
1073 Call obj
.publicFunction()
1075 Call ok(getVT(obj
.publicProp
) = "VT_EMPTY", "getVT(obj.publicProp) = " & getVT(obj
.publicProp
))
1077 Call ok(getVT(obj
.publicProp
) = "VT_I2", "getVT(obj.publicProp) = " & getVT(obj
.publicProp
))
1078 Call ok(obj
.publicProp
= 3, "obj.publicProp = " & obj
.publicProp
)
1079 obj
.publicProp() = 3
1081 Call ok(obj
.getPrivateProp() = true, "obj.getPrivateProp() = " & obj
.getPrivateProp())
1082 Call obj
.setPrivateProp(6)
1083 Call ok(obj
.getPrivateProp
= 6, "obj.getPrivateProp = " & obj
.getPrivateProp
)
1087 Call ok(obj
.gsProp
= 6, "obj.gsProp = " & obj
.gsProp
)
1088 Call ok(funcCalled
= "gsProp get", "funcCalled = " & funcCalled
)
1090 Call ok(funcCalled
= "gsProp let", "funcCalled = " & funcCalled
)
1091 Call ok(obj
.getPrivateProp
= 3, "obj.getPrivateProp = " & obj
.getPrivateProp
)
1092 Set obj
.gsProp
= New testclass
1093 Call ok(funcCalled
= "gsProp set", "funcCalled = " & funcCalled
)
1096 Call ok(x
= 3, "(x = obj) = " & x
)
1097 Call ok(funcCalled
= "GetDefVal", "funcCalled = " & funcCalled
)
1099 Call ok(obj
= 3, "(x = obj) = " & obj
)
1100 Call ok(funcCalled
= "GetDefVal", "funcCalled = " & funcCalled
)
1102 Call obj
.Class_Initialize
1103 Call ok(obj
.getPrivateProp() = true, "obj.getPrivateProp() = " & obj
.getPrivateProp())
1105 x
= (New testclass
).publicProp
1108 Public Sub Class_Terminate()
1109 funcCalled
= "terminate"
1113 Set obj
= New TermTest
1116 Call ok(funcCalled
= "terminate", "funcCalled = " & funcCalled
)
1118 Set obj
= New TermTest
1120 Call obj
.Class_Terminate
1121 Call ok(funcCalled
= "terminate", "funcCalled = " & funcCalled
)
1124 Call ok(funcCalled
= "terminate", "funcCalled = " & funcCalled
)
1126 Call (New testclass
).publicSub()
1127 Call (New testclass
).publicSub
1130 property get prop0()
1134 property get prop1(x
)
1138 property get prop2(x
, y
)
1143 set obj
= new PropTest
1145 call ok(obj
.prop0
= 1, "obj.prop0 = " & obj
.prop0
)
1146 call ok(obj
.prop1(3) = 4, "obj.prop1(3) = " & obj
.prop1(3))
1147 call ok(obj
.prop2(3,4) = 7, "obj.prop2(3,4) = " & obj
.prop2(3,4))
1152 x
= "following ':' is correct syntax" :
1153 x
= "following ':' is correct syntax" :: :
1154 :: x
= "also correct syntax"
1155 rem another ugly way for comments
1156 x
= "rem as simplestatement" : rem rem comment
1159 Set obj
= new EmptyClass
1161 Set y
= new EmptyClass
1163 Call ok(obj is x
, "obj is not x")
1164 Call ok(x is obj
, "x is not obj")
1165 Call ok(not (obj is y
), "obj is not y")
1166 Call ok(not obj is y
, "obj is not y")
1167 Call ok(not (x is
Nothing), "x is 1")
1168 Call ok(Nothing is
Nothing, "Nothing is not Nothing")
1169 Call ok(x is obj
and true, "x is obj and true is false")
1172 Public Sub Test(MyMe
)
1173 Call ok(Me is MyMe
, "Me is not MyMe")
1177 Set obj
= New TestMe
1180 Call ok(getVT(test
) = "VT_DISPATCH", "getVT(test) = " & getVT(test
))
1181 Call ok(Me is Test
, "Me is not Test")
1183 Const c1
= 1, c2
= 2, c3
= -3
1184 Call ok(c1
= 1, "c1 = " & c1
)
1185 Call ok(getVT(c1
) = "VT_I2", "getVT(c1) = " & getVT(c1
))
1186 Call ok(c3
= -3, "c3 = " & c3
)
1187 Call ok(getVT(c3
) = "VT_I2", "getVT(c3) = " & getVT(c3
))
1189 Const cb
= True, cs
= "test", cnull
= null
1190 Call ok(cb
, "cb = " & cb
)
1191 Call ok(getVT(cb
) = "VT_BOOL", "getVT(cb) = " & getVT(cb
))
1192 Call ok(cs
= "test", "cs = " & cs
)
1193 Call ok(getVT(cs
) = "VT_BSTR", "getVT(cs) = " & getVT(cs
))
1194 Call ok(isNull(cnull
), "cnull = " & cnull
)
1195 Call ok(getVT(cnull
) = "VT_NULL", "getVT(cnull) = " & getVT(cnull
))
1197 Call ok(+1 = 1, "+1 != 1")
1198 Call ok(+true = true, "+1 != 1")
1199 Call ok(getVT(+true) = "VT_BOOL", "getVT(+true) = " & getVT(+true))
1200 Call ok(+"true" = "true", """+true"" != true")
1201 Call ok(getVT(+"true") = "VT_BSTR", "getVT(+""true"") = " & getVT(+"true"))
1202 Call ok(+obj is obj
, "+obj != obj")
1203 Call ok(+--+-+1 = -1, "+--+-+1 != -1")
1205 if false then Const conststr
= "str"
1206 Call ok(conststr
= "str", "conststr = " & conststr
)
1207 Call ok(getVT(conststr
) = "VT_BSTR", "getVT(conststr) = " & getVT(conststr
))
1208 Call ok(conststr
= "str", "conststr = " & conststr
)
1212 Call ok(c1
= 1, "c1 = " & c1
)
1213 Call ok(funcconst
= 1, "funcconst = " & funcconst
)
1219 ' Property may be used as an identifier (although it's a keyword)
1223 Call ok(property, "property = " & property)
1225 for property = 1 to 2
1232 Public Sub Property()
1235 Sub Test(byref property)
1246 Sub Test2(byval property)
1250 Class SeparatorTest
: : Dim varTest1
1252 Private Sub Class_Initialize
: varTest1
= 1
1255 Property Get Test1() :
1259 Property Let Test1(a
) :
1263 Public Function AddToTest1(ByVal a
) :: :
1264 varTest1
= varTest1
+ a
1265 AddToTest1
= varTest1
1266 End Function : End Class
: :: Set obj
= New SeparatorTest
1268 Call ok(obj
.Test1
= 1, "obj.Test1 is not 1")
1270 Call ok(obj
.Test1
= 6, "obj.Test1 is not 6")
1272 Call ok(obj
.Test1
= 11, "obj.Test1 is not 11")
1276 call ok(getVT(obj
) = "VT_UNKNOWN*", "getVT(obj) = " & getVT(obj
))
1277 call ok(getVT(x
) = "VT_UNKNOWN*", "getVT(x) = " & getVT(x
))
1278 call ok(getVT(unkObj
) = "VT_UNKNOWN", "getVT(unkObj) = " & getVT(unkObj
))
1279 call ok(obj is unkObj
, "obj is not unkObj")
1283 Call ok(getVT(arr
) = "VT_EMPTY*", "getVT(arr) = " & getVT(arr
))
1286 Dim arr2(4,3), arr3(5,4,3), arr0(0), noarr()
1288 Call ok(getVT(arr
) = "VT_ARRAY|VT_BYREF|VT_VARIANT*", "getVT(arr) = " & getVT(arr
))
1289 Call ok(getVT(arr2
) = "VT_ARRAY|VT_BYREF|VT_VARIANT*", "getVT(arr2) = " & getVT(arr2
))
1290 Call ok(getVT(arr0
) = "VT_ARRAY|VT_BYREF|VT_VARIANT*", "getVT(arr0) = " & getVT(arr0
))
1291 Call ok(getVT(noarr
) = "VT_ARRAY|VT_BYREF|VT_VARIANT*", "getVT(noarr) = " & getVT(noarr
))
1293 Call testArray(1, arr
)
1294 Call testArray(2, arr2
)
1295 Call testArray(3, arr3
)
1296 Call testArray(0, arr0
)
1297 Call testArray(-1, noarr
)
1299 Call ok(getVT(arr(1)) = "VT_EMPTY*", "getVT(arr(1)) = " & getVT(arr(1)))
1300 Call ok(getVT(arr2(1,2)) = "VT_EMPTY*", "getVT(arr2(1,2)) = " & getVT(arr2(1,2)))
1301 Call ok(getVT(arr3(1,2,2)) = "VT_EMPTY*", "getVT(arr3(1,2,3)) = " & getVT(arr3(1,2,2)))
1302 Call ok(getVT(arr(0)) = "VT_EMPTY*", "getVT(arr(0)) = " & getVT(arr(0)))
1303 Call ok(getVT(arr(3)) = "VT_EMPTY*", "getVT(arr(3)) = " & getVT(arr(3)))
1304 Call ok(getVT(arr0(0)) = "VT_EMPTY*", "getVT(arr0(0)) = " & getVT(arr0(0)))
1307 Call ok(arr(2) = 3, "arr(2) = " & arr(2))
1308 Call ok(getVT(arr(2)) = "VT_I2*", "getVT(arr(2)) = " & getVT(arr(2)))
1312 Call ok(arr3(3,2,1) = 1, "arr3(3,2,1) = " & arr3(3,2,1))
1313 Call ok(arr3(1,2,3) = 2, "arr3(1,2,3) = " & arr3(1,2,3))
1315 Call ok(arr2(4,3) = 1, "arr2(4,3) = " & arr2(4,3))
1318 Call ok(x(3,2,1) = 1, "x(3,2,1) = " & x(3,2,1))
1328 Call ok(getVT(x
) = "VT_ARRAY|VT_VARIANT*", "getVT(x) = " & getVT(x
))
1329 Call ok(x(2) = 2, "x(2) = " & x(2))
1330 Call ok(getVT(x(3)) = "VT_EMPTY*", "getVT(x(3)) = " & getVT(x(3)))
1333 Call ok(x(1) = 1, "x(1) = " & x(1))
1335 Call ok(getVT(x(1)) = "VT_EMPTY*", "getVT(x(1)) = " & getVT(x(1)))
1336 Call ok(x(2) = 2, "x(2) = " & x(2))
1341 Call ok(y(1) = 1, "y(1) = " & y(1))
1346 Call ok(getVT(forarr(1)) = "VT_EMPTY*", "getVT(forarr(1)) = " & getVT(forarr(1)))
1348 Call ok(forarr(1) = x
, "forarr(1) = " & forarr(1))
1354 Call ok(forarr(x
) = 2, "forarr(x) = " & forarr(x
))
1357 ok
arr(1) = 1, "arr(1) = " & arr(1)
1362 ok
arr(1) = 2, "arr(1) = " & arr(1)
1365 ok
arr2(x
,y
) = 1, "arr2(x,y) = " & arr2(x
,y
)
1370 call accessArr2(1, 2)
1371 ok
arr2(1,2) = 2, "arr2(1,2) = " & arr2(1,2)
1374 call ok(x(0)(0) = 3, "x(0)(0) = " & x(0)(0))
1383 ok
x(0) = 2, "x(0) = " & x(0)
1387 ok
x(0) = 1, "x(0) = " & x(0)
1390 call (((seta0
))) ((x
))
1391 ok
x(0) = 1, "x(0) = " & x(0)
1394 call (((seta0
))) (x
)
1395 ok
x(0) = 2, "x(0) = " & x(0)
1399 call ok(x(0)(0) = 2, "x(0)(0) = " & x(0)(0))
1403 call ok(x(0)(0) = 3, "x(0)(0) = " & x(0)(0))
1406 ok y
= 1, "y = " & y
1409 ok y
= 2, "y = " & y
1417 ok
x(0) = 2, "x(0) = " & x(0)
1418 ok
getVT(x
) = "VT_ARRAY|VT_VARIANT*", "getVT(x) after redim = " & getVT(x
)
1422 ok
x(0) = 1, "x(0) = " & x(0)
1426 ok
ubound(x
) = 4, "ubound(x) = " & ubound(x
)
1427 ok
x(0) = empty
, "x(0) = " & x(0)
1431 ok
ubound(x
) = 3, "ubound(x) = " & ubound(x
)
1439 ok
ubound(x
) = 1, "ubound(x) = " & ubound(x
)
1440 ok
x(0) = 1, "x(0) = " & x(1)
1441 ok
x(1) = 2, "x(1) = " & x(1)
1444 ok
ubound(x
) = 2, "ubound(x) = " & ubound(x
)
1445 ok
x(0) = 1, "x(0) = " & x(0)
1446 ok
x(1) = 2, "x(1) = " & x(1)
1447 ok
x(2) = vbEmpty
, "x(2) = " & x(2)
1449 on error resume next
1450 redim preserve x(2,2)
1453 ok e
= 9, "e = " & e
' VBSE_OUT_OF_BOUNDS, cannot change cDims
1457 ok
lbound(x
) = 0, "lbound(x) = " & lbound(x
)
1458 ok
ubound(x
) = -1, "ubound(x) = " & ubound(x
)
1461 ok
ubound(x
) = 3, "ubound(x) = " & ubound(x
)
1462 ok
ubound(x
, 1) = 3, "ubound(x, 1) = " & ubound(x
, 1)
1463 ok
ubound(x
, 2) = 2, "ubound(x, 2) = " & ubound(x
, 2) & " expected 2"
1475 redim preserve x(1,1)
1476 ok
ubound(x
, 1) = 1, "ubound(x, 1) = " & ubound(x
, 1)
1477 ok
ubound(x
, 2) = 1, "ubound(x, 2) = " & ubound(x
, 2)
1478 ok
x(0,0) = 1.1, "x(0,0) = " & x(0,0)
1479 ok
x(0,1) = 1.2, "x(0,1) = " & x(0,1)
1480 ok
x(1,0) = 2.1, "x(1,0) = " & x(1,0)
1481 ok
x(1,1) = 2.2, "x(1,1) = " & x(1,1)
1483 redim preserve x(1,2)
1484 ok
ubound(x
, 1) = 1, "ubound(x, 1) = " & ubound(x
, 1)
1485 ok
ubound(x
, 2) = 2, "ubound(x, 2) = " & ubound(x
, 2)
1486 ok
x(0,0) = 1.1, "x(0,0) = " & x(0,0)
1487 ok
x(0,1) = 1.2, "x(0,1) = " & x(0,1)
1488 ok
x(1,0) = 2.1, "x(1,0) = " & x(1,0)
1489 ok
x(1,1) = 2.2, "x(1,1) = " & x(1,1)
1490 ok
x(0,2) = vbEmpty
, "x(0,2) = " & x(0,2)
1491 ok
x(1,2) = vbEmpty
, "x(1,2) = " & x(1,1)
1493 on error resume next
1494 redim preserve x(2,2)
1497 ok e
= 9, "e = " & e
' VBSE_OUT_OF_BOUNDS, can only change rightmost dimension
1500 on error resume next
1501 redim staticarray(3)
1504 todo_wine_ok e
= 10, "e = " & e
1511 Private Sub Class_Initialize
1512 Call ok(getVT(classarr
) = "VT_ARRAY|VT_BYREF|VT_VARIANT*", "getVT(classarr) = " & getVT(classarr
))
1513 Call testArray(-1, classnoarr
)
1520 Public Sub testVarVT
1521 Call ok(getVT(var
) = "VT_ARRAY|VT_VARIANT*", "getVT(var) = " & getVT(var
))
1525 Set obj
= new ArrClass
1526 Call ok(getVT(obj
.classarr
) = "VT_ARRAY|VT_VARIANT", "getVT(obj.classarr) = " & getVT(obj
.classarr
))
1527 'todo_wine Call ok(obj.classarr(1) = 2, "obj.classarr(1) = " & obj.classarr(1))
1530 Call ok(getVT(obj
.var
) = "VT_ARRAY|VT_VARIANT", "getVT(obj.var) = " & getVT(obj
.var
))
1533 Sub arrarg(byref refarr
, byval valarr
, byref refarr2
, byval valarr2
)
1534 Call ok(getVT(refarr
) = "VT_ARRAY|VT_BYREF|VT_VARIANT*", "getVT(refarr) = " & getVT(refarr
))
1535 Call ok(getVT(valarr
) = "VT_ARRAY|VT_VARIANT*", "getVT(valarr) = " & getVT(valarr
))
1536 Call ok(getVT(refarr2
) = "VT_ARRAY|VT_VARIANT*", "getVT(refarr2) = " & getVT(refarr2
))
1537 Call ok(getVT(valarr2
) = "VT_ARRAY|VT_VARIANT*", "getVT(valarr2) = " & getVT(valarr2
))
1540 Call arrarg(arr
, arr
, obj
.classarr
, obj
.classarr
)
1542 Sub arrarg2(byref refarr(), byval valarr(), byref refarr2(), byval valarr2())
1543 Call ok(getVT(refarr
) = "VT_ARRAY|VT_BYREF|VT_VARIANT*", "getVT(refarr) = " & getVT(refarr
))
1544 Call ok(getVT(valarr
) = "VT_ARRAY|VT_VARIANT*", "getVT(valarr) = " & getVT(valarr
))
1545 Call ok(getVT(refarr2
) = "VT_ARRAY|VT_VARIANT*", "getVT(refarr2) = " & getVT(refarr2
))
1546 Call ok(getVT(valarr2
) = "VT_ARRAY|VT_VARIANT*", "getVT(valarr2) = " & getVT(valarr2
))
1549 Call arrarg2(arr
, arr
, obj
.classarr
, obj
.classarr
)
1551 Sub testarrarg(arg(), vt
)
1552 Call ok(getVT(arg
) = vt
, "getVT() = " & getVT(arg
) & " expected " & vt
)
1555 Call testarrarg(1, "VT_I2*")
1556 Call testarrarg(false, "VT_BOOL*")
1557 Call testarrarg(Empty
, "VT_EMPTY*")
1560 Call ok(arr(0) = "not modified", "arr(0) = " & arr(0))
1564 arr(0) = "not modified"
1566 Call ok(arr(0) = "modified", "arr(0) = " & arr(0))
1568 arr(0) = "not modified"
1570 Call ok(arr(0) = "not modified", "arr(0) = " & arr(0))
1572 for x
= 0 to UBound(arr
)
1577 Call ok(x
= y
, "x = " & x
& ", expected " & y
)
1578 Call ok(arr(y
) = y
, "arr(" & y
& ") = " & arr(y
))
1583 Call ok(y
= 4, "y = " & y
& " after array enumeration")
1585 for x
=0 to UBound(arr2
, 1)
1586 for y
=0 to UBound(arr2
, 2)
1587 arr2(x
, y
) = x
+ y
*(UBound(arr2
, 1)+1)
1592 Call ok(x
= y
, "x = " & x
& ", expected " & y
)
1595 Call ok(y
= 20, "y = " & y
& " after array enumeration")
1598 Call ok(false, "Empty array contains: " & x
)
1601 ' It's allowed to declare non-builtin RegExp class...
1603 public property get Global()
1604 Call ok(false, "Global called")
1609 ' ...but there is no way to use it because builtin instance is always created
1611 Call ok(x
.Global = false, "x.Global = " & x
.Global)
1613 sub test_nothing_errors
1615 on error resume next
1620 call ok(err
.number
= 91, "err.number = " & err
.number
)
1621 call ok(x
= 1, "x = " & x
)
1625 call ok(err
.number
= 91, "err.number = " & err
.number
)
1626 call ok(x
= 1, "x = " & x
)
1630 call ok(err
.number
= 91, "err.number = " & err
.number
)
1631 call ok(x
= 1, "x = " & x
)
1633 call test_nothing_errors()
1635 sub test_identifiers
1636 ' test keywords that can also be a declared identifier
1639 Call ok(default
= "xx", "default = " & default
& " expected ""xx""")
1643 Call ok(error = "xx", "error = " & error & " expected ""xx""")
1647 Call ok(explicit = "xx", "explicit = " & explicit & " expected ""xx""")
1651 Call ok(step
= "xx", "step = " & step
& " expected ""xx""")
1655 Call ok(property = "xx", "property = " & property & " expected ""xx""")
1657 call test_identifiers()
1659 Class class_test_identifiers_as_function_name
1660 Sub Property ( par
)
1663 Function Error( par
)
1669 Function Explicit (par
)
1673 Sub Step ( default
)
1677 Class class_test_identifiers_as_property_name
1678 Public Property Get Property()
1681 Public Property Let Error(par
)
1685 Public Property Set Default(par
)
1690 sub test_dotIdentifiers
1691 ' test keywords that can also be an identifier after a dot
1692 Call ok(testObj
.rem = 10, "testObj.rem = " & testObj.rem & " expected 10")
1693 Call ok(testObj
.true = 10, "testObj.true = " & testObj
.true & " expected 10")
1694 Call ok(testObj
.false = 10, "testObj.false = " & testObj
.false & " expected 10")
1695 Call ok(testObj
.not = 10, "testObj.not = " & testObj
.not & " expected 10")
1696 Call ok(testObj
.and = 10, "testObj.and = " & testObj
.and & " expected 10")
1697 Call ok(testObj
.or = 10, "testObj.or = " & testObj
.or & " expected 10")
1698 Call ok(testObj
.xor
= 10, "testObj.xor = " & testObj
.xor
& " expected 10")
1699 Call ok(testObj
.eqv
= 10, "testObj.eqv = " & testObj
.eqv
& " expected 10")
1700 Call ok(testObj
.imp
= 10, "testObj.imp = " & testObj
.imp
& " expected 10")
1701 Call ok(testObj
.is
= 10, "testObj.is = " & testObj
.is
& " expected 10")
1702 Call ok(testObj
.mod
= 10, "testObj.mod = " & testObj
.mod
& " expected 10")
1703 Call ok(testObj
.call = 10, "testObj.call = " & testObj
.call & " expected 10")
1704 Call ok(testObj
.dim = 10, "testObj.dim = " & testObj
.dim & " expected 10")
1705 Call ok(testObj
.sub = 10, "testObj.sub = " & testObj
.sub & " expected 10")
1706 Call ok(testObj
.function = 10, "testObj.function = " & testObj
.function & " expected 10")
1707 Call ok(testObj
.get = 10, "testObj.get = " & testObj
.get & " expected 10")
1708 Call ok(testObj
.let = 10, "testObj.let = " & testObj
.let & " expected 10")
1709 Call ok(testObj
.const = 10, "testObj.const = " & testObj
.const & " expected 10")
1710 Call ok(testObj
.if = 10, "testObj.if = " & testObj
.if & " expected 10")
1711 Call ok(testObj
.else = 10, "testObj.else = " & testObj
.else & " expected 10")
1712 Call ok(testObj
.elseif = 10, "testObj.elseif = " & testObj
.elseif & " expected 10")
1713 Call ok(testObj
.end = 10, "testObj.end = " & testObj
.end & " expected 10")
1714 Call ok(testObj
.then = 10, "testObj.then = " & testObj
.then & " expected 10")
1715 Call ok(testObj
.exit = 10, "testObj.exit = " & testObj
.exit & " expected 10")
1716 Call ok(testObj
.while = 10, "testObj.while = " & testObj
.while & " expected 10")
1717 Call ok(testObj
.wend = 10, "testObj.wend = " & testObj
.wend & " expected 10")
1718 Call ok(testObj
.do = 10, "testObj.do = " & testObj
.do & " expected 10")
1719 Call ok(testObj
.loop = 10, "testObj.loop = " & testObj
.loop & " expected 10")
1720 Call ok(testObj
.until = 10, "testObj.until = " & testObj
.until & " expected 10")
1721 Call ok(testObj
.for = 10, "testObj.for = " & testObj
.for & " expected 10")
1722 Call ok(testObj
.to = 10, "testObj.to = " & testObj
.to & " expected 10")
1723 Call ok(testObj
.each = 10, "testObj.each = " & testObj
.each & " expected 10")
1724 Call ok(testObj
.in = 10, "testObj.in = " & testObj
.in & " expected 10")
1725 Call ok(testObj
.select = 10, "testObj.select = " & testObj
.select & " expected 10")
1726 Call ok(testObj
.case = 10, "testObj.case = " & testObj
.case & " expected 10")
1727 Call ok(testObj
.byref = 10, "testObj.byref = " & testObj
.byref & " expected 10")
1728 Call ok(testObj
.byval = 10, "testObj.byval = " & testObj
.byval & " expected 10")
1729 Call ok(testObj
.option = 10, "testObj.option = " & testObj
.option & " expected 10")
1730 Call ok(testObj
.nothing = 10, "testObj.nothing = " & testObj
.nothing & " expected 10")
1731 Call ok(testObj
.empty
= 10, "testObj.empty = " & testObj
.empty
& " expected 10")
1732 Call ok(testObj
.null
= 10, "testObj.null = " & testObj
.null
& " expected 10")
1733 Call ok(testObj
.class
= 10, "testObj.class = " & testObj
.class
& " expected 10")
1734 Call ok(testObj
.set = 10, "testObj.set = " & testObj
.set & " expected 10")
1735 Call ok(testObj
.new = 10, "testObj.new = " & testObj
.new & " expected 10")
1736 Call ok(testObj
.public = 10, "testObj.public = " & testObj
.public & " expected 10")
1737 Call ok(testObj
.private = 10, "testObj.private = " & testObj
.private & " expected 10")
1738 Call ok(testObj
.next = 10, "testObj.next = " & testObj
.next & " expected 10")
1739 Call ok(testObj
.on = 10, "testObj.on = " & testObj
.on & " expected 10")
1740 Call ok(testObj
.resume = 10, "testObj.resume = " & testObj
.resume & " expected 10")
1741 Call ok(testObj
.goto = 10, "testObj.goto = " & testObj
.goto & " expected 10")
1742 Call ok(testObj
.with = 10, "testObj.with = " & testObj
.with & " expected 10")
1743 Call ok(testObj
.redim = 10, "testObj.redim = " & testObj
.redim & " expected 10")
1744 Call ok(testObj
.preserve = 10, "testObj.preserve = " & testObj
.preserve & " expected 10")
1745 Call ok(testObj
.property = 10, "testObj.property = " & testObj
.property & " expected 10")
1746 Call ok(testObj
.me = 10, "testObj.me = " & testObj
.me & " expected 10")
1747 Call ok(testObj
.stop = 10, "testObj.stop = " & testObj
.stop & " expected 10")
1749 call test_dotIdentifiers
1751 ' Test End statements not required to be preceded by a newline or separator
1755 Sub EndTestSubWithCall
1757 Call ok(x
= 1, "x = " & x
)End Sub
1758 Call EndTestSubWithCall()
1760 Function EndTestFunc(x
)
1761 Call ok(x
> 0, "x = " & x
)End Function
1764 Class EndTestClassWithStorageId
1767 Class EndTestClassWithDim
1770 Class EndTestClassWithFunc
1771 Function test(ByVal x
)
1772 x
= 0 End Function End Class
1774 Class EndTestClassWithProperty
1776 Public default
Property Get defprop
1777 defprop
= x
End Property End Class
1779 class TestPropSyntax
1786 public default
property get def()
1796 Public Property Set bar(obj
)
1799 Public Property Set foo(par
,obj
)
1801 if obj is
Nothing Then gotNothing
= True
1804 Public Property Let Key(oldKey
,newKey
)
1805 oDict
= oldKey
& newKey
1807 Public Property Let three(uno
,due
,tre
)
1808 oDict
= uno
& due
& tre
1810 Public Property Let ten(a
,b
,c
,d
,e
,f
,g
,h
,i
,j
)
1811 oDict
= a
& b
& c
& d
& e
& f
& g
& h
& i
& j
1815 Set x
= new TestPropParam
1816 x
.key("old") = "new"
1817 call ok(x
.oDict
= "oldnew","x.oDict = " & x
.oDict
& " expected oldnew")
1819 call ok(x
.oDict
= "123","x.oDict = " & x
.oDict
& " expected 123")
1820 x
.ten(1,2,3,4,5,6,7,8,9) = 0
1821 call ok(x
.oDict
= "1234567890","x.oDict = " & x
.oDict
& " expected 1234567890")
1823 call ok(x
.gotNothing
=Empty
,"x.gotNothing = " & x
.gotNothing
& " expected Empty")
1824 Set x
.foo("123") = Nothing
1825 call ok(x
.oDict
= "123","x.oDict = " & x
.oDict
& " expected 123")
1826 call ok(x
.gotNothing
=True,"x.gotNothing = " & x
.gotNothing
& " expected true")
1828 set x
= new TestPropSyntax
1829 set x
.prop
= new TestPropSyntax
1830 set x
.prop
.prop
= new TestPropSyntax
1831 x
.prop
.prop
.prop
= 2
1832 call ok(x
.getProp().getProp
.prop
= 2, "x.getProp().getProp.prop = " & x
.getProp().getProp
.prop
)
1833 x
.getprop
.getprop().prop
= 3
1834 call ok(x
.getProp
.prop
.prop
= 3, "x.getProp.prop.prop = " & x
.getProp
.prop
.prop
)
1835 set x
.getprop
.getprop().prop
= new emptyclass
1836 set obj
= new emptyclass
1837 set x
.getprop
.getprop().prop
= obj
1838 call ok(x
.getprop
.getprop().prop is obj
, "x.getprop.getprop().prop is not obj (emptyclass)")
1840 ok
getVT(x
) = "VT_DISPATCH*", "getVT(x) = " & getVT(x
)
1841 todo_wine_ok
getVT(x()) = "VT_BSTR", "getVT(x()) = " & getVT(x())
1844 class DefaultSubTest1
1845 Public default
Sub init(a
)
1846 funcCalled
= "init" & a
1850 Set obj
= New DefaultSubTest1
1852 call ok(funcCalled
= "init1","funcCalled=" & funcCalled
)
1855 call ok(funcCalled
= "init2","funcCalled=" & funcCalled
)
1857 class DefaultSubTest2
1858 Public Default
Function init
1863 Set obj
= New DefaultSubTest2
1866 call ok(funcCalled
= "init","funcCalled=" & funcCalled
)
1868 ' todo this is not yet supported
1871 'call ok(funcCalled = "init","funcCalled=" & funcCalled)
1876 set x
= new TestPropSyntax
1879 ok
.prop
= 1, ".prop = "&.prop
1881 ok x
.prop
= 1, "x.prop = " & x
.prop
1883 with new TestPropSyntax
1885 ok
.prop
= 1, ".prop = "&.prop
1888 function testsetresult(x
, y
)
1889 set testsetresult
= new TestPropSyntax
1890 testsetresult
.prop
= x
1891 y
= testsetresult
.prop
+ 1
1894 set x
= testsetresult(1, 2)
1895 ok x
.prop
= 1, "x.prop = " & x
.prop
1897 set arr(0) = new TestPropSyntax
1899 ok
arr(0).prop
= 1, "arr(0) = " & arr(0).prop
1901 function recursingfunction(x
)
1902 if (x
) then exit function
1903 recursingfunction
= 2
1905 y
= recursingfunction
1906 call ok(y
= 2, "y = " & y
)
1907 recursingfunction
= 1
1908 call recursingfunction(True)
1910 call ok(recursingfunction(False) = 1, "unexpected return value " & recursingfunction(False))
1913 function recursingfunction2
1914 if (x
) then exit function
1915 recursingfunction2
= 2
1917 y
= recursingfunction2
1918 call ok(y
= 2, "y = " & y
)
1919 recursingfunction2
= 1
1921 recursingfunction2()
1923 call ok(recursingfunction2() = 1, "unexpected return value " & recursingfunction2())
1931 ok x
= true, "x = " & x