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
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(56.789e5
= 5678900, "56.789e5 = 5678900")
45 Call ok(56.789e-2 = 0.56789, "56.789e-2 <> 0.56789")
46 Call ok(1e-94938484 = 0, "1e-... <> 0")
47 Call ok(34e0
= 34, "34e0 <> 34")
48 Call ok(34E1
= 340, "34E0 <> 340")
49 Call ok(--1 = 1, "--1 = " & --1)
50 Call ok(-empty
= 0, "-empty = " & (-empty
))
51 Call ok(true = -1, "! true = -1")
52 Call ok(false = 0, "false <> 0")
53 Call ok(&hff
= 255, "&hff <> 255")
54 Call ok(&Hff
= 255, "&Hff <> 255")
57 Call ok(x
= "xx", "x = " & x
& " expected ""xx""")
59 Call ok(true <> false, "true <> false is false")
60 Call ok(not (true <> true), "true <> true is true")
61 Call ok(not ("x" <> "x"), """x"" <> ""x"" is true")
62 Call ok(not (empty
<> empty
), "empty <> empty is true")
63 Call ok(x
<> "x", "x = ""x""")
64 Call ok("true" <> true, """true"" = true is true")
66 Call ok("" = true = false, """"" = true = false is false")
67 Call ok(not(false = true = ""), "false = true = """" is true")
68 Call ok(not (false = false <> false = false), "false = false <> false = false is true")
69 Call ok(not ("" <> false = false), """"" <> false = false is true")
71 Call ok(getVT(false) = "VT_BOOL", "getVT(false) is not VT_BOOL")
72 Call ok(getVT(true) = "VT_BOOL", "getVT(true) is not VT_BOOL")
73 Call ok(getVT("") = "VT_BSTR", "getVT("""") is not VT_BSTR")
74 Call ok(getVT("test") = "VT_BSTR", "getVT(""test"") is not VT_BSTR")
75 Call ok(getVT(Empty
) = "VT_EMPTY", "getVT(Empty) is not VT_EMPTY")
76 Call ok(getVT(null
) = "VT_NULL", "getVT(null) is not VT_NULL")
77 Call ok(getVT(0) = "VT_I2", "getVT(0) is not VT_I2")
78 Call ok(getVT(1) = "VT_I2", "getVT(1) is not VT_I2")
79 Call ok(getVT(0.5) = "VT_R8", "getVT(0.5) is not VT_R8")
80 Call ok(getVT(0.0) = "VT_R8", "getVT(0.0) is not VT_R8")
81 Call ok(getVT(2147483647) = "VT_I4", "getVT(2147483647) is not VT_I4")
82 Call ok(getVT(2147483648) = "VT_R8", "getVT(2147483648) is not VT_R8")
83 Call ok(getVT(&h10
&) = "VT_I2", "getVT(&h10&) is not VT_I2")
84 Call ok(getVT(&h10000
&) = "VT_I4", "getVT(&h10000&) is not VT_I4")
85 Call ok(getVT(&H10000
&) = "VT_I4", "getVT(&H10000&) is not VT_I4")
86 Call ok(getVT(&hffFFffFF
&) = "VT_I2", "getVT(&hffFFffFF&) is not VT_I2")
87 Call ok(getVT(1e2
) = "VT_R8", "getVT(1e2) is not VT_R8")
88 Call ok(getVT(1e0
) = "VT_R8", "getVT(1e0) is not VT_R8")
89 Call ok(getVT(0.1e2
) = "VT_R8", "getVT(0.1e2) is not VT_R8")
90 Call ok(getVT(1 & 100000) = "VT_BSTR", "getVT(1 & 100000) is not VT_BSTR")
91 Call ok(getVT(-empty
) = "VT_I2", "getVT(-empty) = " & getVT(-empty
))
92 Call ok(getVT(-null
) = "VT_NULL", "getVT(-null) = " & getVT(-null
))
93 Call ok(getVT(y
) = "VT_EMPTY*", "getVT(y) = " & getVT(y
))
94 Call ok(getVT(nothing) = "VT_DISPATCH", "getVT(nothing) = " & getVT(nothing))
96 Call ok(getVT(x
) = "VT_DISPATCH*", "getVT(x=nothing) = " & getVT(x
))
98 Call ok(getVT(x
) = "VT_BOOL*", "getVT(x) = " & getVT(x
))
99 Call ok(getVT(false or true) = "VT_BOOL", "getVT(false) is not VT_BOOL")
101 Call ok(getVT(x
) = "VT_BSTR*", "getVT(x) is not VT_BSTR*")
103 Call ok(getVT(x
) = "VT_R8*", "getVT(x) = " & getVT(x
))
105 Call ok(isNullDisp(nothing), "nothing is not nulldisp?")
108 Call ok("ab" & "cd" = "abcd", """ab"" & ""cd"" <> ""abcd""")
109 Call ok("ab " & null
= "ab ", """ab"" & null = " & ("ab " & null
))
110 Call ok("ab " & empty
= "ab ", """ab"" & empty = " & ("ab " & empty
))
111 Call ok(1 & 100000 = "1100000", "1 & 100000 = " & (1 & 100000))
112 Call ok("ab" & x
= "abxx", """ab"" & x = " & ("ab"&x
))
114 if(isEnglishLang
) then
115 Call ok("" & true = "True", """"" & true = " & true)
116 Call ok(true & false = "TrueFalse", "true & false = " & (true & false))
119 call ok(true and true, "true and true is not true")
120 call ok(true and not false, "true and not false is not true")
121 call ok(not (false and true), "not (false and true) is not true")
122 call ok(getVT(null
and true) = "VT_NULL", "getVT(null and true) = " & getVT(null
and true))
124 call ok(false or true, "false or uie is false?")
125 call ok(not (false or false), "false or false is not false?")
126 call ok(false and false or true, "false and false or true is false?")
127 call ok(true or false and false, "true or false and false is false?")
128 call ok(null
or true, "null or true is false")
130 call ok(true xor
false, "true xor false is false?")
131 call ok(not (false xor
false), "false xor false is true?")
132 call ok(not (true or false xor
true), "true or false xor true is true?")
133 call ok(not (true xor
false or true), "true xor false or true is true?")
135 call ok(false eqv
false, "false does not equal false?")
136 call ok(not (false eqv
true), "false equals true?")
137 call ok(getVT(false eqv null
) = "VT_NULL", "getVT(false eqv null) = " & getVT(false eqv null
))
139 call ok(true imp
true, "true does not imp true?")
140 call ok(false imp
false, "false does not imp false?")
141 call ok(not (true imp
false), "true imp false?")
142 call ok(false imp null
, "false imp null is false?")
144 Call ok(2 >= 1, "! 2 >= 1")
145 Call ok(2 >= 2, "! 2 >= 2")
146 Call ok(not(true >= 2), "true >= 2 ?")
147 Call ok(2 > 1, "! 2 > 1")
148 Call ok(false > true, "! false < true")
149 Call ok(0 > true, "! 0 > true")
150 Call ok(not (true > 0), "true > 0")
151 Call ok(not (0 > 1 = 1), "0 > 1 = 1")
152 Call ok(1 < 2, "! 1 < 2")
153 Call ok(1 = 1 < 0, "! 1 = 1 < 0")
154 Call ok(1 <= 2, "! 1 <= 2")
155 Call ok(2 <= 2, "! 2 <= 2")
157 Call ok(isNull(0 = null
), "'(0 = null)' is not null")
158 Call ok(isNull(null
= 1), "'(null = 1)' is not null")
159 Call ok(isNull(0 > null
), "'(0 > null)' is not null")
160 Call ok(isNull(null
> 1), "'(null > 1)' is not null")
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")
171 Call ok(2+2 = 4, "2+2 = " & (2+2))
172 Call ok(false + 6 + true = 5, "false + 6 + true <> 5")
173 Call ok(getVT(2+null
) = "VT_NULL", "getVT(2+null) = " & getVT(2+null
))
174 Call ok(2+empty
= 2, "2+empty = " & (2+empty
))
175 Call ok(x
+x
= 6, "x+x = " & (x
+x
))
177 Call ok(5-1 = 4, "5-1 = " & (5-1))
178 Call ok(3+5-true = 9, "3+5-true <> 9")
179 Call ok(getVT(2-null
) = "VT_NULL", "getVT(2-null) = " & getVT(2-null
))
180 Call ok(2-empty
= 2, "2-empty = " & (2-empty
))
181 Call ok(2-x
= -1, "2-x = " & (2-x
))
183 Call ok(9 Mod
6 = 3, "9 Mod 6 = " & (9 Mod
6))
184 Call ok(11.6 Mod
5.5 = False, "11.6 Mod 5.5 = " & (11.6 Mod
5.5 = 0.6))
185 Call ok(7 Mod
4+2 = 5, "7 Mod 4+2 <> 5")
186 Call ok(getVT(2 mod null
) = "VT_NULL", "getVT(2 mod null) = " & getVT(2 mod null
))
187 Call ok(getVT(null mod
2) = "VT_NULL", "getVT(null mod 2) = " & getVT(null mod
2))
188 'FIXME: Call ok(empty mod 2 = 0, "empty mod 2 = " & (empty mod 2))
190 Call ok(5 \
2 = 2, "5 \ 2 = " & (5\
2))
191 Call ok(4.6 \
1.5 = 2, "4.6 \ 1.5 = " & (4.6\
1.5))
192 Call ok(4.6 \
1.49 = 5, "4.6 \ 1.49 = " & (4.6\
1.49))
193 Call ok(2+3\
4 = 2, "2+3\4 = " & (2+3\
4))
195 Call ok(2*3 = 6, "2*3 = " & (2*3))
196 Call ok(3/2 = 1.5, "3/2 = " & (3/2))
197 Call ok(5\
4/2 = 2, "5\4/2 = " & (5\
2/1))
198 Call ok(12/3\
2 = 2, "12/3\2 = " & (12/3\
2))
199 Call ok(5/1000000 = 0.000005, "5/1000000 = " & (5/1000000))
201 Call ok(2^
3 = 8, "2^3 = " & (2^
3))
202 Call ok(2^
3^
2 = 64, "2^3^2 = " & (2^
3^
2))
203 Call ok(-3^
2 = 9, "-3^2 = " & (-3^
2))
204 Call ok(2*3^
2 = 18, "2*3^2 = " & (2*3^
2))
213 if true then y
= true : x
= y
216 x
= true : if false then x
= false
217 ok x
, "x is false, if false called?"
219 if not false then x
= true
220 ok x
, "x is false, if not false not called?"
222 if not false then x
= "test" : x
= true
223 ok x
, "x is false, if not false not called?"
225 if false then x
= y
: call ok(false, "if false .. : called")
227 if false then x
= y
: call ok(false, "if false .. : called") else x
= "else"
228 Call ok(x
= "else", "else not called?")
230 if true then x
= y
else y
= x
: Call ok(false, "in else?")
234 if false then x
= y
: if true then call ok(false, "embedded if called")
236 if false then x
=1 else x
=2 end if
237 if true then x
=1 end if
240 if false then x
= true : x
= true
241 Call ok(x
= false, "x <> false")
244 ok
false, "if false called"
251 Call ok(not x
, "x is false, if not evaluated?")
255 Call ok(false, "inside if false")
259 Call ok(x
, "else not called?")
263 Call ok(false, "inside if false")
265 Call ok(false, "inside elseif not true")
269 Call ok(x
, "else not called?")
273 Call ok(false, "inside if false")
276 ElseIf not False Then
279 Call ok(false, "inside else not true")
281 Call ok(x
, "elseif not called?")
285 Call ok(false, "inside if false")
286 ElseIf not False Then
289 Call ok(x
, "elseif not called?")
293 Call ok(x
, "if 1 not run?")
296 if &h10000
& then x
= true
297 Call ok(x
, "if &h10000& not run?")
307 call ok((x
and y
), "x or y is false after while")
329 WHILE x
< 3 : x
= x
+ 1
331 Call ok(x
= 3, "x not equal to 3")
342 do while not (x
and y
)
348 call ok((x
and y
), "x or y is false after while")
355 ok
false, "exit do didn't work"
359 Do While x
< 2 : x
= x
+ 1
361 Call ok(x
= 2, "x not equal to 2")
367 Call ok(x
= -3, "x not equal to -3")
377 call ok((x
and y
), "x or y is false after do until")
384 ok
false, "exit do didn't work"
390 Call ok(x
= 4, "x not equal to 4")
397 Call ok(x
= 40, "x not equal to 40")
405 call ok(x
, "x is false after do..loop?")
413 Call ok(x
= 6, "x not equal to 6")
423 call ok((x
and y
), "x or y is false after while")
430 ok
false, "exit do didn't work"
440 loop while not (x
and y
)
441 call ok((x
and y
), "x or y is false after while")
448 ok
false, "exit do didn't work"
455 Call ok(y
= "for1: 5 6 7 8", "y = " & y
)
458 for x
= 5 to 8 step
2
461 Call ok(y
= "for2: 5 7", "y = " & y
)
468 Call ok(y
= "for3: 5 6 7 8", "y = " & y
)
474 Call ok(y
= "for4:", "y = " & y
)
477 for x
= 5 to 3 step
true
480 Call ok(y
= "for5: 5 4 3", "y = " & y
)
484 for x
= 5 to z step
3-4
488 Call ok(y
= "for6: 5 4", "y = " & y
)
492 for x
= 5 to 8 step z
496 Call ok(y
= "for7: 5 6 7 8", "y = " & y
)
499 For x
= 10 To 18 Step
2 : : z
= z
+ 1
501 Call ok(z
= 5, "z not equal to 5")
508 Call ok(y
= "for8: 5 7", "y = " & y
)
511 Call ok(false, "for..to called when unexpected")
516 Call ok(false, "exit for not escaped the loop?")
522 Call ok(false, "exit for not escaped the loop?")
531 if null
then call ok(false, "if null evaluated")
534 call ok(false, "while null evaluated")
537 Call collectionObj
.reset()
539 for each x
in collectionObj
:
543 Call ok(y
= 9, "y = " & y
)
545 Call collectionObj
.reset()
549 for each x
in collectionObj
: z
= z
+ 2
551 Call ok(x
= y
, "x <> y")
553 Call ok(y
= 3, "y = " & y
)
554 Call ok(z
= 6, "z = " & z
)
555 Call ok(getVT(x
) = "VT_EMPTY*", "getVT(x) = " & getVT(x
))
557 Call collectionObj
.reset()
559 for each x
in collectionObj
560 if x
= 2 then exit for
563 Call ok(y
= 1, "y = " & y
)
564 Call ok(x
= 2, "x = " & x
)
566 Set obj
= collectionObj
572 Call ok(x
= y
, "x <> y")
574 Call ok(y
= 3, "y = " & y
)
575 Call ok(getVT(x
) = "VT_EMPTY*", "getVT(x) = " & getVT(x
))
580 Call ok(false, "unexpected case")
582 Call ok(false, "unexpected case")
584 Call ok(false, "unexpected case")
587 Call ok(false, "unexpected case")
588 case 0, false, 2+1, 10
590 case ok(false, "unexpected case")
591 Call ok(false, "unexpected case")
593 Call ok(false, "unexpected case")
595 Call ok(x
, "wrong case")
602 Call ok(x
, "wrong case")
607 Call ok(false, "unexpected case")
611 Call ok(x
, "wrong case")
619 Call ok(false, "unexpected case")
621 Call ok(x
, "wrong case")
625 Call ok(false, "unexpected case")
627 Call ok(false, "unexpected case")
635 case 3,1,2,4: x
= true
637 Call ok(false, "unexpected case")
639 Call ok(x
, "wrong case")
642 select case 2: case 5,6,7: Call ok(false, "unexpected case")
645 case else: Call ok(false, "unexpected case else")
647 Call ok(x
, "wrong case")
657 Call ok(false, "unexpected case") :
662 Call ok(x
, "wrong case")
672 Call ok(x
, "x is false, testsub not called?")
675 Call ok(not v
, "v is not true")
681 Call ok(x
, "x was not set by SubSetTrue")
684 Call ok(not false, "false is no longer false?")
686 Sub SubSetTrue2(ByRef v
)
687 Call ok(not v
, "v is not true")
693 Call ok(x
, "x was not set by SubSetTrue")
695 Sub TestSubArgVal(ByVal v
)
696 Call ok(not v
, "v is not false")
698 Call ok(v
, "v is not true?")
702 Call TestSubArgVal(x
)
703 Call ok(not x
, "x is true after TestSubArgVal call?")
705 Sub TestSubMultiArgs(a
,b
,c
,d
,e
)
706 Call ok(a
=1, "a = " & a
)
707 Call ok(b
=2, "b = " & b
)
708 Call ok(c
=3, "c = " & c
)
709 Call ok(d
=4, "d = " & d
)
710 Call ok(e
=5, "e = " & e
)
713 Sub TestSubExit(ByRef a
)
717 Call ok(false, "Exit Sub not called?")
720 Call TestSubExit(true)
729 TestSubMultiArgs
1, 2, 3, 4, 5
730 Call TestSubMultiArgs(1, 2, 3, 4, 5)
734 Call ok(not x
, "local x is not false?")
742 Call ok(x
, "global x is not true?")
744 Public Sub TestPublicSub
748 Private Sub TestPrivateSub
760 Call ok(x
, "x is false, testfunc not called?")
762 Function FuncSetTrue(v
)
763 Call ok(not v
, "v is not true")
769 Call ok(x
, "x was not set by FuncSetTrue")
772 Call ok(not false, "false is no longer false?")
774 Function FuncSetTrue2(ByRef v
)
775 Call ok(not v
, "v is not true")
781 Call ok(x
, "x was not set by FuncSetTrue")
783 Function TestFuncArgVal(ByVal v
)
784 Call ok(not v
, "v is not false")
786 Call ok(v
, "v is not true?")
790 Call TestFuncArgVal(x
)
791 Call ok(not x
, "x is true after TestFuncArgVal call?")
793 Function TestFuncMultiArgs(a
,b
,c
,d
,e
)
794 Call ok(a
=1, "a = " & a
)
795 Call ok(b
=2, "b = " & b
)
796 Call ok(c
=3, "c = " & c
)
797 Call ok(d
=4, "d = " & d
)
798 Call ok(e
=5, "e = " & e
)
801 TestFuncMultiArgs
1, 2, 3, 4, 5
802 Call TestFuncMultiArgs(1, 2, 3, 4, 5)
804 Function TestFuncLocalVal
806 Call ok(not x
, "local x is not false?")
812 Call TestFuncLocalVal
813 Call ok(x
, "global x is not true?")
815 Function TestFuncExit(ByRef a
)
819 Call ok(false, "Exit Function not called?")
822 Call TestFuncExit(true)
824 Function TestFuncExit2(ByRef a
)
830 Call ok(false, "Exit Function not called?")
833 Call TestFuncExit2(true)
839 Function FuncParseTest
840 End Function : x
= false
847 Call ok(ReturnTrue(), "ReturnTrue returned false?")
849 Function SetVal(ByRef x
, ByVal v
)
856 ok
SetVal(x
, true), "SetVal returned false?"
857 Call ok(x
, "x is not set to true by SetVal?")
859 Public Function TestPublicFunc
863 Private Function TestPrivateFunc
867 ' Stop has an effect only in debugging mode
871 Call ok(getVT(x
) = "VT_DISPATCH*", "getVT(x=testObj) = " & getVT(x
))
873 Set obj
= New EmptyClass
874 Call ok(getVT(obj
) = "VT_DISPATCH*", "getVT(obj) = " & getVT(obj
))
880 Call ok(getVT(x
) = "VT_DISPATCH*", "getVT(x) = " & getVT(x
))
887 Public Function publicFunction()
892 Public Property Get gsProp()
894 funcCalled
= "gsProp get"
896 Call ok(false, "exit property not returned?")
899 Public Default
Property Get DefValGet
900 DefValGet
= privateProp
901 funcCalled
= "GetDefVal"
904 Public Property Let DefValGet(x
)
912 Public Property Let gsProp(val
)
914 funcCalled
= "gsProp let"
916 Call ok(false, "exit property not returned?")
919 Public Property Set gsProp(val
)
920 funcCalled
= "gsProp set"
922 Call ok(false, "exit property not returned?")
925 Public Sub setPrivateProp(x
)
929 Function getPrivateProp
930 getPrivateProp
= privateProp
933 Private Sub privateSub
936 Public Sub Class_Initialize
939 Call ok(getVT(privateProp
) = "VT_BOOL*", "getVT(privateProp) = " & getVT(privateProp
))
940 Call ok(getVT(publicProp2
) = "VT_I2*", "getVT(publicProp2) = " & getVT(publicProp2
))
941 Call ok(getVT(Me.publicProp2
) = "VT_I2", "getVT(Me.publicProp2) = " & getVT(Me.publicProp2
))
944 Property Get gsGetProp(x
)
949 Call testDisp(new testClass
)
951 Set obj
= New TestClass
953 Call ok(obj
.publicFunction
= 4, "obj.publicFunction = " & obj
.publicFunction
)
954 Call ok(obj
.publicFunction() = 4, "obj.publicFunction() = " & obj
.publicFunction())
958 Call obj
.publicFunction()
960 Call ok(getVT(obj
.publicProp
) = "VT_EMPTY", "getVT(obj.publicProp) = " & getVT(obj
.publicProp
))
962 Call ok(getVT(obj
.publicProp
) = "VT_I2", "getVT(obj.publicProp) = " & getVT(obj
.publicProp
))
963 Call ok(obj
.publicProp
= 3, "obj.publicProp = " & obj
.publicProp
)
966 Call ok(obj
.getPrivateProp() = true, "obj.getPrivateProp() = " & obj
.getPrivateProp())
967 Call obj
.setPrivateProp(6)
968 Call ok(obj
.getPrivateProp
= 6, "obj.getPrivateProp = " & obj
.getPrivateProp
)
972 Call ok(obj
.gsProp
= 6, "obj.gsProp = " & obj
.gsProp
)
973 Call ok(funcCalled
= "gsProp get", "funcCalled = " & funcCalled
)
975 Call ok(funcCalled
= "gsProp let", "funcCalled = " & funcCalled
)
976 Call ok(obj
.getPrivateProp
= 3, "obj.getPrivateProp = " & obj
.getPrivateProp
)
977 Set obj
.gsProp
= New testclass
978 Call ok(funcCalled
= "gsProp set", "funcCalled = " & funcCalled
)
981 Call ok(x
= 3, "(x = obj) = " & x
)
982 Call ok(funcCalled
= "GetDefVal", "funcCalled = " & funcCalled
)
984 Call ok(obj
= 3, "(x = obj) = " & obj
)
985 Call ok(funcCalled
= "GetDefVal", "funcCalled = " & funcCalled
)
987 Call obj
.Class_Initialize
988 Call ok(obj
.getPrivateProp() = true, "obj.getPrivateProp() = " & obj
.getPrivateProp())
990 x
= (New testclass
).publicProp
993 Public Sub Class_Terminate()
994 funcCalled
= "terminate"
998 Set obj
= New TermTest
1001 Call ok(funcCalled
= "terminate", "funcCalled = " & funcCalled
)
1003 Set obj
= New TermTest
1005 Call obj
.Class_Terminate
1006 Call ok(funcCalled
= "terminate", "funcCalled = " & funcCalled
)
1009 Call ok(funcCalled
= "terminate", "funcCalled = " & funcCalled
)
1011 Call (New testclass
).publicSub()
1012 Call (New testclass
).publicSub
1015 property get prop0()
1019 property get prop1(x
)
1023 property get prop2(x
, y
)
1028 set obj
= new PropTest
1030 call ok(obj
.prop0
= 1, "obj.prop0 = " & obj
.prop0
)
1031 call ok(obj
.prop1(3) = 4, "obj.prop1(3) = " & obj
.prop1(3))
1032 call ok(obj
.prop2(3,4) = 7, "obj.prop2(3,4) = " & obj
.prop2(3,4))
1037 x
= "following ':' is correct syntax" :
1038 x
= "following ':' is correct syntax" :: :
1039 :: x
= "also correct syntax"
1040 rem another ugly way for comments
1041 x
= "rem as simplestatement" : rem rem comment
1044 Set obj
= new EmptyClass
1046 Set y
= new EmptyClass
1048 Call ok(obj is x
, "obj is not x")
1049 Call ok(x is obj
, "x is not obj")
1050 Call ok(not (obj is y
), "obj is not y")
1051 Call ok(not obj is y
, "obj is not y")
1052 Call ok(not (x is
Nothing), "x is 1")
1053 Call ok(Nothing is
Nothing, "Nothing is not Nothing")
1054 Call ok(x is obj
and true, "x is obj and true is false")
1057 Public Sub Test(MyMe
)
1058 Call ok(Me is MyMe
, "Me is not MyMe")
1062 Set obj
= New TestMe
1065 Call ok(getVT(test
) = "VT_DISPATCH", "getVT(test) = " & getVT(test
))
1066 Call ok(Me is Test
, "Me is not Test")
1068 Const c1
= 1, c2
= 2, c3
= -3
1069 Call ok(c1
= 1, "c1 = " & c1
)
1070 Call ok(getVT(c1
) = "VT_I2", "getVT(c1) = " & getVT(c1
))
1071 Call ok(c3
= -3, "c3 = " & c3
)
1072 Call ok(getVT(c3
) = "VT_I2", "getVT(c3) = " & getVT(c3
))
1074 Const cb
= True, cs
= "test", cnull
= null
1075 Call ok(cb
, "cb = " & cb
)
1076 Call ok(getVT(cb
) = "VT_BOOL", "getVT(cb) = " & getVT(cb
))
1077 Call ok(cs
= "test", "cs = " & cs
)
1078 Call ok(getVT(cs
) = "VT_BSTR", "getVT(cs) = " & getVT(cs
))
1079 Call ok(isNull(cnull
), "cnull = " & cnull
)
1080 Call ok(getVT(cnull
) = "VT_NULL", "getVT(cnull) = " & getVT(cnull
))
1082 if false then Const conststr
= "str"
1083 Call ok(conststr
= "str", "conststr = " & conststr
)
1084 Call ok(getVT(conststr
) = "VT_BSTR", "getVT(conststr) = " & getVT(conststr
))
1085 Call ok(conststr
= "str", "conststr = " & conststr
)
1089 Call ok(c1
= 1, "c1 = " & c1
)
1090 Call ok(funcconst
= 1, "funcconst = " & funcconst
)
1096 ' Property may be used as an identifier (although it's a keyword)
1100 Call ok(property, "property = " & property)
1102 for property = 1 to 2
1109 Public Sub Property()
1112 Sub Test(byref property)
1123 Sub Test2(byval property)
1129 Call ok(getVT(arr
) = "VT_EMPTY*", "getVT(arr) = " & getVT(arr
))
1132 Dim arr2(4,3), arr3(5,4,3), arr0(0), noarr()
1134 Call ok(getVT(arr
) = "VT_ARRAY|VT_BYREF|VT_VARIANT*", "getVT(arr) = " & getVT(arr
))
1135 Call ok(getVT(arr2
) = "VT_ARRAY|VT_BYREF|VT_VARIANT*", "getVT(arr2) = " & getVT(arr2
))
1136 Call ok(getVT(arr0
) = "VT_ARRAY|VT_BYREF|VT_VARIANT*", "getVT(arr0) = " & getVT(arr0
))
1137 Call ok(getVT(noarr
) = "VT_ARRAY|VT_BYREF|VT_VARIANT*", "getVT(noarr) = " & getVT(noarr
))
1139 Call testArray(1, arr
)
1140 Call testArray(2, arr2
)
1141 Call testArray(3, arr3
)
1142 Call testArray(0, arr0
)
1143 Call testArray(-1, noarr
)
1145 Call ok(getVT(arr(1)) = "VT_EMPTY*", "getVT(arr(1)) = " & getVT(arr(1)))
1146 Call ok(getVT(arr2(1,2)) = "VT_EMPTY*", "getVT(arr2(1,2)) = " & getVT(arr2(1,2)))
1147 Call ok(getVT(arr3(1,2,2)) = "VT_EMPTY*", "getVT(arr3(1,2,3)) = " & getVT(arr3(1,2,2)))
1148 Call ok(getVT(arr(0)) = "VT_EMPTY*", "getVT(arr(0)) = " & getVT(arr(0)))
1149 Call ok(getVT(arr(3)) = "VT_EMPTY*", "getVT(arr(3)) = " & getVT(arr(3)))
1150 Call ok(getVT(arr0(0)) = "VT_EMPTY*", "getVT(arr0(0)) = " & getVT(arr0(0)))
1153 Call ok(arr(2) = 3, "arr(2) = " & arr(2))
1154 Call ok(getVT(arr(2)) = "VT_I2*", "getVT(arr(2)) = " & getVT(arr(2)))
1158 Call ok(arr3(3,2,1) = 1, "arr3(3,2,1) = " & arr3(3,2,1))
1159 Call ok(arr3(1,2,3) = 2, "arr3(1,2,3) = " & arr3(1,2,3))
1162 Call ok(x(3,2,1) = 1, "x(3,2,1) = " & x(3,2,1))
1172 Call ok(getVT(x
) = "VT_ARRAY|VT_VARIANT*", "getVT(x) = " & getVT(x
))
1173 Call ok(x(2) = 2, "x(2) = " & x(2))
1174 Call ok(getVT(x(3)) = "VT_EMPTY*", "getVT(x(3)) = " & getVT(x(3)))
1177 Call ok(x(1) = 1, "x(1) = " & x(1))
1179 Call ok(getVT(x(1)) = "VT_EMPTY*", "getVT(x(1)) = " & getVT(x(1)))
1180 Call ok(x(2) = 2, "x(2) = " & x(2))
1185 Call ok(y(1) = 1, "y(1) = " & y(1))
1190 Call ok(getVT(forarr(1)) = "VT_EMPTY*", "getVT(forarr(1)) = " & getVT(forarr(1)))
1192 Call ok(forarr(1) = x
, "forarr(1) = " & forarr(1))
1198 Call ok(forarr(x
) = 2, "forarr(x) = " & forarr(x
))
1205 Private Sub Class_Initialize
1206 Call ok(getVT(classarr
) = "VT_ARRAY|VT_BYREF|VT_VARIANT*", "getVT(classarr) = " & getVT(classarr
))
1207 Call testArray(-1, classnoarr
)
1214 Public Sub testVarVT
1215 Call ok(getVT(var
) = "VT_ARRAY|VT_VARIANT*", "getVT(var) = " & getVT(var
))
1219 Set obj
= new ArrClass
1220 Call ok(getVT(obj
.classarr
) = "VT_ARRAY|VT_VARIANT", "getVT(obj.classarr) = " & getVT(obj
.classarr
))
1221 'todo_wine Call ok(obj.classarr(1) = 2, "obj.classarr(1) = " & obj.classarr(1))
1224 Call ok(getVT(obj
.var
) = "VT_ARRAY|VT_VARIANT", "getVT(obj.var) = " & getVT(obj
.var
))
1227 Sub arrarg(byref refarr
, byval valarr
, byref refarr2
, byval valarr2
)
1228 Call ok(getVT(refarr
) = "VT_ARRAY|VT_BYREF|VT_VARIANT*", "getVT(refarr) = " & getVT(refarr
))
1229 Call ok(getVT(valarr
) = "VT_ARRAY|VT_VARIANT*", "getVT(valarr) = " & getVT(valarr
))
1230 Call ok(getVT(refarr2
) = "VT_ARRAY|VT_VARIANT*", "getVT(refarr2) = " & getVT(refarr2
))
1231 Call ok(getVT(valarr2
) = "VT_ARRAY|VT_VARIANT*", "getVT(valarr2) = " & getVT(valarr2
))
1234 Call arrarg(arr
, arr
, obj
.classarr
, obj
.classarr
)
1236 Sub arrarg2(byref refarr(), byval valarr(), byref refarr2(), byval valarr2())
1237 Call ok(getVT(refarr
) = "VT_ARRAY|VT_BYREF|VT_VARIANT*", "getVT(refarr) = " & getVT(refarr
))
1238 Call ok(getVT(valarr
) = "VT_ARRAY|VT_VARIANT*", "getVT(valarr) = " & getVT(valarr
))
1239 Call ok(getVT(refarr2
) = "VT_ARRAY|VT_VARIANT*", "getVT(refarr2) = " & getVT(refarr2
))
1240 Call ok(getVT(valarr2
) = "VT_ARRAY|VT_VARIANT*", "getVT(valarr2) = " & getVT(valarr2
))
1243 Call arrarg2(arr
, arr
, obj
.classarr
, obj
.classarr
)
1245 Sub testarrarg(arg(), vt
)
1246 Call ok(getVT(arg
) = vt
, "getVT() = " & getVT(arg
) & " expected " & vt
)
1249 Call testarrarg(1, "VT_I2*")
1250 Call testarrarg(false, "VT_BOOL*")
1251 Call testarrarg(Empty
, "VT_EMPTY*")
1254 'Following test crashes on wine
1255 'Call ok(arr(0) = "not modified", "arr(0) = " & arr(0))
1259 arr(0) = "not modified"
1261 Call ok(arr(0) = "modified", "arr(0) = " & arr(0))
1263 arr(0) = "not modified"
1265 Call todo_wine_ok(arr(0) = "not modified", "arr(0) = " & arr(0))
1267 ' It's allowed to declare non-builtin RegExp class...
1269 public property get Global()
1270 Call ok(false, "Global called")
1275 ' ...but there is no way to use it because builtin instance is always created
1277 Call ok(x
.Global = false, "x.Global = " & x
.Global)