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(--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")
58 Call ok(W
= 5, "W = " & W
& " expected " & 5)
61 Call ok(x
= "xx", "x = " & x
& " expected ""xx""")
63 Call ok(true <> false, "true <> false is false")
64 Call ok(not (true <> true), "true <> true is true")
65 Call ok(not ("x" <> "x"), """x"" <> ""x"" is true")
66 Call ok(not (empty
<> empty
), "empty <> empty is true")
67 Call ok(x
<> "x", "x = ""x""")
68 Call ok("true" <> true, """true"" = true is true")
70 Call ok("" = true = false, """"" = true = false is false")
71 Call ok(not(false = true = ""), "false = true = """" is true")
72 Call ok(not (false = false <> false = false), "false = false <> false = false is true")
73 Call ok(not ("" <> false = false), """"" <> false = false is true")
75 Call ok(getVT(false) = "VT_BOOL", "getVT(false) is not VT_BOOL")
76 Call ok(getVT(true) = "VT_BOOL", "getVT(true) is not VT_BOOL")
77 Call ok(getVT("") = "VT_BSTR", "getVT("""") is not VT_BSTR")
78 Call ok(getVT("test") = "VT_BSTR", "getVT(""test"") is not VT_BSTR")
79 Call ok(getVT(Empty
) = "VT_EMPTY", "getVT(Empty) is not VT_EMPTY")
80 Call ok(getVT(null
) = "VT_NULL", "getVT(null) is not VT_NULL")
81 Call ok(getVT(0) = "VT_I2", "getVT(0) is not VT_I2")
82 Call ok(getVT(1) = "VT_I2", "getVT(1) is not VT_I2")
83 Call ok(getVT(0.5) = "VT_R8", "getVT(0.5) is not VT_R8")
84 Call ok(getVT(0.0) = "VT_R8", "getVT(0.0) is not VT_R8")
85 Call ok(getVT(2147483647) = "VT_I4", "getVT(2147483647) is not VT_I4")
86 Call ok(getVT(2147483648) = "VT_R8", "getVT(2147483648) is not VT_R8")
87 Call ok(getVT(&h10
&) = "VT_I2", "getVT(&h10&) is not VT_I2")
88 Call ok(getVT(&h10000
&) = "VT_I4", "getVT(&h10000&) is not VT_I4")
89 Call ok(getVT(&H10000
&) = "VT_I4", "getVT(&H10000&) is not VT_I4")
90 Call ok(getVT(&hffFFffFF
&) = "VT_I2", "getVT(&hffFFffFF&) is not VT_I2")
91 Call ok(getVT(1e2
) = "VT_R8", "getVT(1e2) is not VT_R8")
92 Call ok(getVT(1e0
) = "VT_R8", "getVT(1e0) is not VT_R8")
93 Call ok(getVT(0.1e2
) = "VT_R8", "getVT(0.1e2) is not VT_R8")
94 Call ok(getVT(1 & 100000) = "VT_BSTR", "getVT(1 & 100000) is not VT_BSTR")
95 Call ok(getVT(-empty
) = "VT_I2", "getVT(-empty) = " & getVT(-empty
))
96 Call ok(getVT(-null
) = "VT_NULL", "getVT(-null) = " & getVT(-null
))
97 Call ok(getVT(y
) = "VT_EMPTY*", "getVT(y) = " & getVT(y
))
98 Call ok(getVT(nothing) = "VT_DISPATCH", "getVT(nothing) = " & getVT(nothing))
100 Call ok(getVT(x
) = "VT_DISPATCH*", "getVT(x=nothing) = " & getVT(x
))
102 Call ok(getVT(x
) = "VT_BOOL*", "getVT(x) = " & getVT(x
))
103 Call ok(getVT(false or true) = "VT_BOOL", "getVT(false) is not VT_BOOL")
105 Call ok(getVT(x
) = "VT_BSTR*", "getVT(x) is not VT_BSTR*")
107 Call ok(getVT(x
) = "VT_R8*", "getVT(x) = " & getVT(x
))
109 Call ok(isNullDisp(nothing), "nothing is not nulldisp?")
112 Call ok("ab" & "cd" = "abcd", """ab"" & ""cd"" <> ""abcd""")
113 Call ok("ab " & null
= "ab ", """ab"" & null = " & ("ab " & null
))
114 Call ok("ab " & empty
= "ab ", """ab"" & empty = " & ("ab " & empty
))
115 Call ok(1 & 100000 = "1100000", "1 & 100000 = " & (1 & 100000))
116 Call ok("ab" & x
= "abxx", """ab"" & x = " & ("ab"&x
))
118 if(isEnglishLang
) then
119 Call ok("" & true = "True", """"" & true = " & true)
120 Call ok(true & false = "TrueFalse", "true & false = " & (true & false))
123 call ok(true and true, "true and true is not true")
124 call ok(true and not false, "true and not false is not true")
125 call ok(not (false and true), "not (false and true) is not true")
126 call ok(getVT(null
and true) = "VT_NULL", "getVT(null and true) = " & getVT(null
and true))
128 call ok(false or true, "false or uie is false?")
129 call ok(not (false or false), "false or false is not false?")
130 call ok(false and false or true, "false and false or true is false?")
131 call ok(true or false and false, "true or false and false is false?")
132 call ok(null
or true, "null or true is false")
134 call ok(true xor
false, "true xor false is false?")
135 call ok(not (false xor
false), "false xor false is true?")
136 call ok(not (true or false xor
true), "true or false xor true is true?")
137 call ok(not (true xor
false or true), "true xor false or true is true?")
139 call ok(false eqv
false, "false does not equal false?")
140 call ok(not (false eqv
true), "false equals true?")
141 call ok(getVT(false eqv null
) = "VT_NULL", "getVT(false eqv null) = " & getVT(false eqv null
))
143 call ok(true imp
true, "true does not imp true?")
144 call ok(false imp
false, "false does not imp false?")
145 call ok(not (true imp
false), "true imp false?")
146 call ok(false imp null
, "false imp null is false?")
148 Call ok(2 >= 1, "! 2 >= 1")
149 Call ok(2 >= 2, "! 2 >= 2")
150 Call ok(not(true >= 2), "true >= 2 ?")
151 Call ok(2 > 1, "! 2 > 1")
152 Call ok(false > true, "! false < true")
153 Call ok(0 > true, "! 0 > true")
154 Call ok(not (true > 0), "true > 0")
155 Call ok(not (0 > 1 = 1), "0 > 1 = 1")
156 Call ok(1 < 2, "! 1 < 2")
157 Call ok(1 = 1 < 0, "! 1 = 1 < 0")
158 Call ok(1 <= 2, "! 1 <= 2")
159 Call ok(2 <= 2, "! 2 <= 2")
161 Call ok(isNull(0 = null
), "'(0 = null)' is not null")
162 Call ok(isNull(null
= 1), "'(null = 1)' is not null")
163 Call ok(isNull(0 > null
), "'(0 > null)' is not null")
164 Call ok(isNull(null
> 1), "'(null > 1)' is not null")
165 Call ok(isNull(0 < null
), "'(0 < null)' is not null")
166 Call ok(isNull(null
< 1), "'(null < 1)' is not null")
167 Call ok(isNull(0 <> null
), "'(0 <> null)' is not null")
168 Call ok(isNull(null
<> 1), "'(null <> 1)' is not null")
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")
175 Call ok(2+2 = 4, "2+2 = " & (2+2))
176 Call ok(false + 6 + true = 5, "false + 6 + true <> 5")
177 Call ok(getVT(2+null
) = "VT_NULL", "getVT(2+null) = " & getVT(2+null
))
178 Call ok(2+empty
= 2, "2+empty = " & (2+empty
))
179 Call ok(x
+x
= 6, "x+x = " & (x
+x
))
181 Call ok(5-1 = 4, "5-1 = " & (5-1))
182 Call ok(3+5-true = 9, "3+5-true <> 9")
183 Call ok(getVT(2-null
) = "VT_NULL", "getVT(2-null) = " & getVT(2-null
))
184 Call ok(2-empty
= 2, "2-empty = " & (2-empty
))
185 Call ok(2-x
= -1, "2-x = " & (2-x
))
187 Call ok(9 Mod
6 = 3, "9 Mod 6 = " & (9 Mod
6))
188 Call ok(11.6 Mod
5.5 = False, "11.6 Mod 5.5 = " & (11.6 Mod
5.5 = 0.6))
189 Call ok(7 Mod
4+2 = 5, "7 Mod 4+2 <> 5")
190 Call ok(getVT(2 mod null
) = "VT_NULL", "getVT(2 mod null) = " & getVT(2 mod null
))
191 Call ok(getVT(null mod
2) = "VT_NULL", "getVT(null mod 2) = " & getVT(null mod
2))
192 'FIXME: Call ok(empty mod 2 = 0, "empty mod 2 = " & (empty mod 2))
194 Call ok(5 \
2 = 2, "5 \ 2 = " & (5\
2))
195 Call ok(4.6 \
1.5 = 2, "4.6 \ 1.5 = " & (4.6\
1.5))
196 Call ok(4.6 \
1.49 = 5, "4.6 \ 1.49 = " & (4.6\
1.49))
197 Call ok(2+3\
4 = 2, "2+3\4 = " & (2+3\
4))
199 Call ok(2*3 = 6, "2*3 = " & (2*3))
200 Call ok(3/2 = 1.5, "3/2 = " & (3/2))
201 Call ok(5\
4/2 = 2, "5\4/2 = " & (5\
2/1))
202 Call ok(12/3\
2 = 2, "12/3\2 = " & (12/3\
2))
203 Call ok(5/1000000 = 0.000005, "5/1000000 = " & (5/1000000))
205 Call ok(2^
3 = 8, "2^3 = " & (2^
3))
206 Call ok(2^
3^
2 = 64, "2^3^2 = " & (2^
3^
2))
207 Call ok(-3^
2 = 9, "-3^2 = " & (-3^
2))
208 Call ok(2*3^
2 = 18, "2*3^2 = " & (2*3^
2))
217 if true then y
= true : x
= y
220 x
= true : if false then x
= false
221 ok x
, "x is false, if false called?"
223 if not false then x
= true
224 ok x
, "x is false, if not false not called?"
226 if not false then x
= "test" : x
= true
227 ok x
, "x is false, if not false not called?"
229 if false then x
= y
: call ok(false, "if false .. : called")
231 if false then x
= y
: call ok(false, "if false .. : called") else x
= "else"
232 Call ok(x
= "else", "else not called?")
234 if true then x
= y
else y
= x
: Call ok(false, "in else?")
238 if false then x
= y
: if true then call ok(false, "embedded if called")
240 if false then x
=1 else x
=2 end if
241 if true then x
=1 end if
244 if false then x
= true : x
= true
245 Call ok(x
= false, "x <> false")
248 ok
false, "if false called"
255 Call ok(not x
, "x is false, if not evaluated?")
259 Call ok(false, "inside if false")
263 Call ok(x
, "else not called?")
267 Call ok(false, "inside if false")
269 Call ok(false, "inside elseif not true")
273 Call ok(x
, "else not called?")
277 Call ok(false, "inside if false")
280 ElseIf not False Then
283 Call ok(false, "inside else not true")
285 Call ok(x
, "elseif not called?")
289 Call ok(false, "inside if false")
290 ElseIf not False Then
293 Call ok(x
, "elseif not called?")
297 Call ok(x
, "if 1 not run?")
300 if &h10000
& then x
= true
301 Call ok(x
, "if &h10000& not run?")
311 call ok((x
and y
), "x or y is false after while")
333 ok
false, "if empty executed"
337 ok
false, "while empty executed"
341 WHILE x
< 3 : x
= x
+ 1
343 Call ok(x
= 3, "x not equal to 3")
354 do while not (x
and y
)
360 call ok((x
and y
), "x or y is false after while")
367 ok
false, "exit do didn't work"
371 Do While x
< 2 : x
= x
+ 1
373 Call ok(x
= 2, "x not equal to 2")
379 Call ok(x
= -3, "x not equal to -3")
389 call ok((x
and y
), "x or y is false after do until")
396 ok
false, "exit do didn't work"
402 Call ok(x
= 4, "x not equal to 4")
409 Call ok(x
= 40, "x not equal to 40")
417 call ok(x
, "x is false after do..loop?")
425 Call ok(x
= 6, "x not equal to 6")
435 call ok((x
and y
), "x or y is false after while")
442 ok
false, "exit do didn't work"
452 loop while not (x
and y
)
453 call ok((x
and y
), "x or y is false after while")
460 ok
false, "exit do didn't work"
467 Call ok(y
= "for1: 5 6 7 8", "y = " & y
)
470 for x
= 5 to 8 step
2
473 Call ok(y
= "for2: 5 7", "y = " & y
)
480 Call ok(y
= "for3: 5 6 7 8", "y = " & y
)
486 Call ok(y
= "for4:", "y = " & y
)
489 for x
= 5 to 3 step
true
492 Call ok(y
= "for5: 5 4 3", "y = " & y
)
496 for x
= 5 to z step
3-4
500 Call ok(y
= "for6: 5 4", "y = " & y
)
504 for x
= 5 to 8 step z
508 Call ok(y
= "for7: 5 6 7 8", "y = " & y
)
511 For x
= 10 To 18 Step
2 : : z
= z
+ 1
513 Call ok(z
= 5, "z not equal to 5")
520 Call ok(y
= "for8: 5 7", "y = " & y
)
523 Call ok(false, "for..to called when unexpected")
528 Call ok(false, "exit for not escaped the loop?")
534 Call ok(false, "exit for not escaped the loop?")
543 if null
then call ok(false, "if null evaluated")
546 call ok(false, "while null evaluated")
549 Call collectionObj
.reset()
551 for each x
in collectionObj
:
555 Call ok(y
= 9, "y = " & y
)
557 Call collectionObj
.reset()
561 for each x
in collectionObj
: z
= z
+ 2
563 Call ok(x
= y
, "x <> y")
565 Call ok(y
= 3, "y = " & y
)
566 Call ok(z
= 6, "z = " & z
)
567 Call ok(getVT(x
) = "VT_EMPTY*", "getVT(x) = " & getVT(x
))
569 Call collectionObj
.reset()
571 for each x
in collectionObj
572 if x
= 2 then exit for
575 Call ok(y
= 1, "y = " & y
)
576 Call ok(x
= 2, "x = " & x
)
578 Set obj
= collectionObj
584 Call ok(x
= y
, "x <> y")
586 Call ok(y
= 3, "y = " & y
)
587 Call ok(getVT(x
) = "VT_EMPTY*", "getVT(x) = " & getVT(x
))
592 Call ok(false, "unexpected case")
594 Call ok(false, "unexpected case")
596 Call ok(false, "unexpected case")
599 Call ok(false, "unexpected case")
600 case 0, false, 2+1, 10
602 case ok(false, "unexpected case")
603 Call ok(false, "unexpected case")
605 Call ok(false, "unexpected case")
607 Call ok(x
, "wrong case")
614 Call ok(x
, "wrong case")
619 Call ok(false, "unexpected case")
623 Call ok(x
, "wrong case")
631 Call ok(false, "unexpected case")
633 Call ok(x
, "wrong case")
637 Call ok(false, "unexpected case")
639 Call ok(false, "unexpected case")
647 case 3,1,2,4: x
= true
649 Call ok(false, "unexpected case")
651 Call ok(x
, "wrong case")
654 select case 2: case 5,6,7: Call ok(false, "unexpected case")
657 case else: Call ok(false, "unexpected case else")
659 Call ok(x
, "wrong case")
669 Call ok(false, "unexpected case") :
674 Call ok(x
, "wrong case")
684 Call ok(x
, "x is false, testsub not called?")
687 Call ok(not v
, "v is not true")
693 Call ok(x
, "x was not set by SubSetTrue")
696 Call ok(not false, "false is no longer false?")
698 Sub SubSetTrue2(ByRef v
)
699 Call ok(not v
, "v is not true")
705 Call ok(x
, "x was not set by SubSetTrue")
707 Sub TestSubArgVal(ByVal v
)
708 Call ok(not v
, "v is not false")
710 Call ok(v
, "v is not true?")
714 Call TestSubArgVal(x
)
715 Call ok(not x
, "x is true after TestSubArgVal call?")
717 Sub TestSubMultiArgs(a
,b
,c
,d
,e
)
718 Call ok(a
=1, "a = " & a
)
719 Call ok(b
=2, "b = " & b
)
720 Call ok(c
=3, "c = " & c
)
721 Call ok(d
=4, "d = " & d
)
722 Call ok(e
=5, "e = " & e
)
725 Sub TestSubExit(ByRef a
)
729 Call ok(false, "Exit Sub not called?")
732 Call TestSubExit(true)
741 TestSubMultiArgs
1, 2, 3, 4, 5
742 Call TestSubMultiArgs(1, 2, 3, 4, 5)
746 Call ok(not x
, "local x is not false?")
754 Call ok(x
, "global x is not true?")
756 Public Sub TestPublicSub
760 Private Sub TestPrivateSub
764 Public Sub TestSeparatorSub
: :
767 Call TestSeparatorSub
777 Call ok(x
, "x is false, testfunc not called?")
779 Function FuncSetTrue(v
)
780 Call ok(not v
, "v is not true")
786 Call ok(x
, "x was not set by FuncSetTrue")
789 Call ok(not false, "false is no longer false?")
791 Function FuncSetTrue2(ByRef v
)
792 Call ok(not v
, "v is not true")
798 Call ok(x
, "x was not set by FuncSetTrue")
800 Function TestFuncArgVal(ByVal v
)
801 Call ok(not v
, "v is not false")
803 Call ok(v
, "v is not true?")
807 Call TestFuncArgVal(x
)
808 Call ok(not x
, "x is true after TestFuncArgVal call?")
810 Function TestFuncMultiArgs(a
,b
,c
,d
,e
)
811 Call ok(a
=1, "a = " & a
)
812 Call ok(b
=2, "b = " & b
)
813 Call ok(c
=3, "c = " & c
)
814 Call ok(d
=4, "d = " & d
)
815 Call ok(e
=5, "e = " & e
)
818 TestFuncMultiArgs
1, 2, 3, 4, 5
819 Call TestFuncMultiArgs(1, 2, 3, 4, 5)
821 Function TestFuncLocalVal
823 Call ok(not x
, "local x is not false?")
829 Call TestFuncLocalVal
830 Call ok(x
, "global x is not true?")
832 Function TestFuncExit(ByRef a
)
836 Call ok(false, "Exit Function not called?")
839 Call TestFuncExit(true)
841 Function TestFuncExit2(ByRef a
)
847 Call ok(false, "Exit Function not called?")
850 Call TestFuncExit2(true)
856 Function FuncParseTest
857 End Function : x
= false
864 Call ok(ReturnTrue(), "ReturnTrue returned false?")
866 Function SetVal(ByRef x
, ByVal v
)
873 ok
SetVal(x
, true), "SetVal returned false?"
874 Call ok(x
, "x is not set to true by SetVal?")
876 Public Function TestPublicFunc
880 Private Function TestPrivateFunc
884 Public Function TestSepFunc(ByVal a
) : :
887 Call ok(TestSepFunc(1) = 1, "Function did not return 1")
890 ' Stop has an effect only in debugging mode
894 Call ok(getVT(x
) = "VT_DISPATCH*", "getVT(x=testObj) = " & getVT(x
))
896 Set obj
= New EmptyClass
897 Call ok(getVT(obj
) = "VT_DISPATCH*", "getVT(obj) = " & getVT(obj
))
903 Call ok(getVT(x
) = "VT_DISPATCH*", "getVT(x) = " & getVT(x
))
910 Public Function publicFunction()
915 Public Property Get gsProp()
917 funcCalled
= "gsProp get"
919 Call ok(false, "exit property not returned?")
922 Public Default
Property Get DefValGet
923 DefValGet
= privateProp
924 funcCalled
= "GetDefVal"
927 Public Property Let DefValGet(x
)
935 Public Property Let gsProp(val
)
937 funcCalled
= "gsProp let"
939 Call ok(false, "exit property not returned?")
942 Public Property Set gsProp(val
)
943 funcCalled
= "gsProp set"
945 Call ok(false, "exit property not returned?")
948 Public Sub setPrivateProp(x
)
952 Function getPrivateProp
953 getPrivateProp
= privateProp
956 Private Sub privateSub
959 Public Sub Class_Initialize
962 Call ok(getVT(privateProp
) = "VT_BOOL*", "getVT(privateProp) = " & getVT(privateProp
))
963 Call ok(getVT(publicProp2
) = "VT_I2*", "getVT(publicProp2) = " & getVT(publicProp2
))
964 Call ok(getVT(Me.publicProp2
) = "VT_I2", "getVT(Me.publicProp2) = " & getVT(Me.publicProp2
))
967 Property Get gsGetProp(x
)
972 Call testDisp(new testClass
)
974 Set obj
= New TestClass
976 Call ok(obj
.publicFunction
= 4, "obj.publicFunction = " & obj
.publicFunction
)
977 Call ok(obj
.publicFunction() = 4, "obj.publicFunction() = " & obj
.publicFunction())
981 Call obj
.publicFunction()
983 Call ok(getVT(obj
.publicProp
) = "VT_EMPTY", "getVT(obj.publicProp) = " & getVT(obj
.publicProp
))
985 Call ok(getVT(obj
.publicProp
) = "VT_I2", "getVT(obj.publicProp) = " & getVT(obj
.publicProp
))
986 Call ok(obj
.publicProp
= 3, "obj.publicProp = " & obj
.publicProp
)
989 Call ok(obj
.getPrivateProp() = true, "obj.getPrivateProp() = " & obj
.getPrivateProp())
990 Call obj
.setPrivateProp(6)
991 Call ok(obj
.getPrivateProp
= 6, "obj.getPrivateProp = " & obj
.getPrivateProp
)
995 Call ok(obj
.gsProp
= 6, "obj.gsProp = " & obj
.gsProp
)
996 Call ok(funcCalled
= "gsProp get", "funcCalled = " & funcCalled
)
998 Call ok(funcCalled
= "gsProp let", "funcCalled = " & funcCalled
)
999 Call ok(obj
.getPrivateProp
= 3, "obj.getPrivateProp = " & obj
.getPrivateProp
)
1000 Set obj
.gsProp
= New testclass
1001 Call ok(funcCalled
= "gsProp set", "funcCalled = " & funcCalled
)
1004 Call ok(x
= 3, "(x = obj) = " & x
)
1005 Call ok(funcCalled
= "GetDefVal", "funcCalled = " & funcCalled
)
1007 Call ok(obj
= 3, "(x = obj) = " & obj
)
1008 Call ok(funcCalled
= "GetDefVal", "funcCalled = " & funcCalled
)
1010 Call obj
.Class_Initialize
1011 Call ok(obj
.getPrivateProp() = true, "obj.getPrivateProp() = " & obj
.getPrivateProp())
1013 x
= (New testclass
).publicProp
1016 Public Sub Class_Terminate()
1017 funcCalled
= "terminate"
1021 Set obj
= New TermTest
1024 Call ok(funcCalled
= "terminate", "funcCalled = " & funcCalled
)
1026 Set obj
= New TermTest
1028 Call obj
.Class_Terminate
1029 Call ok(funcCalled
= "terminate", "funcCalled = " & funcCalled
)
1032 Call ok(funcCalled
= "terminate", "funcCalled = " & funcCalled
)
1034 Call (New testclass
).publicSub()
1035 Call (New testclass
).publicSub
1038 property get prop0()
1042 property get prop1(x
)
1046 property get prop2(x
, y
)
1051 set obj
= new PropTest
1053 call ok(obj
.prop0
= 1, "obj.prop0 = " & obj
.prop0
)
1054 call ok(obj
.prop1(3) = 4, "obj.prop1(3) = " & obj
.prop1(3))
1055 call ok(obj
.prop2(3,4) = 7, "obj.prop2(3,4) = " & obj
.prop2(3,4))
1060 x
= "following ':' is correct syntax" :
1061 x
= "following ':' is correct syntax" :: :
1062 :: x
= "also correct syntax"
1063 rem another ugly way for comments
1064 x
= "rem as simplestatement" : rem rem comment
1067 Set obj
= new EmptyClass
1069 Set y
= new EmptyClass
1071 Call ok(obj is x
, "obj is not x")
1072 Call ok(x is obj
, "x is not obj")
1073 Call ok(not (obj is y
), "obj is not y")
1074 Call ok(not obj is y
, "obj is not y")
1075 Call ok(not (x is
Nothing), "x is 1")
1076 Call ok(Nothing is
Nothing, "Nothing is not Nothing")
1077 Call ok(x is obj
and true, "x is obj and true is false")
1080 Public Sub Test(MyMe
)
1081 Call ok(Me is MyMe
, "Me is not MyMe")
1085 Set obj
= New TestMe
1088 Call ok(getVT(test
) = "VT_DISPATCH", "getVT(test) = " & getVT(test
))
1089 Call ok(Me is Test
, "Me is not Test")
1091 Const c1
= 1, c2
= 2, c3
= -3
1092 Call ok(c1
= 1, "c1 = " & c1
)
1093 Call ok(getVT(c1
) = "VT_I2", "getVT(c1) = " & getVT(c1
))
1094 Call ok(c3
= -3, "c3 = " & c3
)
1095 Call ok(getVT(c3
) = "VT_I2", "getVT(c3) = " & getVT(c3
))
1097 Const cb
= True, cs
= "test", cnull
= null
1098 Call ok(cb
, "cb = " & cb
)
1099 Call ok(getVT(cb
) = "VT_BOOL", "getVT(cb) = " & getVT(cb
))
1100 Call ok(cs
= "test", "cs = " & cs
)
1101 Call ok(getVT(cs
) = "VT_BSTR", "getVT(cs) = " & getVT(cs
))
1102 Call ok(isNull(cnull
), "cnull = " & cnull
)
1103 Call ok(getVT(cnull
) = "VT_NULL", "getVT(cnull) = " & getVT(cnull
))
1105 Call ok(+1 = 1, "+1 != 1")
1106 Call ok(+true = true, "+1 != 1")
1107 Call ok(getVT(+true) = "VT_BOOL", "getVT(+true) = " & getVT(+true))
1108 Call ok(+"true" = "true", """+true"" != true")
1109 Call ok(getVT(+"true") = "VT_BSTR", "getVT(+""true"") = " & getVT(+"true"))
1110 Call ok(+obj is obj
, "+obj != obj")
1111 Call ok(+--+-+1 = -1, "+--+-+1 != -1")
1113 if false then Const conststr
= "str"
1114 Call ok(conststr
= "str", "conststr = " & conststr
)
1115 Call ok(getVT(conststr
) = "VT_BSTR", "getVT(conststr) = " & getVT(conststr
))
1116 Call ok(conststr
= "str", "conststr = " & conststr
)
1120 Call ok(c1
= 1, "c1 = " & c1
)
1121 Call ok(funcconst
= 1, "funcconst = " & funcconst
)
1127 ' Property may be used as an identifier (although it's a keyword)
1131 Call ok(property, "property = " & property)
1133 for property = 1 to 2
1140 Public Sub Property()
1143 Sub Test(byref property)
1154 Sub Test2(byval property)
1158 Class SeparatorTest
: : Dim varTest1
1160 Private Sub Class_Initialize
: varTest1
= 1
1163 Property Get Test1() :
1167 Property Let Test1(a
) :
1171 Public Function AddToTest1(ByVal a
) :: :
1172 varTest1
= varTest1
+ a
1173 AddToTest1
= varTest1
1174 End Function : End Class
: :: Set obj
= New SeparatorTest
1176 Call ok(obj
.Test1
= 1, "obj.Test1 is not 1")
1178 Call ok(obj
.Test1
= 6, "obj.Test1 is not 6")
1180 Call ok(obj
.Test1
= 11, "obj.Test1 is not 11")
1184 Call ok(getVT(arr
) = "VT_EMPTY*", "getVT(arr) = " & getVT(arr
))
1187 Dim arr2(4,3), arr3(5,4,3), arr0(0), noarr()
1189 Call ok(getVT(arr
) = "VT_ARRAY|VT_BYREF|VT_VARIANT*", "getVT(arr) = " & getVT(arr
))
1190 Call ok(getVT(arr2
) = "VT_ARRAY|VT_BYREF|VT_VARIANT*", "getVT(arr2) = " & getVT(arr2
))
1191 Call ok(getVT(arr0
) = "VT_ARRAY|VT_BYREF|VT_VARIANT*", "getVT(arr0) = " & getVT(arr0
))
1192 Call ok(getVT(noarr
) = "VT_ARRAY|VT_BYREF|VT_VARIANT*", "getVT(noarr) = " & getVT(noarr
))
1194 Call testArray(1, arr
)
1195 Call testArray(2, arr2
)
1196 Call testArray(3, arr3
)
1197 Call testArray(0, arr0
)
1198 Call testArray(-1, noarr
)
1200 Call ok(getVT(arr(1)) = "VT_EMPTY*", "getVT(arr(1)) = " & getVT(arr(1)))
1201 Call ok(getVT(arr2(1,2)) = "VT_EMPTY*", "getVT(arr2(1,2)) = " & getVT(arr2(1,2)))
1202 Call ok(getVT(arr3(1,2,2)) = "VT_EMPTY*", "getVT(arr3(1,2,3)) = " & getVT(arr3(1,2,2)))
1203 Call ok(getVT(arr(0)) = "VT_EMPTY*", "getVT(arr(0)) = " & getVT(arr(0)))
1204 Call ok(getVT(arr(3)) = "VT_EMPTY*", "getVT(arr(3)) = " & getVT(arr(3)))
1205 Call ok(getVT(arr0(0)) = "VT_EMPTY*", "getVT(arr0(0)) = " & getVT(arr0(0)))
1208 Call ok(arr(2) = 3, "arr(2) = " & arr(2))
1209 Call ok(getVT(arr(2)) = "VT_I2*", "getVT(arr(2)) = " & getVT(arr(2)))
1213 Call ok(arr3(3,2,1) = 1, "arr3(3,2,1) = " & arr3(3,2,1))
1214 Call ok(arr3(1,2,3) = 2, "arr3(1,2,3) = " & arr3(1,2,3))
1216 Call ok(arr2(4,3) = 1, "arr2(4,3) = " & arr2(4,3))
1219 Call ok(x(3,2,1) = 1, "x(3,2,1) = " & x(3,2,1))
1229 Call ok(getVT(x
) = "VT_ARRAY|VT_VARIANT*", "getVT(x) = " & getVT(x
))
1230 Call ok(x(2) = 2, "x(2) = " & x(2))
1231 Call ok(getVT(x(3)) = "VT_EMPTY*", "getVT(x(3)) = " & getVT(x(3)))
1234 Call ok(x(1) = 1, "x(1) = " & x(1))
1236 Call ok(getVT(x(1)) = "VT_EMPTY*", "getVT(x(1)) = " & getVT(x(1)))
1237 Call ok(x(2) = 2, "x(2) = " & x(2))
1242 Call ok(y(1) = 1, "y(1) = " & y(1))
1247 Call ok(getVT(forarr(1)) = "VT_EMPTY*", "getVT(forarr(1)) = " & getVT(forarr(1)))
1249 Call ok(forarr(1) = x
, "forarr(1) = " & forarr(1))
1255 Call ok(forarr(x
) = 2, "forarr(x) = " & forarr(x
))
1258 ok
arr(1) = 1, "arr(1) = " & arr(1)
1263 ok
arr(1) = 2, "arr(1) = " & arr(1)
1266 ok
arr2(x
,y
) = 1, "arr2(x,y) = " & arr2(x
,y
)
1271 call accessArr2(1, 2)
1272 ok
arr2(1,2) = 2, "arr2(1,2) = " & arr2(1,2)
1275 call ok(x(0)(0) = 3, "x(0)(0) = " & x(0)(0))
1284 ok
x(0) = 2, "x(0) = " & x(0)
1288 ok
x(0) = 1, "x(0) = " & x(0)
1291 call (((seta0
))) ((x
))
1292 ok
x(0) = 1, "x(0) = " & x(0)
1295 call (((seta0
))) (x
)
1296 ok
x(0) = 2, "x(0) = " & x(0)
1300 call ok(x(0)(0) = 2, "x(0)(0) = " & x(0)(0))
1304 call ok(x(0)(0) = 3, "x(0)(0) = " & x(0)(0))
1307 ok y
= 1, "y = " & y
1310 ok y
= 2, "y = " & y
1318 ok
x(0) = 2, "x(0) = " & x(0)
1319 ok
getVT(x
) = "VT_ARRAY|VT_VARIANT*", "getVT(x) after redim = " & getVT(x
)
1323 ok
x(0) = 1, "x(0) = " & x(0)
1327 ok
ubound(x
) = 4, "ubound(x) = " & ubound(x
)
1328 ok
x(0) = empty
, "x(0) = " & x(0)
1332 ok
ubound(x
) = 3, "ubound(x) = " & ubound(x
)
1336 ok
lbound(x
) = 0, "lbound(x) = " & lbound(x
)
1337 ok
ubound(x
) = -1, "ubound(x) = " & ubound(x
)
1340 ok
ubound(x
) = 3, "ubound(x) = " & ubound(x
)
1341 ok
ubound(x
, 1) = 3, "ubound(x, 1) = " & ubound(x
, 1)
1342 ok
ubound(x
, 2) = 2, "ubound(x, 2) = " & ubound(x
, 2) & " expected 2"
1345 on error resume next
1346 redim staticarray(3)
1349 todo_wine_ok e
= 10, "e = " & e
1356 Private Sub Class_Initialize
1357 Call ok(getVT(classarr
) = "VT_ARRAY|VT_BYREF|VT_VARIANT*", "getVT(classarr) = " & getVT(classarr
))
1358 Call testArray(-1, classnoarr
)
1365 Public Sub testVarVT
1366 Call ok(getVT(var
) = "VT_ARRAY|VT_VARIANT*", "getVT(var) = " & getVT(var
))
1370 Set obj
= new ArrClass
1371 Call ok(getVT(obj
.classarr
) = "VT_ARRAY|VT_VARIANT", "getVT(obj.classarr) = " & getVT(obj
.classarr
))
1372 'todo_wine Call ok(obj.classarr(1) = 2, "obj.classarr(1) = " & obj.classarr(1))
1375 Call ok(getVT(obj
.var
) = "VT_ARRAY|VT_VARIANT", "getVT(obj.var) = " & getVT(obj
.var
))
1378 Sub arrarg(byref refarr
, byval valarr
, byref refarr2
, byval valarr2
)
1379 Call ok(getVT(refarr
) = "VT_ARRAY|VT_BYREF|VT_VARIANT*", "getVT(refarr) = " & getVT(refarr
))
1380 Call ok(getVT(valarr
) = "VT_ARRAY|VT_VARIANT*", "getVT(valarr) = " & getVT(valarr
))
1381 Call ok(getVT(refarr2
) = "VT_ARRAY|VT_VARIANT*", "getVT(refarr2) = " & getVT(refarr2
))
1382 Call ok(getVT(valarr2
) = "VT_ARRAY|VT_VARIANT*", "getVT(valarr2) = " & getVT(valarr2
))
1385 Call arrarg(arr
, arr
, obj
.classarr
, obj
.classarr
)
1387 Sub arrarg2(byref refarr(), byval valarr(), byref refarr2(), byval valarr2())
1388 Call ok(getVT(refarr
) = "VT_ARRAY|VT_BYREF|VT_VARIANT*", "getVT(refarr) = " & getVT(refarr
))
1389 Call ok(getVT(valarr
) = "VT_ARRAY|VT_VARIANT*", "getVT(valarr) = " & getVT(valarr
))
1390 Call ok(getVT(refarr2
) = "VT_ARRAY|VT_VARIANT*", "getVT(refarr2) = " & getVT(refarr2
))
1391 Call ok(getVT(valarr2
) = "VT_ARRAY|VT_VARIANT*", "getVT(valarr2) = " & getVT(valarr2
))
1394 Call arrarg2(arr
, arr
, obj
.classarr
, obj
.classarr
)
1396 Sub testarrarg(arg(), vt
)
1397 Call ok(getVT(arg
) = vt
, "getVT() = " & getVT(arg
) & " expected " & vt
)
1400 Call testarrarg(1, "VT_I2*")
1401 Call testarrarg(false, "VT_BOOL*")
1402 Call testarrarg(Empty
, "VT_EMPTY*")
1405 Call ok(arr(0) = "not modified", "arr(0) = " & arr(0))
1409 arr(0) = "not modified"
1411 Call ok(arr(0) = "modified", "arr(0) = " & arr(0))
1413 arr(0) = "not modified"
1415 Call ok(arr(0) = "not modified", "arr(0) = " & arr(0))
1417 for x
= 0 to UBound(arr
)
1422 Call ok(x
= y
, "x = " & x
& ", expected " & y
)
1423 Call ok(arr(y
) = y
, "arr(" & y
& ") = " & arr(y
))
1428 Call ok(y
= 4, "y = " & y
& " after array enumeration")
1430 for x
=0 to UBound(arr2
, 1)
1431 for y
=0 to UBound(arr2
, 2)
1432 arr2(x
, y
) = x
+ y
*(UBound(arr2
, 1)+1)
1437 Call ok(x
= y
, "x = " & x
& ", expected " & y
)
1440 Call ok(y
= 20, "y = " & y
& " after array enumeration")
1443 Call ok(false, "Empty array contains: " & x
)
1446 ' It's allowed to declare non-builtin RegExp class...
1448 public property get Global()
1449 Call ok(false, "Global called")
1454 ' ...but there is no way to use it because builtin instance is always created
1456 Call ok(x
.Global = false, "x.Global = " & x
.Global)
1458 sub test_nothing_errors
1460 on error resume next
1465 call ok(err
.number
= 91, "err.number = " & err
.number
)
1466 call ok(x
= 1, "x = " & x
)
1470 call ok(err
.number
= 91, "err.number = " & err
.number
)
1471 call ok(x
= 1, "x = " & x
)
1475 call ok(err
.number
= 91, "err.number = " & err
.number
)
1476 call ok(x
= 1, "x = " & x
)
1478 call test_nothing_errors()
1480 sub test_identifiers
1481 ' test keywords that can also be a declared identifier
1484 Call ok(default
= "xx", "default = " & default
& " expected ""xx""")
1488 Call ok(error = "xx", "error = " & error & " expected ""xx""")
1492 Call ok(explicit = "xx", "explicit = " & explicit & " expected ""xx""")
1496 Call ok(step
= "xx", "step = " & step
& " expected ""xx""")
1498 call test_identifiers()
1500 sub test_dotIdentifiers
1501 ' test keywords that can also be an identifier after a dot
1502 ' Call ok(testObj.rem = 10, "testObj.rem = " & testObj.rem & " expected 10")
1503 Call ok(testObj
.true = 10, "testObj.true = " & testObj
.true & " expected 10")
1504 Call ok(testObj
.false = 10, "testObj.false = " & testObj
.false & " expected 10")
1505 Call ok(testObj
.not = 10, "testObj.not = " & testObj
.not & " expected 10")
1506 Call ok(testObj
.and = 10, "testObj.and = " & testObj
.and & " expected 10")
1507 Call ok(testObj
.or = 10, "testObj.or = " & testObj
.or & " expected 10")
1508 Call ok(testObj
.xor
= 10, "testObj.xor = " & testObj
.xor
& " expected 10")
1509 Call ok(testObj
.eqv
= 10, "testObj.eqv = " & testObj
.eqv
& " expected 10")
1510 Call ok(testObj
.imp
= 10, "testObj.imp = " & testObj
.imp
& " expected 10")
1511 Call ok(testObj
.is
= 10, "testObj.is = " & testObj
.is
& " expected 10")
1512 Call ok(testObj
.mod
= 10, "testObj.mod = " & testObj
.mod
& " expected 10")
1513 Call ok(testObj
.call = 10, "testObj.call = " & testObj
.call & " expected 10")
1514 Call ok(testObj
.dim = 10, "testObj.dim = " & testObj
.dim & " expected 10")
1515 Call ok(testObj
.sub = 10, "testObj.sub = " & testObj
.sub & " expected 10")
1516 Call ok(testObj
.function = 10, "testObj.function = " & testObj
.function & " expected 10")
1517 Call ok(testObj
.get = 10, "testObj.get = " & testObj
.get & " expected 10")
1518 Call ok(testObj
.let = 10, "testObj.let = " & testObj
.let & " expected 10")
1519 Call ok(testObj
.const = 10, "testObj.const = " & testObj
.const & " expected 10")
1520 Call ok(testObj
.if = 10, "testObj.if = " & testObj
.if & " expected 10")
1521 Call ok(testObj
.else = 10, "testObj.else = " & testObj
.else & " expected 10")
1522 Call ok(testObj
.elseif = 10, "testObj.elseif = " & testObj
.elseif & " expected 10")
1523 Call ok(testObj
.end = 10, "testObj.end = " & testObj
.end & " expected 10")
1524 Call ok(testObj
.then = 10, "testObj.then = " & testObj
.then & " expected 10")
1525 Call ok(testObj
.exit = 10, "testObj.exit = " & testObj
.exit & " expected 10")
1526 Call ok(testObj
.while = 10, "testObj.while = " & testObj
.while & " expected 10")
1527 Call ok(testObj
.wend = 10, "testObj.wend = " & testObj
.wend & " expected 10")
1528 Call ok(testObj
.do = 10, "testObj.do = " & testObj
.do & " expected 10")
1529 Call ok(testObj
.loop = 10, "testObj.loop = " & testObj
.loop & " expected 10")
1530 Call ok(testObj
.until = 10, "testObj.until = " & testObj
.until & " expected 10")
1531 Call ok(testObj
.for = 10, "testObj.for = " & testObj
.for & " expected 10")
1532 Call ok(testObj
.to = 10, "testObj.to = " & testObj
.to & " expected 10")
1533 Call ok(testObj
.each = 10, "testObj.each = " & testObj
.each & " expected 10")
1534 Call ok(testObj
.in = 10, "testObj.in = " & testObj
.in & " expected 10")
1535 Call ok(testObj
.select = 10, "testObj.select = " & testObj
.select & " expected 10")
1536 Call ok(testObj
.case = 10, "testObj.case = " & testObj
.case & " expected 10")
1537 Call ok(testObj
.byref = 10, "testObj.byref = " & testObj
.byref & " expected 10")
1538 Call ok(testObj
.byval = 10, "testObj.byval = " & testObj
.byval & " expected 10")
1539 Call ok(testObj
.option = 10, "testObj.option = " & testObj
.option & " expected 10")
1540 Call ok(testObj
.nothing = 10, "testObj.nothing = " & testObj
.nothing & " expected 10")
1541 Call ok(testObj
.empty
= 10, "testObj.empty = " & testObj
.empty
& " expected 10")
1542 Call ok(testObj
.null
= 10, "testObj.null = " & testObj
.null
& " expected 10")
1543 Call ok(testObj
.class
= 10, "testObj.class = " & testObj
.class
& " expected 10")
1544 Call ok(testObj
.set = 10, "testObj.set = " & testObj
.set & " expected 10")
1545 Call ok(testObj
.new = 10, "testObj.new = " & testObj
.new & " expected 10")
1546 Call ok(testObj
.public = 10, "testObj.public = " & testObj
.public & " expected 10")
1547 Call ok(testObj
.private = 10, "testObj.private = " & testObj
.private & " expected 10")
1548 Call ok(testObj
.next = 10, "testObj.next = " & testObj
.next & " expected 10")
1549 Call ok(testObj
.on = 10, "testObj.on = " & testObj
.on & " expected 10")
1550 Call ok(testObj
.resume = 10, "testObj.resume = " & testObj
.resume & " expected 10")
1551 Call ok(testObj
.goto = 10, "testObj.goto = " & testObj
.goto & " expected 10")
1552 Call ok(testObj
.with = 10, "testObj.with = " & testObj
.with & " expected 10")
1553 Call ok(testObj
.redim = 10, "testObj.redim = " & testObj
.redim & " expected 10")
1554 Call ok(testObj
.preserve = 10, "testObj.preserve = " & testObj
.preserve & " expected 10")
1556 call test_dotIdentifiers
1558 ' Test End statements not required to be preceeded by a newline or separator
1562 Sub EndTestSubWithCall
1564 Call ok(x
= 1, "x = " & x
)End Sub
1565 Call EndTestSubWithCall()
1567 Function EndTestFunc(x
)
1568 Call ok(x
> 0, "x = " & x
)End Function
1571 Class EndTestClassWithStorageId
1574 Class EndTestClassWithDim
1577 Class EndTestClassWithFunc
1578 Function test(ByVal x
)
1579 x
= 0 End Function End Class
1581 Class EndTestClassWithProperty
1583 Public default
Property Get defprop
1584 defprop
= x
End Property End Class
1586 class TestPropSyntax
1593 public default
property get def()
1598 set x
= new TestPropSyntax
1599 set x
.prop
= new TestPropSyntax
1600 set x
.prop
.prop
= new TestPropSyntax
1601 x
.prop
.prop
.prop
= 2
1602 call ok(x
.getProp().getProp
.prop
= 2, "x.getProp().getProp.prop = " & x
.getProp().getProp
.prop
)
1603 x
.getprop
.getprop().prop
= 3
1604 call ok(x
.getProp
.prop
.prop
= 3, "x.getProp.prop.prop = " & x
.getProp
.prop
.prop
)
1606 ok
getVT(x
) = "VT_DISPATCH*", "getVT(x) = " & getVT(x
)
1607 todo_wine_ok
getVT(x()) = "VT_BSTR", "getVT(x()) = " & getVT(x())
1612 set x
= new TestPropSyntax
1615 ok
.prop
= 1, ".prop = "&.prop
1617 ok x
.prop
= 1, "x.prop = " & x
.prop
1619 with new TestPropSyntax
1621 ok
.prop
= 1, ".prop = "&.prop