1c2c66affSColin Finck'
2c2c66affSColin Finck' Copyright 2011 Jacek Caban for CodeWeavers
3c2c66affSColin Finck'
4c2c66affSColin Finck' This library is free software; you can redistribute it and/or
5c2c66affSColin Finck' modify it under the terms of the GNU Lesser General Public
6c2c66affSColin Finck' License as published by the Free Software Foundation; either
7c2c66affSColin Finck' version 2.1 of the License, or (at your option) any later version.
8c2c66affSColin Finck'
9c2c66affSColin Finck' This library is distributed in the hope that it will be useful,
10c2c66affSColin Finck' but WITHOUT ANY WARRANTY; without even the implied warranty of
11c2c66affSColin Finck' MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12c2c66affSColin Finck' Lesser General Public License for more details.
13c2c66affSColin Finck'
14c2c66affSColin Finck' You should have received a copy of the GNU Lesser General Public
15c2c66affSColin Finck' License along with this library; if not, write to the Free Software
16c2c66affSColin Finck' Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
17c2c66affSColin Finck'
18c2c66affSColin Finck
19942c4265SAmine KhaldiOPTION EXPLICIT  : : DIM W
20c2c66affSColin Finck
21c2c66affSColin Finckdim x, y, z
22c2c66affSColin FinckDim obj
23c2c66affSColin Finck
24c2c66affSColin Finckcall ok(true, "true is not true?")
25c2c66affSColin Finckok true, "true is not true?"
26c2c66affSColin Finckcall ok((true), "true is not true?")
27c2c66affSColin Finck
28c2c66affSColin Finckok not false, "not false but not true?"
29c2c66affSColin Finckok not not true, "not not true but not true?"
30c2c66affSColin Finck
31c2c66affSColin FinckCall ok(true = true, "true = true is false")
32c2c66affSColin FinckCall ok(false = false, "false = false is false")
33c2c66affSColin FinckCall ok(not (true = false), "true = false is true")
34c2c66affSColin FinckCall ok("x" = "x", """x"" = ""x"" is false")
35c2c66affSColin FinckCall ok(empty = empty, "empty = empty is false")
36c2c66affSColin FinckCall ok(empty = "", "empty = """" is false")
37c2c66affSColin FinckCall ok(0 = 0.0, "0 <> 0.0")
38c2c66affSColin FinckCall ok(16 = &h10&, "16 <> &h10&")
39c2c66affSColin FinckCall ok(010 = 10, "010 <> 10")
40c2c66affSColin FinckCall ok(10. = 10, "10. <> 10")
41c2c66affSColin FinckCall ok(&hffFFffFF& = -1, "&hffFFffFF& <> -1")
42c2c66affSColin FinckCall ok(&hffFFffFF& = -1, "&hffFFffFF& <> -1")
43c2c66affSColin FinckCall ok(34e5 = 3400000, "34e5 <> 3400000")
44*7d76303dSAmine KhaldiCall ok(34e+5 = 3400000, "34e+5 <> 3400000")
45c2c66affSColin FinckCall ok(56.789e5 = 5678900, "56.789e5 = 5678900")
46c2c66affSColin FinckCall ok(56.789e-2 = 0.56789, "56.789e-2 <> 0.56789")
47c2c66affSColin FinckCall ok(1e-94938484 = 0, "1e-... <> 0")
48c2c66affSColin FinckCall ok(34e0 = 34, "34e0 <> 34")
49c2c66affSColin FinckCall ok(34E1 = 340, "34E0 <> 340")
50c2c66affSColin FinckCall ok(--1 = 1, "--1 = " & --1)
51c2c66affSColin FinckCall ok(-empty = 0, "-empty = " & (-empty))
52c2c66affSColin FinckCall ok(true = -1, "! true = -1")
53c2c66affSColin FinckCall ok(false = 0, "false <> 0")
54c2c66affSColin FinckCall ok(&hff = 255, "&hff <> 255")
55c2c66affSColin FinckCall ok(&Hff = 255, "&Hff <> 255")
56c2c66affSColin Finck
57942c4265SAmine KhaldiW = 5
58942c4265SAmine KhaldiCall ok(W = 5, "W = " & W & " expected " & 5)
59942c4265SAmine Khaldi
60c2c66affSColin Finckx = "xx"
61c2c66affSColin FinckCall ok(x = "xx", "x = " & x & " expected ""xx""")
62c2c66affSColin Finck
63c2c66affSColin FinckCall ok(true <> false, "true <> false is false")
64c2c66affSColin FinckCall ok(not (true <> true), "true <> true is true")
65c2c66affSColin FinckCall ok(not ("x" <> "x"), """x"" <> ""x"" is true")
66c2c66affSColin FinckCall ok(not (empty <> empty), "empty <> empty is true")
67c2c66affSColin FinckCall ok(x <> "x", "x = ""x""")
68c2c66affSColin FinckCall ok("true" <> true, """true"" = true is true")
69c2c66affSColin Finck
70c2c66affSColin FinckCall ok("" = true = false, """"" = true = false is false")
71c2c66affSColin FinckCall ok(not(false = true = ""), "false = true = """" is true")
72c2c66affSColin FinckCall ok(not (false = false <> false = false), "false = false <> false = false is true")
73c2c66affSColin FinckCall ok(not ("" <> false = false), """"" <> false = false is true")
74c2c66affSColin Finck
75c2c66affSColin FinckCall ok(getVT(false) = "VT_BOOL", "getVT(false) is not VT_BOOL")
76c2c66affSColin FinckCall ok(getVT(true) = "VT_BOOL", "getVT(true) is not VT_BOOL")
77c2c66affSColin FinckCall ok(getVT("") = "VT_BSTR", "getVT("""") is not VT_BSTR")
78c2c66affSColin FinckCall ok(getVT("test") = "VT_BSTR", "getVT(""test"") is not VT_BSTR")
79c2c66affSColin FinckCall ok(getVT(Empty) = "VT_EMPTY", "getVT(Empty) is not VT_EMPTY")
80c2c66affSColin FinckCall ok(getVT(null) = "VT_NULL", "getVT(null) is not VT_NULL")
81c2c66affSColin FinckCall ok(getVT(0) = "VT_I2", "getVT(0) is not VT_I2")
82c2c66affSColin FinckCall ok(getVT(1) = "VT_I2", "getVT(1) is not VT_I2")
83c2c66affSColin FinckCall ok(getVT(0.5) = "VT_R8", "getVT(0.5) is not VT_R8")
84c2c66affSColin FinckCall ok(getVT(0.0) = "VT_R8", "getVT(0.0) is not VT_R8")
85c2c66affSColin FinckCall ok(getVT(2147483647) = "VT_I4", "getVT(2147483647) is not VT_I4")
86c2c66affSColin FinckCall ok(getVT(2147483648) = "VT_R8", "getVT(2147483648) is not VT_R8")
87c2c66affSColin FinckCall ok(getVT(&h10&) = "VT_I2", "getVT(&h10&) is not VT_I2")
88c2c66affSColin FinckCall ok(getVT(&h10000&) = "VT_I4", "getVT(&h10000&) is not VT_I4")
89c2c66affSColin FinckCall ok(getVT(&H10000&) = "VT_I4", "getVT(&H10000&) is not VT_I4")
90c2c66affSColin FinckCall ok(getVT(&hffFFffFF&) = "VT_I2", "getVT(&hffFFffFF&) is not VT_I2")
91c2c66affSColin FinckCall ok(getVT(1e2) = "VT_R8", "getVT(1e2) is not VT_R8")
92c2c66affSColin FinckCall ok(getVT(1e0) = "VT_R8", "getVT(1e0) is not VT_R8")
93c2c66affSColin FinckCall ok(getVT(0.1e2) = "VT_R8", "getVT(0.1e2) is not VT_R8")
94c2c66affSColin FinckCall ok(getVT(1 & 100000) = "VT_BSTR", "getVT(1 & 100000) is not VT_BSTR")
95c2c66affSColin FinckCall ok(getVT(-empty) = "VT_I2", "getVT(-empty) = " & getVT(-empty))
96c2c66affSColin FinckCall ok(getVT(-null) = "VT_NULL", "getVT(-null) = " & getVT(-null))
97c2c66affSColin FinckCall ok(getVT(y) = "VT_EMPTY*", "getVT(y) = " & getVT(y))
98c2c66affSColin FinckCall ok(getVT(nothing) = "VT_DISPATCH", "getVT(nothing) = " & getVT(nothing))
99c2c66affSColin Finckset x = nothing
100c2c66affSColin FinckCall ok(getVT(x) = "VT_DISPATCH*", "getVT(x=nothing) = " & getVT(x))
101c2c66affSColin Finckx = true
102c2c66affSColin FinckCall ok(getVT(x) = "VT_BOOL*", "getVT(x) = " & getVT(x))
103c2c66affSColin FinckCall ok(getVT(false or true) = "VT_BOOL", "getVT(false) is not VT_BOOL")
104c2c66affSColin Finckx = "x"
105c2c66affSColin FinckCall ok(getVT(x) = "VT_BSTR*", "getVT(x) is not VT_BSTR*")
106c2c66affSColin Finckx = 0.0
107c2c66affSColin FinckCall ok(getVT(x) = "VT_R8*", "getVT(x) = " & getVT(x))
108c2c66affSColin Finck
109c2c66affSColin FinckCall ok(isNullDisp(nothing), "nothing is not nulldisp?")
110c2c66affSColin Finck
111c2c66affSColin Finckx = "xx"
112c2c66affSColin FinckCall ok("ab" & "cd" = "abcd", """ab"" & ""cd"" <> ""abcd""")
113c2c66affSColin FinckCall ok("ab " & null = "ab ", """ab"" & null = " & ("ab " & null))
114c2c66affSColin FinckCall ok("ab " & empty = "ab ", """ab"" & empty = " & ("ab " & empty))
115c2c66affSColin FinckCall ok(1 & 100000 = "1100000", "1 & 100000 = " & (1 & 100000))
116c2c66affSColin FinckCall ok("ab" & x = "abxx", """ab"" & x = " & ("ab"&x))
117c2c66affSColin Finck
118c2c66affSColin Finckif(isEnglishLang) then
119c2c66affSColin Finck    Call ok("" & true = "True", """"" & true = " & true)
120c2c66affSColin Finck    Call ok(true & false = "TrueFalse", "true & false = " & (true & false))
121c2c66affSColin Finckend if
122c2c66affSColin Finck
123c2c66affSColin Finckcall ok(true and true, "true and true is not true")
124c2c66affSColin Finckcall ok(true and not false, "true and not false is not true")
125c2c66affSColin Finckcall ok(not (false and true), "not (false and true) is not true")
126c2c66affSColin Finckcall ok(getVT(null and true) = "VT_NULL", "getVT(null and true) = " & getVT(null and true))
127c2c66affSColin Finck
128c2c66affSColin Finckcall ok(false or true, "false or uie is false?")
129c2c66affSColin Finckcall ok(not (false or false), "false or false is not false?")
130c2c66affSColin Finckcall ok(false and false or true, "false and false or true is false?")
131c2c66affSColin Finckcall ok(true or false and false, "true or false and false is false?")
132c2c66affSColin Finckcall ok(null or true, "null or true is false")
133c2c66affSColin Finck
134c2c66affSColin Finckcall ok(true xor false, "true xor false is false?")
135c2c66affSColin Finckcall ok(not (false xor false), "false xor false is true?")
136c2c66affSColin Finckcall ok(not (true or false xor true), "true or false xor true is true?")
137c2c66affSColin Finckcall ok(not (true xor false or true), "true xor false or true is true?")
138c2c66affSColin Finck
139c2c66affSColin Finckcall ok(false eqv false, "false does not equal false?")
140c2c66affSColin Finckcall ok(not (false eqv true), "false equals true?")
141c2c66affSColin Finckcall ok(getVT(false eqv null) = "VT_NULL", "getVT(false eqv null) = " & getVT(false eqv null))
142c2c66affSColin Finck
143c2c66affSColin Finckcall ok(true imp true, "true does not imp true?")
144c2c66affSColin Finckcall ok(false imp false, "false does not imp false?")
145c2c66affSColin Finckcall ok(not (true imp false), "true imp false?")
146c2c66affSColin Finckcall ok(false imp null, "false imp null is false?")
147c2c66affSColin Finck
148c2c66affSColin FinckCall ok(2 >= 1, "! 2 >= 1")
149c2c66affSColin FinckCall ok(2 >= 2, "! 2 >= 2")
150c2c66affSColin FinckCall ok(not(true >= 2), "true >= 2 ?")
151c2c66affSColin FinckCall ok(2 > 1, "! 2 > 1")
152c2c66affSColin FinckCall ok(false > true, "! false < true")
153c2c66affSColin FinckCall ok(0 > true, "! 0 > true")
154c2c66affSColin FinckCall ok(not (true > 0), "true > 0")
155c2c66affSColin FinckCall ok(not (0 > 1 = 1), "0 > 1 = 1")
156c2c66affSColin FinckCall ok(1 < 2, "! 1 < 2")
157c2c66affSColin FinckCall ok(1 = 1 < 0, "! 1 = 1 < 0")
158c2c66affSColin FinckCall ok(1 <= 2, "! 1 <= 2")
159c2c66affSColin FinckCall ok(2 <= 2, "! 2 <= 2")
160c2c66affSColin Finck
161c2c66affSColin FinckCall ok(isNull(0 = null), "'(0 = null)' is not null")
162c2c66affSColin FinckCall ok(isNull(null = 1), "'(null = 1)' is not null")
163c2c66affSColin FinckCall ok(isNull(0 > null), "'(0 > null)' is not null")
164c2c66affSColin FinckCall ok(isNull(null > 1), "'(null > 1)' is not null")
165c2c66affSColin FinckCall ok(isNull(0 < null), "'(0 < null)' is not null")
166c2c66affSColin FinckCall ok(isNull(null < 1), "'(null < 1)' is not null")
167c2c66affSColin FinckCall ok(isNull(0 <> null), "'(0 <> null)' is not null")
168c2c66affSColin FinckCall ok(isNull(null <> 1), "'(null <> 1)' is not null")
169c2c66affSColin FinckCall ok(isNull(0 >= null), "'(0 >= null)' is not null")
170c2c66affSColin FinckCall ok(isNull(null >= 1), "'(null >= 1)' is not null")
171c2c66affSColin FinckCall ok(isNull(0 <= null), "'(0 <= null)' is not null")
172c2c66affSColin FinckCall ok(isNull(null <= 1), "'(null <= 1)' is not null")
173c2c66affSColin Finck
174c2c66affSColin Finckx = 3
175c2c66affSColin FinckCall ok(2+2 = 4, "2+2 = " & (2+2))
176c2c66affSColin FinckCall ok(false + 6 + true = 5, "false + 6 + true <> 5")
177c2c66affSColin FinckCall ok(getVT(2+null) = "VT_NULL", "getVT(2+null) = " & getVT(2+null))
178c2c66affSColin FinckCall ok(2+empty = 2, "2+empty = " & (2+empty))
179c2c66affSColin FinckCall ok(x+x = 6, "x+x = " & (x+x))
180c2c66affSColin Finck
181c2c66affSColin FinckCall ok(5-1 = 4, "5-1 = " & (5-1))
182c2c66affSColin FinckCall ok(3+5-true = 9, "3+5-true <> 9")
183c2c66affSColin FinckCall ok(getVT(2-null) = "VT_NULL", "getVT(2-null) = " & getVT(2-null))
184c2c66affSColin FinckCall ok(2-empty = 2, "2-empty = " & (2-empty))
185c2c66affSColin FinckCall ok(2-x = -1, "2-x = " & (2-x))
186c2c66affSColin Finck
187c2c66affSColin FinckCall ok(9 Mod 6 = 3, "9 Mod 6 = " & (9 Mod 6))
188c2c66affSColin FinckCall ok(11.6 Mod 5.5 = False, "11.6 Mod 5.5 = " & (11.6 Mod 5.5 = 0.6))
189c2c66affSColin FinckCall ok(7 Mod 4+2 = 5, "7 Mod 4+2 <> 5")
190c2c66affSColin FinckCall ok(getVT(2 mod null) = "VT_NULL", "getVT(2 mod null) = " & getVT(2 mod null))
191c2c66affSColin FinckCall ok(getVT(null mod 2) = "VT_NULL", "getVT(null mod 2) = " & getVT(null mod 2))
192c2c66affSColin Finck'FIXME: Call ok(empty mod 2 = 0, "empty mod 2 = " & (empty mod 2))
193c2c66affSColin Finck
194c2c66affSColin FinckCall ok(5 \ 2 = 2, "5 \ 2 = " & (5\2))
195c2c66affSColin FinckCall ok(4.6 \ 1.5 = 2, "4.6 \ 1.5 = " & (4.6\1.5))
196c2c66affSColin FinckCall ok(4.6 \ 1.49 = 5, "4.6 \ 1.49 = " & (4.6\1.49))
197c2c66affSColin FinckCall ok(2+3\4 = 2, "2+3\4 = " & (2+3\4))
198c2c66affSColin Finck
199c2c66affSColin FinckCall ok(2*3 = 6, "2*3 = " & (2*3))
200c2c66affSColin FinckCall ok(3/2 = 1.5, "3/2 = " & (3/2))
201c2c66affSColin FinckCall ok(5\4/2 = 2, "5\4/2 = " & (5\2/1))
202c2c66affSColin FinckCall ok(12/3\2 = 2, "12/3\2 = " & (12/3\2))
203c2c66affSColin FinckCall ok(5/1000000 = 0.000005, "5/1000000 = " & (5/1000000))
204c2c66affSColin Finck
205c2c66affSColin FinckCall ok(2^3 = 8, "2^3 = " & (2^3))
206c2c66affSColin FinckCall ok(2^3^2 = 64, "2^3^2 = " & (2^3^2))
207c2c66affSColin FinckCall ok(-3^2 = 9, "-3^2 = " & (-3^2))
208c2c66affSColin FinckCall ok(2*3^2 = 18, "2*3^2 = " & (2*3^2))
209c2c66affSColin Finck
210c2c66affSColin Finckx =_
211c2c66affSColin Finck    3
212c2c66affSColin Finckx _
213c2c66affSColin Finck    = 3
214c2c66affSColin Finck
215c2c66affSColin Finckx = 3
216c2c66affSColin Finck
217c2c66affSColin Finckif true then y = true : x = y
218c2c66affSColin Finckok x, "x is false"
219c2c66affSColin Finck
220c2c66affSColin Finckx = true : if false then x = false
221c2c66affSColin Finckok x, "x is false, if false called?"
222c2c66affSColin Finck
223c2c66affSColin Finckif not false then x = true
224c2c66affSColin Finckok x, "x is false, if not false not called?"
225c2c66affSColin Finck
226c2c66affSColin Finckif not false then x = "test" : x = true
227c2c66affSColin Finckok x, "x is false, if not false not called?"
228c2c66affSColin Finck
229c2c66affSColin Finckif false then x = y : call ok(false, "if false .. : called")
230c2c66affSColin Finck
231c2c66affSColin Finckif false then x = y : call ok(false, "if false .. : called") else x = "else"
232c2c66affSColin FinckCall ok(x = "else", "else not called?")
233c2c66affSColin Finck
234c2c66affSColin Finckif true then x = y else y = x : Call ok(false, "in else?")
235c2c66affSColin Finck
236c2c66affSColin Finckif false then :
237c2c66affSColin Finck
238c2c66affSColin Finckif false then x = y : if true then call ok(false, "embedded if called")
239c2c66affSColin Finck
240c2c66affSColin Finckif false then x=1 else x=2 end if
241c2c66affSColin Finckif true then x=1 end if
242c2c66affSColin Finck
243c2c66affSColin Finckx = false
244c2c66affSColin Finckif false then x = true : x = true
245c2c66affSColin FinckCall ok(x = false, "x <> false")
246c2c66affSColin Finck
247c2c66affSColin Finckif false then
248c2c66affSColin Finck    ok false, "if false called"
249c2c66affSColin Finckend if
250c2c66affSColin Finck
251c2c66affSColin Finckx = true
252c2c66affSColin Finckif x then
253c2c66affSColin Finck    x = false
254c2c66affSColin Finckend if
255c2c66affSColin FinckCall ok(not x, "x is false, if not evaluated?")
256c2c66affSColin Finck
257c2c66affSColin Finckx = false
258c2c66affSColin FinckIf false Then
259c2c66affSColin Finck   Call ok(false, "inside if false")
260c2c66affSColin FinckElse
261c2c66affSColin Finck   x = true
262c2c66affSColin FinckEnd If
263c2c66affSColin FinckCall ok(x, "else not called?")
264c2c66affSColin Finck
265c2c66affSColin Finckx = false
266c2c66affSColin FinckIf false Then
267c2c66affSColin Finck   Call ok(false, "inside if false")
268c2c66affSColin FinckElseIf not True Then
269c2c66affSColin Finck   Call ok(false, "inside elseif not true")
270c2c66affSColin FinckElse
271c2c66affSColin Finck   x = true
272c2c66affSColin FinckEnd If
273c2c66affSColin FinckCall ok(x, "else not called?")
274c2c66affSColin Finck
275c2c66affSColin Finckx = false
276c2c66affSColin FinckIf false Then
277c2c66affSColin Finck   Call ok(false, "inside if false")
278c2c66affSColin Finck   x = 1
279c2c66affSColin Finck   y = 10+x
280c2c66affSColin FinckElseIf not False Then
281c2c66affSColin Finck   x = true
282c2c66affSColin FinckElse
283c2c66affSColin Finck   Call ok(false, "inside else not true")
284c2c66affSColin FinckEnd If
285c2c66affSColin FinckCall ok(x, "elseif not called?")
286c2c66affSColin Finck
287c2c66affSColin Finckx = false
288c2c66affSColin FinckIf false Then
289c2c66affSColin Finck   Call ok(false, "inside if false")
290c2c66affSColin FinckElseIf not False Then
291c2c66affSColin Finck   x = true
292c2c66affSColin FinckEnd If
293c2c66affSColin FinckCall ok(x, "elseif not called?")
294c2c66affSColin Finck
295c2c66affSColin Finckx = false
296c2c66affSColin Finckif 1 then x = true
297c2c66affSColin FinckCall ok(x, "if 1 not run?")
298c2c66affSColin Finck
299c2c66affSColin Finckx = false
300c2c66affSColin Finckif &h10000& then x = true
301c2c66affSColin FinckCall ok(x, "if &h10000& not run?")
302c2c66affSColin Finck
303c2c66affSColin Finckx = false
304c2c66affSColin Fincky = false
305c2c66affSColin Finckwhile not (x and y)
306c2c66affSColin Finck    if x then
307c2c66affSColin Finck        y = true
308c2c66affSColin Finck    end if
309c2c66affSColin Finck    x = true
310c2c66affSColin Finckwend
311c2c66affSColin Finckcall ok((x and y), "x or y is false after while")
312c2c66affSColin Finck
313c2c66affSColin Finckif false then
314c2c66affSColin Finck' empty body
315c2c66affSColin Finckend if
316c2c66affSColin Finck
317c2c66affSColin Finckif false then
318c2c66affSColin Finck    x = false
319c2c66affSColin Finckelseif true then
320c2c66affSColin Finck' empty body
321c2c66affSColin Finckend if
322c2c66affSColin Finck
323c2c66affSColin Finckif false then
324c2c66affSColin Finck    x = false
325c2c66affSColin Finckelse
326c2c66affSColin Finck' empty body
327c2c66affSColin Finckend if
328c2c66affSColin Finck
329c2c66affSColin Finckwhile false
330c2c66affSColin Finckwend
331c2c66affSColin Finck
332c2c66affSColin Finckx = 0
333c2c66affSColin FinckWHILE x < 3 : x = x + 1
334c2c66affSColin FinckWend
335c2c66affSColin FinckCall ok(x = 3, "x not equal to 3")
336c2c66affSColin Finck
337942c4265SAmine Khaldiz = 2
338942c4265SAmine Khaldiwhile z > -4 :
339942c4265SAmine Khaldi
340942c4265SAmine Khaldi
341942c4265SAmine Khaldiz = z -2
342942c4265SAmine Khaldiwend
343942c4265SAmine Khaldi
344c2c66affSColin Finckx = false
345c2c66affSColin Fincky = false
346c2c66affSColin Finckdo while not (x and y)
347c2c66affSColin Finck    if x then
348c2c66affSColin Finck        y = true
349c2c66affSColin Finck    end if
350c2c66affSColin Finck    x = true
351c2c66affSColin Finckloop
352c2c66affSColin Finckcall ok((x and y), "x or y is false after while")
353c2c66affSColin Finck
354c2c66affSColin Finckdo while false
355c2c66affSColin Finckloop
356c2c66affSColin Finck
357c2c66affSColin Finckdo while true
358c2c66affSColin Finck    exit do
359c2c66affSColin Finck    ok false, "exit do didn't work"
360c2c66affSColin Finckloop
361c2c66affSColin Finck
362c2c66affSColin Finckx = 0
363c2c66affSColin FinckDo While x < 2 : x = x + 1
364c2c66affSColin FinckLoop
365c2c66affSColin FinckCall ok(x = 2, "x not equal to 2")
366c2c66affSColin Finck
367942c4265SAmine Khaldix = 0
368942c4265SAmine KhaldiDo While x >= -2 :
369942c4265SAmine Khaldix = x - 1
370942c4265SAmine KhaldiLoop
371942c4265SAmine KhaldiCall ok(x = -3, "x not equal to -3")
372942c4265SAmine Khaldi
373c2c66affSColin Finckx = false
374c2c66affSColin Fincky = false
375c2c66affSColin Finckdo until x and y
376c2c66affSColin Finck    if x then
377c2c66affSColin Finck        y = true
378c2c66affSColin Finck    end if
379c2c66affSColin Finck    x = true
380c2c66affSColin Finckloop
381c2c66affSColin Finckcall ok((x and y), "x or y is false after do until")
382c2c66affSColin Finck
383c2c66affSColin Finckdo until true
384c2c66affSColin Finckloop
385c2c66affSColin Finck
386c2c66affSColin Finckdo until false
387c2c66affSColin Finck    exit do
388c2c66affSColin Finck    ok false, "exit do didn't work"
389c2c66affSColin Finckloop
390c2c66affSColin Finck
391c2c66affSColin Finckx = 0
392c2c66affSColin FinckDo: :: x = x + 2
393c2c66affSColin FinckLoop Until x = 4
394c2c66affSColin FinckCall ok(x = 4, "x not equal to 4")
395c2c66affSColin Finck
396942c4265SAmine Khaldix = 5
397942c4265SAmine KhaldiDo: :
398942c4265SAmine Khaldi
399942c4265SAmine Khaldi: x = x * 2
400942c4265SAmine KhaldiLoop Until x = 40
401942c4265SAmine KhaldiCall ok(x = 40, "x not equal to 40")
402942c4265SAmine Khaldi
403942c4265SAmine Khaldi
404c2c66affSColin Finckx = false
405c2c66affSColin Finckdo
406c2c66affSColin Finck    if x then exit do
407c2c66affSColin Finck    x = true
408c2c66affSColin Finckloop
409c2c66affSColin Finckcall ok(x, "x is false after do..loop?")
410c2c66affSColin Finck
411c2c66affSColin Finckx = 0
412c2c66affSColin FinckDo :If x = 6 Then
413c2c66affSColin Finck        Exit Do
414c2c66affSColin Finck    End If
415c2c66affSColin Finck    x = x + 3
416c2c66affSColin FinckLoop
417c2c66affSColin FinckCall ok(x = 6, "x not equal to 6")
418c2c66affSColin Finck
419c2c66affSColin Finckx = false
420c2c66affSColin Fincky = false
421c2c66affSColin Finckdo
422c2c66affSColin Finck    if x then
423c2c66affSColin Finck        y = true
424c2c66affSColin Finck    end if
425c2c66affSColin Finck    x = true
426c2c66affSColin Finckloop until x and y
427c2c66affSColin Finckcall ok((x and y), "x or y is false after while")
428c2c66affSColin Finck
429c2c66affSColin Finckdo
430c2c66affSColin Finckloop until true
431c2c66affSColin Finck
432c2c66affSColin Finckdo
433c2c66affSColin Finck    exit do
434c2c66affSColin Finck    ok false, "exit do didn't work"
435c2c66affSColin Finckloop until false
436c2c66affSColin Finck
437c2c66affSColin Finckx = false
438c2c66affSColin Fincky = false
439c2c66affSColin Finckdo
440c2c66affSColin Finck    if x then
441c2c66affSColin Finck        y = true
442c2c66affSColin Finck    end if
443c2c66affSColin Finck    x = true
444c2c66affSColin Finckloop while not (x and y)
445c2c66affSColin Finckcall ok((x and y), "x or y is false after while")
446c2c66affSColin Finck
447c2c66affSColin Finckdo
448c2c66affSColin Finckloop while false
449c2c66affSColin Finck
450c2c66affSColin Finckdo
451c2c66affSColin Finck    exit do
452c2c66affSColin Finck    ok false, "exit do didn't work"
453c2c66affSColin Finckloop while true
454c2c66affSColin Finck
455c2c66affSColin Fincky = "for1:"
456c2c66affSColin Finckfor x = 5 to 8
457c2c66affSColin Finck    y = y & " " & x
458c2c66affSColin Fincknext
459c2c66affSColin FinckCall ok(y = "for1: 5 6 7 8", "y = " & y)
460c2c66affSColin Finck
461c2c66affSColin Fincky = "for2:"
462c2c66affSColin Finckfor x = 5 to 8 step 2
463c2c66affSColin Finck    y = y & " " & x
464c2c66affSColin Fincknext
465c2c66affSColin FinckCall ok(y = "for2: 5 7", "y = " & y)
466c2c66affSColin Finck
467c2c66affSColin Fincky = "for3:"
468c2c66affSColin Finckx = 2
469c2c66affSColin Finckfor x = x+3 to 8
470c2c66affSColin Finck    y = y & " " & x
471c2c66affSColin Fincknext
472c2c66affSColin FinckCall ok(y = "for3: 5 6 7 8", "y = " & y)
473c2c66affSColin Finck
474c2c66affSColin Fincky = "for4:"
475c2c66affSColin Finckfor x = 5 to 4
476c2c66affSColin Finck    y = y & " " & x
477c2c66affSColin Fincknext
478c2c66affSColin FinckCall ok(y = "for4:", "y = " & y)
479c2c66affSColin Finck
480c2c66affSColin Fincky = "for5:"
481c2c66affSColin Finckfor x = 5 to 3 step true
482c2c66affSColin Finck    y = y & " " & x
483c2c66affSColin Fincknext
484c2c66affSColin FinckCall ok(y = "for5: 5 4 3", "y = " & y)
485c2c66affSColin Finck
486c2c66affSColin Fincky = "for6:"
487c2c66affSColin Finckz = 4
488c2c66affSColin Finckfor x = 5 to z step 3-4
489c2c66affSColin Finck    y = y & " " & x
490c2c66affSColin Finck    z = 0
491c2c66affSColin Fincknext
492c2c66affSColin FinckCall ok(y = "for6: 5 4", "y = " & y)
493c2c66affSColin Finck
494c2c66affSColin Fincky = "for7:"
495c2c66affSColin Finckz = 1
496c2c66affSColin Finckfor x = 5 to 8 step z
497c2c66affSColin Finck    y = y & " " & x
498c2c66affSColin Finck    z = 2
499c2c66affSColin Fincknext
500c2c66affSColin FinckCall ok(y = "for7: 5 6 7 8", "y = " & y)
501c2c66affSColin Finck
502c2c66affSColin Finckz = 0
503c2c66affSColin FinckFor x = 10 To 18 Step 2 : : z = z + 1
504c2c66affSColin FinckNext
505c2c66affSColin FinckCall ok(z = 5, "z not equal to 5")
506c2c66affSColin Finck
507c2c66affSColin Fincky = "for8:"
508c2c66affSColin Finckfor x = 5 to 8
509c2c66affSColin Finck    y = y & " " & x
510c2c66affSColin Finck    x = x+1
511c2c66affSColin Fincknext
512c2c66affSColin FinckCall ok(y = "for8: 5 7", "y = " & y)
513c2c66affSColin Finck
514c2c66affSColin Finckfor x = 1.5 to 1
515c2c66affSColin Finck    Call ok(false, "for..to called when unexpected")
516c2c66affSColin Fincknext
517c2c66affSColin Finck
518c2c66affSColin Finckfor x = 1 to 100
519c2c66affSColin Finck    exit for
520c2c66affSColin Finck    Call ok(false, "exit for not escaped the loop?")
521c2c66affSColin Fincknext
522c2c66affSColin Finck
523942c4265SAmine Khaldifor x = 1 to 5 :
524942c4265SAmine Khaldi:
525942c4265SAmine Khaldi:   :exit for
526942c4265SAmine Khaldi    Call ok(false, "exit for not escaped the loop?")
527942c4265SAmine Khaldinext
528942c4265SAmine Khaldi
529c2c66affSColin Finckdo while true
530c2c66affSColin Finck    for x = 1 to 100
531c2c66affSColin Finck        exit do
532c2c66affSColin Finck    next
533c2c66affSColin Finckloop
534c2c66affSColin Finck
535c2c66affSColin Finckif null then call ok(false, "if null evaluated")
536c2c66affSColin Finck
537c2c66affSColin Finckwhile null
538c2c66affSColin Finck    call ok(false, "while null evaluated")
539c2c66affSColin Finckwend
540c2c66affSColin Finck
541c2c66affSColin FinckCall collectionObj.reset()
542c2c66affSColin Fincky = 0
543942c4265SAmine Khaldifor each x in collectionObj :
544942c4265SAmine Khaldi
545942c4265SAmine Khaldi   :y = y + 3
546942c4265SAmine Khaldinext
547942c4265SAmine KhaldiCall ok(y = 9, "y = " & y)
548942c4265SAmine Khaldi
549942c4265SAmine KhaldiCall collectionObj.reset()
550942c4265SAmine Khaldiy = 0
551c2c66affSColin Finckx = 10
552c2c66affSColin Finckz = 0
553c2c66affSColin Finckfor each x in collectionObj : z = z + 2
554c2c66affSColin Finck    y = y+1
555c2c66affSColin Finck    Call ok(x = y, "x <> y")
556c2c66affSColin Fincknext
557c2c66affSColin FinckCall ok(y = 3, "y = " & y)
558c2c66affSColin FinckCall ok(z = 6, "z = " & z)
559c2c66affSColin FinckCall ok(getVT(x) = "VT_EMPTY*", "getVT(x) = " & getVT(x))
560c2c66affSColin Finck
561c2c66affSColin FinckCall collectionObj.reset()
562c2c66affSColin Fincky = false
563c2c66affSColin Finckfor each x in collectionObj
564c2c66affSColin Finck    if x = 2 then exit for
565c2c66affSColin Finck    y = 1
566c2c66affSColin Fincknext
567c2c66affSColin FinckCall ok(y = 1, "y = " & y)
568c2c66affSColin FinckCall ok(x = 2, "x = " & x)
569c2c66affSColin Finck
570c2c66affSColin FinckSet obj = collectionObj
571c2c66affSColin FinckCall obj.reset()
572c2c66affSColin Fincky = 0
573c2c66affSColin Finckx = 10
574c2c66affSColin Finckfor each x in obj
575c2c66affSColin Finck    y = y+1
576c2c66affSColin Finck    Call ok(x = y, "x <> y")
577c2c66affSColin Fincknext
578c2c66affSColin FinckCall ok(y = 3, "y = " & y)
579c2c66affSColin FinckCall ok(getVT(x) = "VT_EMPTY*", "getVT(x) = " & getVT(x))
580c2c66affSColin Finck
581c2c66affSColin Finckx = false
582c2c66affSColin Finckselect case 3
583c2c66affSColin Finck    case 2
584c2c66affSColin Finck        Call ok(false, "unexpected case")
585c2c66affSColin Finck    case 2
586c2c66affSColin Finck        Call ok(false, "unexpected case")
587c2c66affSColin Finck    case 4
588c2c66affSColin Finck        Call ok(false, "unexpected case")
589c2c66affSColin Finck    case "test"
590c2c66affSColin Finck    case "another case"
591c2c66affSColin Finck        Call ok(false, "unexpected case")
592c2c66affSColin Finck    case 0, false, 2+1, 10
593c2c66affSColin Finck        x = true
594c2c66affSColin Finck    case ok(false, "unexpected case")
595c2c66affSColin Finck        Call ok(false, "unexpected case")
596c2c66affSColin Finck    case else
597c2c66affSColin Finck        Call ok(false, "unexpected case")
598c2c66affSColin Finckend select
599c2c66affSColin FinckCall ok(x, "wrong case")
600c2c66affSColin Finck
601c2c66affSColin Finckx = false
602c2c66affSColin Finckselect case 3
603c2c66affSColin Finck    case 3
604c2c66affSColin Finck        x = true
605c2c66affSColin Finckend select
606c2c66affSColin FinckCall ok(x, "wrong case")
607c2c66affSColin Finck
608c2c66affSColin Finckx = false
609c2c66affSColin Finckselect case 2+2
610c2c66affSColin Finck    case 3
611c2c66affSColin Finck        Call ok(false, "unexpected case")
612c2c66affSColin Finck    case else
613c2c66affSColin Finck        x = true
614c2c66affSColin Finckend select
615c2c66affSColin FinckCall ok(x, "wrong case")
616c2c66affSColin Finck
617c2c66affSColin Fincky = "3"
618c2c66affSColin Finckx = false
619c2c66affSColin Finckselect case y
620c2c66affSColin Finck    case "3"
621c2c66affSColin Finck        x = true
622c2c66affSColin Finck    case 3
623c2c66affSColin Finck        Call ok(false, "unexpected case")
624c2c66affSColin Finckend select
625c2c66affSColin FinckCall ok(x, "wrong case")
626c2c66affSColin Finck
627c2c66affSColin Finckselect case 0
628c2c66affSColin Finck    case 1
629c2c66affSColin Finck        Call ok(false, "unexpected case")
630c2c66affSColin Finck    case "2"
631c2c66affSColin Finck        Call ok(false, "unexpected case")
632c2c66affSColin Finckend select
633c2c66affSColin Finck
634c2c66affSColin Finckselect case 0
635c2c66affSColin Finckend select
636c2c66affSColin Finck
637c2c66affSColin Finckx = false
638c2c66affSColin Finckselect case 2
639c2c66affSColin Finck    case 3,1,2,4: x = true
640c2c66affSColin Finck    case 5,6,7
641c2c66affSColin Finck        Call ok(false, "unexpected case")
642c2c66affSColin Finckend select
643c2c66affSColin FinckCall ok(x, "wrong case")
644c2c66affSColin Finck
645c2c66affSColin Finckx = false
646c2c66affSColin Finckselect case 2: case 5,6,7: Call ok(false, "unexpected case")
647c2c66affSColin Finck    case 2,1,2,4
648c2c66affSColin Finck        x = true
649c2c66affSColin Finck    case else: Call ok(false, "unexpected case else")
650c2c66affSColin Finckend select
651c2c66affSColin FinckCall ok(x, "wrong case")
652c2c66affSColin Finck
653942c4265SAmine Khaldix = False
654942c4265SAmine Khaldiselect case 1  :
655942c4265SAmine Khaldi
656942c4265SAmine Khaldi    :case 3, 4 :
657942c4265SAmine Khaldi
658942c4265SAmine Khaldi
659942c4265SAmine Khaldi    case 5
660942c4265SAmine Khaldi:
661942c4265SAmine Khaldi        Call ok(false, "unexpected case") :
662942c4265SAmine Khaldi    Case Else:
663942c4265SAmine Khaldi
664942c4265SAmine Khaldi        x = True
665942c4265SAmine Khaldiend select
666942c4265SAmine KhaldiCall ok(x, "wrong case")
667942c4265SAmine Khaldi
668c2c66affSColin Finckif false then
669c2c66affSColin FinckSub testsub
670c2c66affSColin Finck    x = true
671c2c66affSColin FinckEnd Sub
672c2c66affSColin Finckend if
673c2c66affSColin Finck
674c2c66affSColin Finckx = false
675c2c66affSColin FinckCall testsub
676c2c66affSColin FinckCall ok(x, "x is false, testsub not called?")
677c2c66affSColin Finck
678c2c66affSColin FinckSub SubSetTrue(v)
679c2c66affSColin Finck    Call ok(not v, "v is not true")
680c2c66affSColin Finck    v = true
681c2c66affSColin FinckEnd Sub
682c2c66affSColin Finck
683c2c66affSColin Finckx = false
684c2c66affSColin FinckSubSetTrue x
685c2c66affSColin FinckCall ok(x, "x was not set by SubSetTrue")
686c2c66affSColin Finck
687c2c66affSColin FinckSubSetTrue false
688c2c66affSColin FinckCall ok(not false, "false is no longer false?")
689c2c66affSColin Finck
690c2c66affSColin FinckSub SubSetTrue2(ByRef v)
691c2c66affSColin Finck    Call ok(not v, "v is not true")
692c2c66affSColin Finck    v = true
693c2c66affSColin FinckEnd Sub
694c2c66affSColin Finck
695c2c66affSColin Finckx = false
696c2c66affSColin FinckSubSetTrue2 x
697c2c66affSColin FinckCall ok(x, "x was not set by SubSetTrue")
698c2c66affSColin Finck
699c2c66affSColin FinckSub TestSubArgVal(ByVal v)
700c2c66affSColin Finck    Call ok(not v, "v is not false")
701c2c66affSColin Finck    v = true
702c2c66affSColin Finck    Call ok(v, "v is not true?")
703c2c66affSColin FinckEnd Sub
704c2c66affSColin Finck
705c2c66affSColin Finckx = false
706c2c66affSColin FinckCall TestSubArgVal(x)
707c2c66affSColin FinckCall ok(not x, "x is true after TestSubArgVal call?")
708c2c66affSColin Finck
709c2c66affSColin FinckSub TestSubMultiArgs(a,b,c,d,e)
710c2c66affSColin Finck    Call ok(a=1, "a = " & a)
711c2c66affSColin Finck    Call ok(b=2, "b = " & b)
712c2c66affSColin Finck    Call ok(c=3, "c = " & c)
713c2c66affSColin Finck    Call ok(d=4, "d = " & d)
714c2c66affSColin Finck    Call ok(e=5, "e = " & e)
715c2c66affSColin FinckEnd Sub
716c2c66affSColin Finck
717c2c66affSColin FinckSub TestSubExit(ByRef a)
718c2c66affSColin Finck    If a Then
719c2c66affSColin Finck        Exit Sub
720c2c66affSColin Finck    End If
721c2c66affSColin Finck    Call ok(false, "Exit Sub not called?")
722c2c66affSColin FinckEnd Sub
723c2c66affSColin Finck
724c2c66affSColin FinckCall TestSubExit(true)
725c2c66affSColin Finck
726c2c66affSColin FinckSub TestSubExit2
727c2c66affSColin Finck    for x = 1 to 100
728c2c66affSColin Finck        Exit Sub
729c2c66affSColin Finck    next
730c2c66affSColin FinckEnd Sub
731c2c66affSColin FinckCall TestSubExit2
732c2c66affSColin Finck
733c2c66affSColin FinckTestSubMultiArgs 1, 2, 3, 4, 5
734c2c66affSColin FinckCall TestSubMultiArgs(1, 2, 3, 4, 5)
735c2c66affSColin Finck
736c2c66affSColin FinckSub TestSubLocalVal
737c2c66affSColin Finck    x = false
738c2c66affSColin Finck    Call ok(not x, "local x is not false?")
739c2c66affSColin Finck    Dim x
740c2c66affSColin Finck    Dim a,b, c
741c2c66affSColin FinckEnd Sub
742c2c66affSColin Finck
743c2c66affSColin Finckx = true
744c2c66affSColin Fincky = true
745c2c66affSColin FinckCall TestSubLocalVal
746c2c66affSColin FinckCall ok(x, "global x is not true?")
747c2c66affSColin Finck
748c2c66affSColin FinckPublic Sub TestPublicSub
749c2c66affSColin FinckEnd Sub
750c2c66affSColin FinckCall TestPublicSub
751c2c66affSColin Finck
752c2c66affSColin FinckPrivate Sub TestPrivateSub
753c2c66affSColin FinckEnd Sub
754c2c66affSColin FinckCall TestPrivateSub
755c2c66affSColin Finck
756942c4265SAmine KhaldiPublic Sub TestSeparatorSub : :
757942c4265SAmine Khaldi:
758942c4265SAmine KhaldiEnd Sub
759942c4265SAmine KhaldiCall TestSeparatorSub
760942c4265SAmine Khaldi
761c2c66affSColin Finckif false then
762c2c66affSColin FinckFunction testfunc
763c2c66affSColin Finck    x = true
764c2c66affSColin FinckEnd Function
765c2c66affSColin Finckend if
766c2c66affSColin Finck
767c2c66affSColin Finckx = false
768c2c66affSColin FinckCall TestFunc
769c2c66affSColin FinckCall ok(x, "x is false, testfunc not called?")
770c2c66affSColin Finck
771c2c66affSColin FinckFunction FuncSetTrue(v)
772c2c66affSColin Finck    Call ok(not v, "v is not true")
773c2c66affSColin Finck    v = true
774c2c66affSColin FinckEnd Function
775c2c66affSColin Finck
776c2c66affSColin Finckx = false
777c2c66affSColin FinckFuncSetTrue x
778c2c66affSColin FinckCall ok(x, "x was not set by FuncSetTrue")
779c2c66affSColin Finck
780c2c66affSColin FinckFuncSetTrue false
781c2c66affSColin FinckCall ok(not false, "false is no longer false?")
782c2c66affSColin Finck
783c2c66affSColin FinckFunction FuncSetTrue2(ByRef v)
784c2c66affSColin Finck    Call ok(not v, "v is not true")
785c2c66affSColin Finck    v = true
786c2c66affSColin FinckEnd Function
787c2c66affSColin Finck
788c2c66affSColin Finckx = false
789c2c66affSColin FinckFuncSetTrue2 x
790c2c66affSColin FinckCall ok(x, "x was not set by FuncSetTrue")
791c2c66affSColin Finck
792c2c66affSColin FinckFunction TestFuncArgVal(ByVal v)
793c2c66affSColin Finck    Call ok(not v, "v is not false")
794c2c66affSColin Finck    v = true
795c2c66affSColin Finck    Call ok(v, "v is not true?")
796c2c66affSColin FinckEnd Function
797c2c66affSColin Finck
798c2c66affSColin Finckx = false
799c2c66affSColin FinckCall TestFuncArgVal(x)
800c2c66affSColin FinckCall ok(not x, "x is true after TestFuncArgVal call?")
801c2c66affSColin Finck
802c2c66affSColin FinckFunction TestFuncMultiArgs(a,b,c,d,e)
803c2c66affSColin Finck    Call ok(a=1, "a = " & a)
804c2c66affSColin Finck    Call ok(b=2, "b = " & b)
805c2c66affSColin Finck    Call ok(c=3, "c = " & c)
806c2c66affSColin Finck    Call ok(d=4, "d = " & d)
807c2c66affSColin Finck    Call ok(e=5, "e = " & e)
808c2c66affSColin FinckEnd Function
809c2c66affSColin Finck
810c2c66affSColin FinckTestFuncMultiArgs 1, 2, 3, 4, 5
811c2c66affSColin FinckCall TestFuncMultiArgs(1, 2, 3, 4, 5)
812c2c66affSColin Finck
813c2c66affSColin FinckFunction TestFuncLocalVal
814c2c66affSColin Finck    x = false
815c2c66affSColin Finck    Call ok(not x, "local x is not false?")
816c2c66affSColin Finck    Dim x
817c2c66affSColin FinckEnd Function
818c2c66affSColin Finck
819c2c66affSColin Finckx = true
820c2c66affSColin Fincky = true
821c2c66affSColin FinckCall TestFuncLocalVal
822c2c66affSColin FinckCall ok(x, "global x is not true?")
823c2c66affSColin Finck
824c2c66affSColin FinckFunction TestFuncExit(ByRef a)
825c2c66affSColin Finck    If a Then
826c2c66affSColin Finck        Exit Function
827c2c66affSColin Finck    End If
828c2c66affSColin Finck    Call ok(false, "Exit Function not called?")
829c2c66affSColin FinckEnd Function
830c2c66affSColin Finck
831c2c66affSColin FinckCall TestFuncExit(true)
832c2c66affSColin Finck
833c2c66affSColin FinckFunction TestFuncExit2(ByRef a)
834c2c66affSColin Finck    For x = 1 to 100
835c2c66affSColin Finck        For y = 1 to 100
836c2c66affSColin Finck            Exit Function
837c2c66affSColin Finck        Next
838c2c66affSColin Finck    Next
839c2c66affSColin Finck    Call ok(false, "Exit Function not called?")
840c2c66affSColin FinckEnd Function
841c2c66affSColin Finck
842c2c66affSColin FinckCall TestFuncExit2(true)
843c2c66affSColin Finck
844c2c66affSColin FinckSub SubParseTest
845c2c66affSColin FinckEnd Sub : x = false
846c2c66affSColin FinckCall SubParseTest
847c2c66affSColin Finck
848c2c66affSColin FinckFunction FuncParseTest
849c2c66affSColin FinckEnd Function : x = false
850c2c66affSColin Finck
851c2c66affSColin FinckFunction ReturnTrue
852c2c66affSColin Finck     ReturnTrue = false
853c2c66affSColin Finck     ReturnTrue = true
854c2c66affSColin FinckEnd Function
855c2c66affSColin Finck
856c2c66affSColin FinckCall ok(ReturnTrue(), "ReturnTrue returned false?")
857c2c66affSColin Finck
858c2c66affSColin FinckFunction SetVal(ByRef x, ByVal v)
859c2c66affSColin Finck    x = v
860c2c66affSColin Finck    SetVal = x
861c2c66affSColin Finck    Exit Function
862c2c66affSColin FinckEnd Function
863c2c66affSColin Finck
864c2c66affSColin Finckx = false
865c2c66affSColin Finckok SetVal(x, true), "SetVal returned false?"
866c2c66affSColin FinckCall ok(x, "x is not set to true by SetVal?")
867c2c66affSColin Finck
868c2c66affSColin FinckPublic Function TestPublicFunc
869c2c66affSColin FinckEnd Function
870c2c66affSColin FinckCall TestPublicFunc
871c2c66affSColin Finck
872c2c66affSColin FinckPrivate Function TestPrivateFunc
873c2c66affSColin FinckEnd Function
874c2c66affSColin FinckCall TestPrivateFunc
875c2c66affSColin Finck
876942c4265SAmine KhaldiPublic Function TestSepFunc(ByVal a) : :
877942c4265SAmine Khaldi: TestSepFunc = a
878942c4265SAmine KhaldiEnd Function
879942c4265SAmine KhaldiCall ok(TestSepFunc(1) = 1, "Function did not return 1")
880942c4265SAmine Khaldi
881942c4265SAmine Khaldi
882c2c66affSColin Finck' Stop has an effect only in debugging mode
883c2c66affSColin FinckStop
884c2c66affSColin Finck
885c2c66affSColin Finckset x = testObj
886c2c66affSColin FinckCall ok(getVT(x) = "VT_DISPATCH*", "getVT(x=testObj) = " & getVT(x))
887c2c66affSColin Finck
888c2c66affSColin FinckSet obj = New EmptyClass
889c2c66affSColin FinckCall ok(getVT(obj) = "VT_DISPATCH*", "getVT(obj) = " & getVT(obj))
890c2c66affSColin Finck
891c2c66affSColin FinckClass EmptyClass
892c2c66affSColin FinckEnd Class
893c2c66affSColin Finck
894c2c66affSColin FinckSet x = obj
895c2c66affSColin FinckCall ok(getVT(x) = "VT_DISPATCH*", "getVT(x) = " & getVT(x))
896c2c66affSColin Finck
897c2c66affSColin FinckClass TestClass
898c2c66affSColin Finck    Public publicProp
899c2c66affSColin Finck
900c2c66affSColin Finck    Private privateProp
901c2c66affSColin Finck
902c2c66affSColin Finck    Public Function publicFunction()
903c2c66affSColin Finck        privateSub()
904c2c66affSColin Finck        publicFunction = 4
905c2c66affSColin Finck    End Function
906c2c66affSColin Finck
907c2c66affSColin Finck    Public Property Get gsProp()
908c2c66affSColin Finck        gsProp = privateProp
909c2c66affSColin Finck        funcCalled = "gsProp get"
910c2c66affSColin Finck        exit property
911c2c66affSColin Finck        Call ok(false, "exit property not returned?")
912c2c66affSColin Finck    End Property
913c2c66affSColin Finck
914c2c66affSColin Finck    Public Default Property Get DefValGet
915c2c66affSColin Finck        DefValGet = privateProp
916c2c66affSColin Finck        funcCalled = "GetDefVal"
917c2c66affSColin Finck    End Property
918c2c66affSColin Finck
919c2c66affSColin Finck    Public Property Let DefValGet(x)
920c2c66affSColin Finck    End Property
921c2c66affSColin Finck
922c2c66affSColin Finck    Public publicProp2
923c2c66affSColin Finck
924c2c66affSColin Finck    Public Sub publicSub
925c2c66affSColin Finck    End Sub
926c2c66affSColin Finck
927c2c66affSColin Finck    Public Property Let gsProp(val)
928c2c66affSColin Finck        privateProp = val
929c2c66affSColin Finck        funcCalled = "gsProp let"
930c2c66affSColin Finck        exit property
931c2c66affSColin Finck        Call ok(false, "exit property not returned?")
932c2c66affSColin Finck    End Property
933c2c66affSColin Finck
934c2c66affSColin Finck    Public Property Set gsProp(val)
935c2c66affSColin Finck        funcCalled = "gsProp set"
936c2c66affSColin Finck        exit property
937c2c66affSColin Finck        Call ok(false, "exit property not returned?")
938c2c66affSColin Finck    End Property
939c2c66affSColin Finck
940c2c66affSColin Finck    Public Sub setPrivateProp(x)
941c2c66affSColin Finck        privateProp = x
942c2c66affSColin Finck    End Sub
943c2c66affSColin Finck
944c2c66affSColin Finck    Function getPrivateProp
945c2c66affSColin Finck        getPrivateProp = privateProp
946c2c66affSColin Finck    End Function
947c2c66affSColin Finck
948c2c66affSColin Finck    Private Sub privateSub
949c2c66affSColin Finck    End Sub
950c2c66affSColin Finck
951c2c66affSColin Finck    Public Sub Class_Initialize
952c2c66affSColin Finck        publicProp2 = 2
953c2c66affSColin Finck        privateProp = true
954c2c66affSColin Finck        Call ok(getVT(privateProp) = "VT_BOOL*", "getVT(privateProp) = " & getVT(privateProp))
955c2c66affSColin Finck        Call ok(getVT(publicProp2) = "VT_I2*", "getVT(publicProp2) = " & getVT(publicProp2))
956c2c66affSColin Finck        Call ok(getVT(Me.publicProp2) = "VT_I2", "getVT(Me.publicProp2) = " & getVT(Me.publicProp2))
957c2c66affSColin Finck    End Sub
958c2c66affSColin Finck
959c2c66affSColin Finck    Property Get gsGetProp(x)
960c2c66affSColin Finck        gsGetProp = x
961c2c66affSColin Finck    End Property
962c2c66affSColin FinckEnd Class
963c2c66affSColin Finck
964c2c66affSColin FinckCall testDisp(new testClass)
965c2c66affSColin Finck
966c2c66affSColin FinckSet obj = New TestClass
967c2c66affSColin Finck
968c2c66affSColin FinckCall ok(obj.publicFunction = 4, "obj.publicFunction = " & obj.publicFunction)
969c2c66affSColin FinckCall ok(obj.publicFunction() = 4, "obj.publicFunction() = " & obj.publicFunction())
970c2c66affSColin Finck
971c2c66affSColin Finckobj.publicSub()
972c2c66affSColin FinckCall obj.publicSub
973c2c66affSColin FinckCall obj.publicFunction()
974c2c66affSColin Finck
975c2c66affSColin FinckCall ok(getVT(obj.publicProp) = "VT_EMPTY", "getVT(obj.publicProp) = " & getVT(obj.publicProp))
976c2c66affSColin Finckobj.publicProp = 3
977c2c66affSColin FinckCall ok(getVT(obj.publicProp) = "VT_I2", "getVT(obj.publicProp) = " & getVT(obj.publicProp))
978c2c66affSColin FinckCall ok(obj.publicProp = 3, "obj.publicProp = " & obj.publicProp)
979c2c66affSColin Finckobj.publicProp() = 3
980c2c66affSColin Finck
981c2c66affSColin FinckCall ok(obj.getPrivateProp() = true, "obj.getPrivateProp() = " & obj.getPrivateProp())
982c2c66affSColin FinckCall obj.setPrivateProp(6)
983c2c66affSColin FinckCall ok(obj.getPrivateProp = 6, "obj.getPrivateProp = " & obj.getPrivateProp)
984c2c66affSColin Finck
985c2c66affSColin FinckDim funcCalled
986c2c66affSColin FinckfuncCalled = ""
987c2c66affSColin FinckCall ok(obj.gsProp = 6, "obj.gsProp = " & obj.gsProp)
988c2c66affSColin FinckCall ok(funcCalled = "gsProp get", "funcCalled = " & funcCalled)
989c2c66affSColin Finckobj.gsProp = 3
990c2c66affSColin FinckCall ok(funcCalled = "gsProp let", "funcCalled = " & funcCalled)
991c2c66affSColin FinckCall ok(obj.getPrivateProp = 3, "obj.getPrivateProp = " & obj.getPrivateProp)
992c2c66affSColin FinckSet obj.gsProp = New testclass
993c2c66affSColin FinckCall ok(funcCalled = "gsProp set", "funcCalled = " & funcCalled)
994c2c66affSColin Finck
995c2c66affSColin Finckx = obj
996c2c66affSColin FinckCall ok(x = 3, "(x = obj) = " & x)
997c2c66affSColin FinckCall ok(funcCalled = "GetDefVal", "funcCalled = " & funcCalled)
998c2c66affSColin FinckfuncCalled = ""
999c2c66affSColin FinckCall ok(obj = 3, "(x = obj) = " & obj)
1000c2c66affSColin FinckCall ok(funcCalled = "GetDefVal", "funcCalled = " & funcCalled)
1001c2c66affSColin Finck
1002c2c66affSColin FinckCall obj.Class_Initialize
1003c2c66affSColin FinckCall ok(obj.getPrivateProp() = true, "obj.getPrivateProp() = " & obj.getPrivateProp())
1004c2c66affSColin Finck
1005c2c66affSColin Finckx = (New testclass).publicProp
1006c2c66affSColin Finck
1007c2c66affSColin FinckClass TermTest
1008c2c66affSColin Finck    Public Sub Class_Terminate()
1009c2c66affSColin Finck        funcCalled = "terminate"
1010c2c66affSColin Finck    End Sub
1011c2c66affSColin FinckEnd Class
1012c2c66affSColin Finck
1013c2c66affSColin FinckSet obj = New TermTest
1014c2c66affSColin FinckfuncCalled = ""
1015c2c66affSColin FinckSet obj = Nothing
1016c2c66affSColin FinckCall ok(funcCalled = "terminate", "funcCalled = " & funcCalled)
1017c2c66affSColin Finck
1018c2c66affSColin FinckSet obj = New TermTest
1019c2c66affSColin FinckfuncCalled = ""
1020c2c66affSColin FinckCall obj.Class_Terminate
1021c2c66affSColin FinckCall ok(funcCalled = "terminate", "funcCalled = " & funcCalled)
1022c2c66affSColin FinckfuncCalled = ""
1023c2c66affSColin FinckSet obj = Nothing
1024c2c66affSColin FinckCall ok(funcCalled = "terminate", "funcCalled = " & funcCalled)
1025c2c66affSColin Finck
1026c2c66affSColin FinckCall (New testclass).publicSub()
1027c2c66affSColin FinckCall (New testclass).publicSub
1028c2c66affSColin Finck
1029c2c66affSColin Finckclass PropTest
1030c2c66affSColin Finck    property get prop0()
1031c2c66affSColin Finck        prop0 = 1
1032c2c66affSColin Finck    end property
1033c2c66affSColin Finck
1034c2c66affSColin Finck    property get prop1(x)
1035c2c66affSColin Finck        prop1 = x+1
1036c2c66affSColin Finck    end property
1037c2c66affSColin Finck
1038c2c66affSColin Finck    property get prop2(x, y)
1039c2c66affSColin Finck        prop2 = x+y
1040c2c66affSColin Finck    end property
1041c2c66affSColin Finckend class
1042c2c66affSColin Finck
1043c2c66affSColin Finckset obj = new PropTest
1044c2c66affSColin Finck
1045c2c66affSColin Finckcall ok(obj.prop0 = 1, "obj.prop0 = " & obj.prop0)
1046c2c66affSColin Finckcall ok(obj.prop1(3) = 4, "obj.prop1(3) = " & obj.prop1(3))
1047c2c66affSColin Finckcall ok(obj.prop2(3,4) = 7, "obj.prop2(3,4) = " & obj.prop2(3,4))
1048c2c66affSColin Finckcall obj.prop0()
1049c2c66affSColin Finckcall obj.prop1(2)
1050c2c66affSColin Finckcall obj.prop2(3,4)
1051c2c66affSColin Finck
1052c2c66affSColin Finckx = "following ':' is correct syntax" :
1053c2c66affSColin Finckx = "following ':' is correct syntax" :: :
1054c2c66affSColin Finck:: x = "also correct syntax"
1055c2c66affSColin Finckrem another ugly way for comments
1056c2c66affSColin Finckx = "rem as simplestatement" : rem rem comment
1057c2c66affSColin Finck:
1058c2c66affSColin Finck
1059c2c66affSColin FinckSet obj = new EmptyClass
1060c2c66affSColin FinckSet x = obj
1061c2c66affSColin FinckSet y = new EmptyClass
1062c2c66affSColin Finck
1063c2c66affSColin FinckCall ok(obj is x, "obj is not x")
1064c2c66affSColin FinckCall ok(x is obj, "x is not obj")
1065c2c66affSColin FinckCall ok(not (obj is y), "obj is not y")
1066c2c66affSColin FinckCall ok(not obj is y, "obj is not y")
1067c2c66affSColin FinckCall ok(not (x is Nothing), "x is 1")
1068c2c66affSColin FinckCall ok(Nothing is Nothing, "Nothing is not Nothing")
1069c2c66affSColin FinckCall ok(x is obj and true, "x is obj and true is false")
1070c2c66affSColin Finck
1071c2c66affSColin FinckClass TestMe
1072c2c66affSColin Finck    Public Sub Test(MyMe)
1073c2c66affSColin Finck        Call ok(Me is MyMe, "Me is not MyMe")
1074c2c66affSColin Finck    End Sub
1075c2c66affSColin FinckEnd Class
1076c2c66affSColin Finck
1077c2c66affSColin FinckSet obj = New TestMe
1078c2c66affSColin FinckCall obj.test(obj)
1079c2c66affSColin Finck
1080c2c66affSColin FinckCall ok(getVT(test) = "VT_DISPATCH", "getVT(test) = " & getVT(test))
1081c2c66affSColin FinckCall ok(Me is Test, "Me is not Test")
1082c2c66affSColin Finck
1083c2c66affSColin FinckConst c1 = 1, c2 = 2, c3 = -3
1084c2c66affSColin FinckCall ok(c1 = 1, "c1 = " & c1)
1085c2c66affSColin FinckCall ok(getVT(c1) = "VT_I2", "getVT(c1) = " & getVT(c1))
1086c2c66affSColin FinckCall ok(c3 = -3, "c3 = " & c3)
1087c2c66affSColin FinckCall ok(getVT(c3) = "VT_I2", "getVT(c3) = " & getVT(c3))
1088c2c66affSColin Finck
1089c2c66affSColin FinckConst cb = True, cs = "test", cnull = null
1090c2c66affSColin FinckCall ok(cb, "cb = " & cb)
1091c2c66affSColin FinckCall ok(getVT(cb) = "VT_BOOL", "getVT(cb) = " & getVT(cb))
1092c2c66affSColin FinckCall ok(cs = "test", "cs = " & cs)
1093c2c66affSColin FinckCall ok(getVT(cs) = "VT_BSTR", "getVT(cs) = " & getVT(cs))
1094c2c66affSColin FinckCall ok(isNull(cnull), "cnull = " & cnull)
1095c2c66affSColin FinckCall ok(getVT(cnull) = "VT_NULL", "getVT(cnull) = " & getVT(cnull))
1096c2c66affSColin Finck
1097*7d76303dSAmine KhaldiCall ok(+1 = 1, "+1 != 1")
1098*7d76303dSAmine KhaldiCall ok(+true = true, "+1 != 1")
1099*7d76303dSAmine KhaldiCall ok(getVT(+true) = "VT_BOOL", "getVT(+true) = " & getVT(+true))
1100*7d76303dSAmine KhaldiCall ok(+"true" = "true", """+true"" != true")
1101*7d76303dSAmine KhaldiCall ok(getVT(+"true") = "VT_BSTR", "getVT(+""true"") = " & getVT(+"true"))
1102*7d76303dSAmine KhaldiCall ok(+obj is obj, "+obj != obj")
1103*7d76303dSAmine KhaldiCall ok(+--+-+1 = -1, "+--+-+1 != -1")
1104*7d76303dSAmine Khaldi
1105c2c66affSColin Finckif false then Const conststr = "str"
1106c2c66affSColin FinckCall ok(conststr = "str", "conststr = " & conststr)
1107c2c66affSColin FinckCall ok(getVT(conststr) = "VT_BSTR", "getVT(conststr) = " & getVT(conststr))
1108c2c66affSColin FinckCall ok(conststr = "str", "conststr = " & conststr)
1109c2c66affSColin Finck
1110c2c66affSColin FinckSub ConstTestSub
1111c2c66affSColin Finck    Const funcconst = 1
1112c2c66affSColin Finck    Call ok(c1 = 1, "c1 = " & c1)
1113c2c66affSColin Finck    Call ok(funcconst = 1, "funcconst = " & funcconst)
1114c2c66affSColin FinckEnd Sub
1115c2c66affSColin Finck
1116c2c66affSColin FinckCall ConstTestSub
1117c2c66affSColin FinckDim funcconst
1118c2c66affSColin Finck
1119c2c66affSColin Finck' Property may be used as an identifier (although it's a keyword)
1120c2c66affSColin FinckSub TestProperty
1121c2c66affSColin Finck    Dim Property
1122c2c66affSColin Finck    PROPERTY = true
1123c2c66affSColin Finck    Call ok(property, "property = " & property)
1124c2c66affSColin Finck
1125c2c66affSColin Finck    for property = 1 to 2
1126c2c66affSColin Finck    next
1127c2c66affSColin FinckEnd Sub
1128c2c66affSColin Finck
1129c2c66affSColin FinckCall TestProperty
1130c2c66affSColin Finck
1131c2c66affSColin FinckClass Property
1132c2c66affSColin Finck    Public Sub Property()
1133c2c66affSColin Finck    End Sub
1134c2c66affSColin Finck
1135c2c66affSColin Finck    Sub Test(byref property)
1136c2c66affSColin Finck    End Sub
1137c2c66affSColin FinckEnd Class
1138c2c66affSColin Finck
1139c2c66affSColin FinckClass Property2
1140c2c66affSColin Finck    Function Property()
1141c2c66affSColin Finck    End Function
1142c2c66affSColin Finck
1143c2c66affSColin Finck    Sub Test(property)
1144c2c66affSColin Finck    End Sub
1145c2c66affSColin Finck
1146c2c66affSColin Finck    Sub Test2(byval property)
1147c2c66affSColin Finck    End Sub
1148c2c66affSColin FinckEnd Class
1149c2c66affSColin Finck
1150942c4265SAmine KhaldiClass SeparatorTest : : Dim varTest1
1151942c4265SAmine Khaldi:
1152942c4265SAmine Khaldi    Private Sub Class_Initialize : varTest1 = 1
1153942c4265SAmine Khaldi    End Sub ::
1154942c4265SAmine Khaldi
1155942c4265SAmine Khaldi    Property Get Test1() :
1156942c4265SAmine Khaldi        Test1 = varTest1
1157942c4265SAmine Khaldi    End Property ::
1158942c4265SAmine Khaldi: :
1159942c4265SAmine Khaldi    Property Let Test1(a) :
1160942c4265SAmine Khaldi        varTest1 = a
1161942c4265SAmine Khaldi    End Property :
1162942c4265SAmine Khaldi
1163942c4265SAmine Khaldi    Public Function AddToTest1(ByVal a)  :: :
1164942c4265SAmine Khaldi        varTest1 = varTest1 + a
1165942c4265SAmine Khaldi        AddToTest1 = varTest1
1166942c4265SAmine Khaldi    End Function :    End Class : ::   Set obj = New SeparatorTest
1167942c4265SAmine Khaldi
1168942c4265SAmine KhaldiCall ok(obj.Test1 = 1, "obj.Test1 is not 1")
1169942c4265SAmine Khaldiobj.Test1 = 6
1170942c4265SAmine KhaldiCall ok(obj.Test1 = 6, "obj.Test1 is not 6")
1171942c4265SAmine Khaldiobj.AddToTest1(5)
1172942c4265SAmine KhaldiCall ok(obj.Test1 = 11, "obj.Test1 is not 11")
1173942c4265SAmine Khaldi
1174c2c66affSColin Finck' Array tests
1175c2c66affSColin Finck
1176c2c66affSColin FinckCall ok(getVT(arr) = "VT_EMPTY*", "getVT(arr) = " & getVT(arr))
1177c2c66affSColin Finck
1178c2c66affSColin FinckDim arr(3)
1179c2c66affSColin FinckDim arr2(4,3), arr3(5,4,3), arr0(0), noarr()
1180c2c66affSColin Finck
1181c2c66affSColin FinckCall ok(getVT(arr) = "VT_ARRAY|VT_BYREF|VT_VARIANT*", "getVT(arr) = " & getVT(arr))
1182c2c66affSColin FinckCall ok(getVT(arr2) = "VT_ARRAY|VT_BYREF|VT_VARIANT*", "getVT(arr2) = " & getVT(arr2))
1183c2c66affSColin FinckCall ok(getVT(arr0) = "VT_ARRAY|VT_BYREF|VT_VARIANT*", "getVT(arr0) = " & getVT(arr0))
1184c2c66affSColin FinckCall ok(getVT(noarr) = "VT_ARRAY|VT_BYREF|VT_VARIANT*", "getVT(noarr) = " & getVT(noarr))
1185c2c66affSColin Finck
1186c2c66affSColin FinckCall testArray(1, arr)
1187c2c66affSColin FinckCall testArray(2, arr2)
1188c2c66affSColin FinckCall testArray(3, arr3)
1189c2c66affSColin FinckCall testArray(0, arr0)
1190c2c66affSColin FinckCall testArray(-1, noarr)
1191c2c66affSColin Finck
1192c2c66affSColin FinckCall ok(getVT(arr(1)) = "VT_EMPTY*", "getVT(arr(1)) = " & getVT(arr(1)))
1193c2c66affSColin FinckCall ok(getVT(arr2(1,2)) = "VT_EMPTY*", "getVT(arr2(1,2)) = " & getVT(arr2(1,2)))
1194c2c66affSColin FinckCall ok(getVT(arr3(1,2,2)) = "VT_EMPTY*", "getVT(arr3(1,2,3)) = " & getVT(arr3(1,2,2)))
1195c2c66affSColin FinckCall ok(getVT(arr(0)) = "VT_EMPTY*", "getVT(arr(0)) = " & getVT(arr(0)))
1196c2c66affSColin FinckCall ok(getVT(arr(3)) = "VT_EMPTY*", "getVT(arr(3)) = " & getVT(arr(3)))
1197c2c66affSColin FinckCall ok(getVT(arr0(0)) = "VT_EMPTY*", "getVT(arr0(0)) = " & getVT(arr0(0)))
1198c2c66affSColin Finck
1199c2c66affSColin Finckarr(2) = 3
1200c2c66affSColin FinckCall ok(arr(2) = 3, "arr(2) = " & arr(2))
1201c2c66affSColin FinckCall ok(getVT(arr(2)) = "VT_I2*", "getVT(arr(2)) = " & getVT(arr(2)))
1202c2c66affSColin Finck
1203c2c66affSColin Finckarr3(3,2,1) = 1
1204c2c66affSColin Finckarr3(1,2,3) = 2
1205c2c66affSColin FinckCall ok(arr3(3,2,1) = 1, "arr3(3,2,1) = " & arr3(3,2,1))
1206c2c66affSColin FinckCall ok(arr3(1,2,3) = 2, "arr3(1,2,3) = " & arr3(1,2,3))
1207942c4265SAmine Khaldiarr2(4,3) = 1
1208942c4265SAmine KhaldiCall ok(arr2(4,3) = 1, "arr2(4,3) = " & arr2(4,3))
1209c2c66affSColin Finck
1210c2c66affSColin Finckx = arr3
1211c2c66affSColin FinckCall ok(x(3,2,1) = 1, "x(3,2,1) = " & x(3,2,1))
1212c2c66affSColin Finck
1213c2c66affSColin FinckFunction getarr()
1214c2c66affSColin Finck    Dim arr(3)
1215c2c66affSColin Finck    arr(2) = 2
1216c2c66affSColin Finck    getarr = arr
1217c2c66affSColin Finck    arr(3) = 3
1218c2c66affSColin FinckEnd Function
1219c2c66affSColin Finck
1220c2c66affSColin Finckx = getarr()
1221c2c66affSColin FinckCall ok(getVT(x) = "VT_ARRAY|VT_VARIANT*", "getVT(x) = " & getVT(x))
1222c2c66affSColin FinckCall ok(x(2) = 2, "x(2) = " & x(2))
1223c2c66affSColin FinckCall ok(getVT(x(3)) = "VT_EMPTY*", "getVT(x(3)) = " & getVT(x(3)))
1224c2c66affSColin Finck
1225c2c66affSColin Finckx(1) = 1
1226c2c66affSColin FinckCall ok(x(1) = 1, "x(1) = " & x(1))
1227c2c66affSColin Finckx = getarr()
1228c2c66affSColin FinckCall ok(getVT(x(1)) = "VT_EMPTY*", "getVT(x(1)) = " & getVT(x(1)))
1229c2c66affSColin FinckCall ok(x(2) = 2, "x(2) = " & x(2))
1230c2c66affSColin Finck
1231c2c66affSColin Finckx(1) = 1
1232c2c66affSColin Fincky = x
1233c2c66affSColin Finckx(1) = 2
1234c2c66affSColin FinckCall ok(y(1) = 1, "y(1) = " & y(1))
1235c2c66affSColin Finck
1236c2c66affSColin Finckfor x=1 to 1
1237c2c66affSColin Finck    Dim forarr(3)
1238c2c66affSColin Finck    if x=1 then
1239c2c66affSColin Finck        Call ok(getVT(forarr(1)) = "VT_EMPTY*", "getVT(forarr(1)) = " & getVT(forarr(1)))
1240c2c66affSColin Finck    else
1241c2c66affSColin Finck        Call ok(forarr(1) = x, "forarr(1) = " & forarr(1))
1242c2c66affSColin Finck    end if
1243c2c66affSColin Finck    forarr(1) = x+1
1244c2c66affSColin Fincknext
1245c2c66affSColin Finck
1246c2c66affSColin Finckx=1
1247c2c66affSColin FinckCall ok(forarr(x) = 2, "forarr(x) = " & forarr(x))
1248c2c66affSColin Finck
1249c2c66affSColin FinckClass ArrClass
1250c2c66affSColin Finck    Dim classarr(3)
1251c2c66affSColin Finck    Dim classnoarr()
1252c2c66affSColin Finck    Dim var
1253c2c66affSColin Finck
1254c2c66affSColin Finck    Private Sub Class_Initialize
1255c2c66affSColin Finck        Call ok(getVT(classarr) = "VT_ARRAY|VT_BYREF|VT_VARIANT*", "getVT(classarr) = " & getVT(classarr))
1256c2c66affSColin Finck        Call testArray(-1, classnoarr)
1257c2c66affSColin Finck        classarr(0) = 1
1258c2c66affSColin Finck        classarr(1) = 2
1259c2c66affSColin Finck        classarr(2) = 3
1260c2c66affSColin Finck        classarr(3) = 4
1261c2c66affSColin Finck    End Sub
1262c2c66affSColin Finck
1263c2c66affSColin Finck    Public Sub testVarVT
1264c2c66affSColin Finck        Call ok(getVT(var) = "VT_ARRAY|VT_VARIANT*", "getVT(var) = " & getVT(var))
1265c2c66affSColin Finck    End Sub
1266c2c66affSColin FinckEnd Class
1267c2c66affSColin Finck
1268c2c66affSColin FinckSet obj = new ArrClass
1269c2c66affSColin FinckCall ok(getVT(obj.classarr) = "VT_ARRAY|VT_VARIANT", "getVT(obj.classarr) = " & getVT(obj.classarr))
1270c2c66affSColin Finck'todo_wine Call ok(obj.classarr(1) = 2, "obj.classarr(1) = " & obj.classarr(1))
1271c2c66affSColin Finck
1272c2c66affSColin Finckobj.var = arr
1273c2c66affSColin FinckCall ok(getVT(obj.var) = "VT_ARRAY|VT_VARIANT", "getVT(obj.var) = " & getVT(obj.var))
1274c2c66affSColin FinckCall obj.testVarVT
1275c2c66affSColin Finck
1276c2c66affSColin FinckSub arrarg(byref refarr, byval valarr, byref refarr2, byval valarr2)
1277c2c66affSColin Finck    Call ok(getVT(refarr) = "VT_ARRAY|VT_BYREF|VT_VARIANT*", "getVT(refarr) = " & getVT(refarr))
1278c2c66affSColin Finck    Call ok(getVT(valarr) = "VT_ARRAY|VT_VARIANT*", "getVT(valarr) = " & getVT(valarr))
1279c2c66affSColin Finck    Call ok(getVT(refarr2) = "VT_ARRAY|VT_VARIANT*", "getVT(refarr2) = " & getVT(refarr2))
1280c2c66affSColin Finck    Call ok(getVT(valarr2) = "VT_ARRAY|VT_VARIANT*", "getVT(valarr2) = " & getVT(valarr2))
1281c2c66affSColin FinckEnd Sub
1282c2c66affSColin Finck
1283c2c66affSColin FinckCall arrarg(arr, arr, obj.classarr, obj.classarr)
1284c2c66affSColin Finck
1285c2c66affSColin FinckSub arrarg2(byref refarr(), byval valarr(), byref refarr2(), byval valarr2())
1286c2c66affSColin Finck    Call ok(getVT(refarr) = "VT_ARRAY|VT_BYREF|VT_VARIANT*", "getVT(refarr) = " & getVT(refarr))
1287c2c66affSColin Finck    Call ok(getVT(valarr) = "VT_ARRAY|VT_VARIANT*", "getVT(valarr) = " & getVT(valarr))
1288c2c66affSColin Finck    Call ok(getVT(refarr2) = "VT_ARRAY|VT_VARIANT*", "getVT(refarr2) = " & getVT(refarr2))
1289c2c66affSColin Finck    Call ok(getVT(valarr2) = "VT_ARRAY|VT_VARIANT*", "getVT(valarr2) = " & getVT(valarr2))
1290c2c66affSColin FinckEnd Sub
1291c2c66affSColin Finck
1292c2c66affSColin FinckCall arrarg2(arr, arr, obj.classarr, obj.classarr)
1293c2c66affSColin Finck
1294c2c66affSColin FinckSub testarrarg(arg(), vt)
1295c2c66affSColin Finck    Call ok(getVT(arg) = vt, "getVT() = " & getVT(arg) & " expected " & vt)
1296c2c66affSColin FinckEnd Sub
1297c2c66affSColin Finck
1298c2c66affSColin FinckCall testarrarg(1, "VT_I2*")
1299c2c66affSColin FinckCall testarrarg(false, "VT_BOOL*")
1300c2c66affSColin FinckCall testarrarg(Empty, "VT_EMPTY*")
1301c2c66affSColin Finck
1302942c4265SAmine KhaldiSub modifyarr(arr)
1303942c4265SAmine Khaldi    'Following test crashes on wine
1304942c4265SAmine Khaldi    'Call ok(arr(0) = "not modified", "arr(0) = " & arr(0))
1305942c4265SAmine Khaldi    arr(0) = "modified"
1306942c4265SAmine KhaldiEnd Sub
1307942c4265SAmine Khaldi
1308942c4265SAmine Khaldiarr(0) = "not modified"
1309942c4265SAmine KhaldiCall modifyarr(arr)
1310942c4265SAmine KhaldiCall ok(arr(0) = "modified", "arr(0) = " & arr(0))
1311942c4265SAmine Khaldi
1312942c4265SAmine Khaldiarr(0) = "not modified"
1313942c4265SAmine Khaldimodifyarr(arr)
1314942c4265SAmine KhaldiCall todo_wine_ok(arr(0) = "not modified", "arr(0) = " & arr(0))
1315942c4265SAmine Khaldi
1316942c4265SAmine Khaldifor x = 0 to UBound(arr)
1317942c4265SAmine Khaldi    arr(x) = x
1318942c4265SAmine Khaldinext
1319942c4265SAmine Khaldiy = 0
1320942c4265SAmine Khaldifor each x in arr
1321942c4265SAmine Khaldi    Call ok(x = y, "x = " & x & ", expected " & y)
1322942c4265SAmine Khaldi    Call ok(arr(y) = y, "arr(" & y & ") = " & arr(y))
1323942c4265SAmine Khaldi    arr(y) = 1
1324942c4265SAmine Khaldi    x = 1
1325942c4265SAmine Khaldi    y = y+1
1326942c4265SAmine Khaldinext
1327942c4265SAmine KhaldiCall ok(y = 4, "y = " & y & " after array enumeration")
1328942c4265SAmine Khaldi
1329942c4265SAmine Khaldifor x=0 to UBound(arr2, 1)
1330942c4265SAmine Khaldi    for y=0 to UBound(arr2, 2)
1331942c4265SAmine Khaldi        arr2(x, y) = x + y*(UBound(arr2, 1)+1)
1332942c4265SAmine Khaldi    next
1333942c4265SAmine Khaldinext
1334942c4265SAmine Khaldiy = 0
1335942c4265SAmine Khaldifor each x in arr2
1336942c4265SAmine Khaldi    Call ok(x = y, "x = " & x & ", expected " & y)
1337942c4265SAmine Khaldi    y = y+1
1338942c4265SAmine Khaldinext
1339942c4265SAmine KhaldiCall ok(y = 20, "y = " & y & " after array enumeration")
1340942c4265SAmine Khaldi
1341942c4265SAmine Khaldifor each x in noarr
1342942c4265SAmine Khaldi    Call ok(false, "Empty array contains: " & x)
1343942c4265SAmine Khaldinext
1344942c4265SAmine Khaldi
1345c2c66affSColin Finck' It's allowed to declare non-builtin RegExp class...
1346c2c66affSColin Finckclass RegExp
1347c2c66affSColin Finck     public property get Global()
1348c2c66affSColin Finck         Call ok(false, "Global called")
1349c2c66affSColin Finck         Global = "fail"
1350c2c66affSColin Finck     end property
1351c2c66affSColin Finckend class
1352c2c66affSColin Finck
1353c2c66affSColin Finck' ...but there is no way to use it because builtin instance is always created
1354c2c66affSColin Finckset x = new RegExp
1355c2c66affSColin FinckCall ok(x.Global = false, "x.Global = " & x.Global)
1356c2c66affSColin Finck
1357*7d76303dSAmine Khaldisub test_nothing_errors
1358*7d76303dSAmine Khaldi    dim x
1359*7d76303dSAmine Khaldi    on error resume next
1360*7d76303dSAmine Khaldi
1361*7d76303dSAmine Khaldi    x = 1
1362*7d76303dSAmine Khaldi    err.clear
1363*7d76303dSAmine Khaldi    x = nothing
1364*7d76303dSAmine Khaldi    call ok(err.number = 91, "err.number = " & err.number)
1365*7d76303dSAmine Khaldi    call ok(x = 1, "x = " & x)
1366*7d76303dSAmine Khaldi
1367*7d76303dSAmine Khaldi    err.clear
1368*7d76303dSAmine Khaldi    x = not nothing
1369*7d76303dSAmine Khaldi    call ok(err.number = 91, "err.number = " & err.number)
1370*7d76303dSAmine Khaldi    call ok(x = 1, "x = " & x)
1371*7d76303dSAmine Khaldi
1372*7d76303dSAmine Khaldi    err.clear
1373*7d76303dSAmine Khaldi    x = "" & nothing
1374*7d76303dSAmine Khaldi    call ok(err.number = 91, "err.number = " & err.number)
1375*7d76303dSAmine Khaldi    call ok(x = 1, "x = " & x)
1376*7d76303dSAmine Khaldiend sub
1377*7d76303dSAmine Khaldicall test_nothing_errors()
1378*7d76303dSAmine Khaldi
1379*7d76303dSAmine Khaldisub test_identifiers
1380*7d76303dSAmine Khaldi    ' test keywords that can also be a declared identifier
1381*7d76303dSAmine Khaldi    Dim default
1382*7d76303dSAmine Khaldi    default = "xx"
1383*7d76303dSAmine Khaldi    Call ok(default = "xx", "default = " & default & " expected ""xx""")
1384*7d76303dSAmine Khaldi
1385*7d76303dSAmine Khaldi    Dim error
1386*7d76303dSAmine Khaldi    error = "xx"
1387*7d76303dSAmine Khaldi    Call ok(error = "xx", "error = " & error & " expected ""xx""")
1388*7d76303dSAmine Khaldi
1389*7d76303dSAmine Khaldi    Dim explicit
1390*7d76303dSAmine Khaldi    explicit = "xx"
1391*7d76303dSAmine Khaldi    Call ok(explicit = "xx", "explicit = " & explicit & " expected ""xx""")
1392*7d76303dSAmine Khaldi
1393*7d76303dSAmine Khaldi    Dim step
1394*7d76303dSAmine Khaldi    step = "xx"
1395*7d76303dSAmine Khaldi    Call ok(step = "xx", "step = " & step & " expected ""xx""")
1396*7d76303dSAmine Khaldiend sub
1397*7d76303dSAmine Khaldicall test_identifiers()
1398*7d76303dSAmine Khaldi
1399*7d76303dSAmine Khaldisub test_dotIdentifiers
1400*7d76303dSAmine Khaldi    ' test keywords that can also be an identifier after a dot
1401*7d76303dSAmine Khaldi    ' Call ok(testObj.rem = 10, "testObj.rem = " & testObj.rem & " expected 10")
1402*7d76303dSAmine Khaldi    Call ok(testObj.true = 10, "testObj.true = " & testObj.true & " expected 10")
1403*7d76303dSAmine Khaldi    Call ok(testObj.false = 10, "testObj.false = " & testObj.false & " expected 10")
1404*7d76303dSAmine Khaldi    Call ok(testObj.not = 10, "testObj.not = " & testObj.not & " expected 10")
1405*7d76303dSAmine Khaldi    Call ok(testObj.and = 10, "testObj.and = " & testObj.and & " expected 10")
1406*7d76303dSAmine Khaldi    Call ok(testObj.or = 10, "testObj.or = " & testObj.or & " expected 10")
1407*7d76303dSAmine Khaldi    Call ok(testObj.xor = 10, "testObj.xor = " & testObj.xor & " expected 10")
1408*7d76303dSAmine Khaldi    Call ok(testObj.eqv = 10, "testObj.eqv = " & testObj.eqv & " expected 10")
1409*7d76303dSAmine Khaldi    Call ok(testObj.imp = 10, "testObj.imp = " & testObj.imp & " expected 10")
1410*7d76303dSAmine Khaldi    Call ok(testObj.is = 10, "testObj.is = " & testObj.is & " expected 10")
1411*7d76303dSAmine Khaldi    Call ok(testObj.mod = 10, "testObj.mod = " & testObj.mod & " expected 10")
1412*7d76303dSAmine Khaldi    Call ok(testObj.call = 10, "testObj.call = " & testObj.call & " expected 10")
1413*7d76303dSAmine Khaldi    Call ok(testObj.dim = 10, "testObj.dim = " & testObj.dim & " expected 10")
1414*7d76303dSAmine Khaldi    Call ok(testObj.sub = 10, "testObj.sub = " & testObj.sub & " expected 10")
1415*7d76303dSAmine Khaldi    Call ok(testObj.function = 10, "testObj.function = " & testObj.function & " expected 10")
1416*7d76303dSAmine Khaldi    Call ok(testObj.get = 10, "testObj.get = " & testObj.get & " expected 10")
1417*7d76303dSAmine Khaldi    Call ok(testObj.let = 10, "testObj.let = " & testObj.let & " expected 10")
1418*7d76303dSAmine Khaldi    Call ok(testObj.const = 10, "testObj.const = " & testObj.const & " expected 10")
1419*7d76303dSAmine Khaldi    Call ok(testObj.if = 10, "testObj.if = " & testObj.if & " expected 10")
1420*7d76303dSAmine Khaldi    Call ok(testObj.else = 10, "testObj.else = " & testObj.else & " expected 10")
1421*7d76303dSAmine Khaldi    Call ok(testObj.elseif = 10, "testObj.elseif = " & testObj.elseif & " expected 10")
1422*7d76303dSAmine Khaldi    Call ok(testObj.end = 10, "testObj.end = " & testObj.end & " expected 10")
1423*7d76303dSAmine Khaldi    Call ok(testObj.then = 10, "testObj.then = " & testObj.then & " expected 10")
1424*7d76303dSAmine Khaldi    Call ok(testObj.exit = 10, "testObj.exit = " & testObj.exit & " expected 10")
1425*7d76303dSAmine Khaldi    Call ok(testObj.while = 10, "testObj.while = " & testObj.while & " expected 10")
1426*7d76303dSAmine Khaldi    Call ok(testObj.wend = 10, "testObj.wend = " & testObj.wend & " expected 10")
1427*7d76303dSAmine Khaldi    Call ok(testObj.do = 10, "testObj.do = " & testObj.do & " expected 10")
1428*7d76303dSAmine Khaldi    Call ok(testObj.loop = 10, "testObj.loop = " & testObj.loop & " expected 10")
1429*7d76303dSAmine Khaldi    Call ok(testObj.until = 10, "testObj.until = " & testObj.until & " expected 10")
1430*7d76303dSAmine Khaldi    Call ok(testObj.for = 10, "testObj.for = " & testObj.for & " expected 10")
1431*7d76303dSAmine Khaldi    Call ok(testObj.to = 10, "testObj.to = " & testObj.to & " expected 10")
1432*7d76303dSAmine Khaldi    Call ok(testObj.each = 10, "testObj.each = " & testObj.each & " expected 10")
1433*7d76303dSAmine Khaldi    Call ok(testObj.in = 10, "testObj.in = " & testObj.in & " expected 10")
1434*7d76303dSAmine Khaldi    Call ok(testObj.select = 10, "testObj.select = " & testObj.select & " expected 10")
1435*7d76303dSAmine Khaldi    Call ok(testObj.case = 10, "testObj.case = " & testObj.case & " expected 10")
1436*7d76303dSAmine Khaldi    Call ok(testObj.byref = 10, "testObj.byref = " & testObj.byref & " expected 10")
1437*7d76303dSAmine Khaldi    Call ok(testObj.byval = 10, "testObj.byval = " & testObj.byval & " expected 10")
1438*7d76303dSAmine Khaldi    Call ok(testObj.option = 10, "testObj.option = " & testObj.option & " expected 10")
1439*7d76303dSAmine Khaldi    Call ok(testObj.nothing = 10, "testObj.nothing = " & testObj.nothing & " expected 10")
1440*7d76303dSAmine Khaldi    Call ok(testObj.empty = 10, "testObj.empty = " & testObj.empty & " expected 10")
1441*7d76303dSAmine Khaldi    Call ok(testObj.null = 10, "testObj.null = " & testObj.null & " expected 10")
1442*7d76303dSAmine Khaldi    Call ok(testObj.class = 10, "testObj.class = " & testObj.class & " expected 10")
1443*7d76303dSAmine Khaldi    Call ok(testObj.set = 10, "testObj.set = " & testObj.set & " expected 10")
1444*7d76303dSAmine Khaldi    Call ok(testObj.new = 10, "testObj.new = " & testObj.new & " expected 10")
1445*7d76303dSAmine Khaldi    Call ok(testObj.public = 10, "testObj.public = " & testObj.public & " expected 10")
1446*7d76303dSAmine Khaldi    Call ok(testObj.private = 10, "testObj.private = " & testObj.private & " expected 10")
1447*7d76303dSAmine Khaldi    Call ok(testObj.next = 10, "testObj.next = " & testObj.next & " expected 10")
1448*7d76303dSAmine Khaldi    Call ok(testObj.on = 10, "testObj.on = " & testObj.on & " expected 10")
1449*7d76303dSAmine Khaldi    Call ok(testObj.resume = 10, "testObj.resume = " & testObj.resume & " expected 10")
1450*7d76303dSAmine Khaldi    Call ok(testObj.goto = 10, "testObj.goto = " & testObj.goto & " expected 10")
1451*7d76303dSAmine Khaldiend sub
1452*7d76303dSAmine Khaldicall test_dotIdentifiers
1453*7d76303dSAmine Khaldi
1454*7d76303dSAmine Khaldi' Test End statements not required to be preceeded by a newline or separator
1455*7d76303dSAmine KhaldiSub EndTestSub
1456*7d76303dSAmine Khaldi    x = 1 End Sub
1457*7d76303dSAmine Khaldi
1458*7d76303dSAmine KhaldiSub EndTestSubWithCall
1459*7d76303dSAmine Khaldi    x = 1
1460*7d76303dSAmine Khaldi    Call ok(x = 1, "x = " & x)End Sub
1461*7d76303dSAmine KhaldiCall EndTestSubWithCall()
1462*7d76303dSAmine Khaldi
1463*7d76303dSAmine KhaldiFunction EndTestFunc(x)
1464*7d76303dSAmine Khaldi    Call ok(x > 0, "x = " & x)End Function
1465*7d76303dSAmine KhaldiEndTestFunc(1)
1466*7d76303dSAmine Khaldi
1467*7d76303dSAmine KhaldiClass EndTestClassWithStorageId
1468*7d76303dSAmine Khaldi    Public x End Class
1469*7d76303dSAmine Khaldi
1470*7d76303dSAmine KhaldiClass EndTestClassWithDim
1471*7d76303dSAmine Khaldi    Dim x End Class
1472*7d76303dSAmine Khaldi
1473*7d76303dSAmine KhaldiClass EndTestClassWithFunc
1474*7d76303dSAmine Khaldi    Function test(ByVal x)
1475*7d76303dSAmine Khaldi        x = 0 End Function End Class
1476*7d76303dSAmine Khaldi
1477*7d76303dSAmine KhaldiClass EndTestClassWithProperty
1478*7d76303dSAmine Khaldi    Public x
1479*7d76303dSAmine Khaldi    Public default Property Get defprop
1480*7d76303dSAmine Khaldi        defprop = x End Property End Class
1481*7d76303dSAmine Khaldi
1482c2c66affSColin FinckreportSuccess()
1483