vbscript: Fixed locale-related test failures.
[wine/multimedia.git] / dlls / vbscript / tests / api.vbs
blobfd339dd9be759be52ce5b670752db8f44090476d
2 ' Copyright 2011 Jacek Caban for CodeWeavers
4 ' This library is free software; you can redistribute it and/or
5 ' modify it under the terms of the GNU Lesser General Public
6 ' License as published by the Free Software Foundation; either
7 ' version 2.1 of the License, or (at your option) any later version.
9 ' This library is distributed in the hope that it will be useful,
10 ' but WITHOUT ANY WARRANTY; without even the implied warranty of
11 ' MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 ' Lesser General Public License for more details.
14 ' You should have received a copy of the GNU Lesser General Public
15 ' License along with this library; if not, write to the Free Software
16 ' Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
19 Option Explicit
21 Dim x
23 Class EmptyClass
24 End Class
26 Call ok(vbSunday = 1, "vbSunday = " & vbSunday)
27 Call ok(getVT(vbSunday) = "VT_I2", "getVT(vbSunday) = " & getVT(vbSunday))
28 Call ok(vbMonday = 2, "vbMonday = " & vbMonday)
29 Call ok(getVT(vbMonday) = "VT_I2", "getVT(vbMonday) = " & getVT(vbMonday))
30 Call ok(vbTuesday = 3, "vbTuesday = " & vbTuesday)
31 Call ok(getVT(vbTuesday) = "VT_I2", "getVT(vbTuesday) = " & getVT(vbTuesday))
32 Call ok(vbWednesday = 4, "vbWednesday = " & vbWednesday)
33 Call ok(getVT(vbWednesday) = "VT_I2", "getVT(vbWednesday) = " & getVT(vbWednesday))
34 Call ok(vbThursday = 5, "vbThursday = " & vbThursday)
35 Call ok(getVT(vbThursday) = "VT_I2", "getVT(vbThursday) = " & getVT(vbThursday))
36 Call ok(vbFriday = 6, "vbFriday = " & vbFriday)
37 Call ok(getVT(vbFriday) = "VT_I2", "getVT(vbFriday) = " & getVT(vbFriday))
38 Call ok(vbSaturday = 7, "vbSaturday = " & vbSaturday)
39 Call ok(getVT(vbSaturday) = "VT_I2", "getVT(vbSaturday) = " & getVT(vbSaturday))
41 Call ok(isObject(new EmptyClass), "isObject(new EmptyClass) is not true?")
42 Set x = new EmptyClass
43 Call ok(isObject(x), "isObject(x) is not true?")
44 Call ok(isObject(Nothing), "isObject(Nothing) is not true?")
45 Call ok(not isObject(true), "isObject(true) is true?")
46 Call ok(not isObject(4), "isObject(4) is true?")
47 Call ok(not isObject("x"), "isObject(""x"") is true?")
48 Call ok(not isObject(Null), "isObject(Null) is true?")
50 Call ok(not isEmpty(new EmptyClass), "isEmpty(new EmptyClass) is true?")
51 Set x = new EmptyClass
52 Call ok(not isEmpty(x), "isEmpty(x) is true?")
53 x = empty
54 Call ok(isEmpty(x), "isEmpty(x) is not true?")
55 Call ok(isEmpty(empty), "isEmpty(empty) is not true?")
56 Call ok(not isEmpty(Nothing), "isEmpty(Nothing) is not true?")
57 Call ok(not isEmpty(true), "isEmpty(true) is true?")
58 Call ok(not isEmpty(4), "isEmpty(4) is true?")
59 Call ok(not isEmpty("x"), "isEmpty(""x"") is true?")
60 Call ok(not isEmpty(Null), "isEmpty(Null) is true?")
62 Call ok(not isNull(new EmptyClass), "isNull(new EmptyClass) is true?")
63 Set x = new EmptyClass
64 Call ok(not isNull(x), "isNull(x) is true?")
65 x = null
66 Call ok(isNull(x), "isNull(x) is not true?")
67 Call ok(not isNull(empty), "isNull(empty) is true?")
68 Call ok(not isNull(Nothing), "isNull(Nothing) is true?")
69 Call ok(not isNull(true), "isNull(true) is true?")
70 Call ok(not isNull(4), "isNull(4) is true?")
71 Call ok(not isNull("x"), "isNull(""x"") is true?")
72 Call ok(isNull(Null), "isNull(Null) is not true?")
74 Call ok(getVT(err) = "VT_DISPATCH", "getVT(err) = " & getVT(err))
76 Sub TestHex(x, ex)
77 Call ok(hex(x) = ex, "hex(" & x & ") = " & hex(x) & " expected " & ex)
78 End Sub
80 TestHex 0, "0"
81 TestHex 6, "6"
82 TestHex 16, "10"
83 TestHex &hdeadbeef&, "DEADBEEF"
84 TestHex -1, "FFFF"
85 TestHex -16, "FFF0"
86 TestHex -934859845, "C8472BBB"
87 TestHex empty, "0"
89 Call ok(getVT(hex(null)) = "VT_NULL", "getVT(hex(null)) = " & getVT(hex(null)))
90 Call ok(getVT(hex(empty)) = "VT_BSTR", "getVT(hex(empty)) = " & getVT(hex(empty)))
92 x = InStr(1, "abcd", "bc")
93 Call ok(x = 2, "InStr returned " & x)
95 x = InStr("abcd", "bc")
96 Call ok(x = 2, "InStr returned " & x)
98 x = InStr("abc", "bc")
99 Call ok(x = 2, "InStr returned " & x)
101 x = InStr("abcbc", "bc")
102 Call ok(x = 2, "InStr returned " & x)
104 x = InStr("bcabc", "bc")
105 Call ok(x = 1, "InStr returned " & x)
107 x = InStr(3, "abcd", "bc")
108 Call ok(x = 0, "InStr returned " & x)
110 x = InStr("abcd", "bcx")
111 Call ok(x = 0, "InStr returned " & x)
113 x = InStr(5, "abcd", "bc")
114 Call ok(x = 0, "InStr returned " & x)
116 x = "abcd"
117 x = InStr(x, "bc")
118 Call ok(x = 2, "InStr returned " & x)
120 x = InStr("abcd", null)
121 Call ok(isNull(x), "InStr returned " & x)
122 x = InStr(null, "abcd")
123 Call ok(isNull(x), "InStr returned " & x)
124 x = InStr(2, null, "abcd")
125 Call ok(isNull(x), "InStr returned " & x)
127 Sub TestMid(str, start, len, ex)
128 x = Mid(str, start, len)
129 Call ok(x = ex, "Mid(" & str & ", " & start & ", " & len & ") = " & x & " expected " & ex)
130 End Sub
132 Sub TestMid2(str, start, ex)
133 x = Mid(str, start)
134 Call ok(x = ex, "Mid(" & str & ", " & start & ") = " & x & " expected " & ex)
135 End Sub
137 TestMid "test", 2, 2, "es"
138 TestMid "test", 2, 4, "est"
139 TestMid "test", 1, 2, "te"
140 TestMid "test", 1, 0, ""
141 TestMid "test", 1, 0, ""
142 TestMid "test", 5, 2, ""
143 TestMid2 "test", 1, "test"
144 TestMid2 "test", 2, "est"
145 TestMid2 "test", 4, "t"
146 TestMid2 "test", 5, ""
148 Sub TestUCase(str, ex)
149 x = UCase(str)
150 Call ok(x = ex, "UCase(" & str & ") = " & x & " expected " & ex)
151 End Sub
153 TestUCase "test", "TEST"
154 TestUCase "123aBC?", "123ABC?"
155 TestUCase "", ""
156 TestUCase 1, "1"
157 if isEnglishLang then TestUCase true, "TRUE"
158 TestUCase 0.123, doubleAsString(0.123)
159 TestUCase Empty, ""
160 Call ok(getVT(UCase(Null)) = "VT_NULL", "getVT(UCase(Null)) = " & getVT(UCase(Null)))
162 Sub TestLCase(str, ex)
163 x = LCase(str)
164 Call ok(x = ex, "LCase(" & str & ") = " & x & " expected " & ex)
165 End Sub
167 TestLCase "test", "test"
168 TestLCase "123aBC?", "123abc?"
169 TestLCase "", ""
170 TestLCase 1, "1"
171 if isEnglishLang then TestLCase true, "true"
172 TestLCase 0.123, doubleAsString(0.123)
173 TestLCase Empty, ""
174 Call ok(getVT(LCase(Null)) = "VT_NULL", "getVT(LCase(Null)) = " & getVT(LCase(Null)))
176 Call reportSuccess()