vbscript: Added assign statement tests.
[wine] / dlls / vbscript / tests / lang.vbs
1 '
2 ' Copyright 2011 Jacek Caban for CodeWeavers
3 '
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.
8 '
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.
13 '
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
17 '
18
19 Option Explicit
20
21 call ok(true, "true is not true?")
22 ok true, "true is not true?"
23 call ok((true), "true is not true?")
24
25 ok not false, "not false but not true?"
26 ok not not true, "not not true but not true?"
27
28 Call ok(true = true, "true = true is false")
29 Call ok(false = false, "false = false is false")
30 Call ok(not (true = false), "true = false is true")
31 Call ok("x" = "x", """x"" = ""x"" is false")
32 Call ok(empty = empty, "empty = empty is false")
33 Call ok(empty = "", "empty = """" is false")
34 Call ok(0 = 0.0, "0 <> 0.0")
35 Call ok(16 = &h10&, "16 <> &h10&")
36 Call ok(010 = 10, "010 <> 10")
37 Call ok(10. = 10, "10. <> 10")
38 Call ok(&hffFFffFF& = -1, "&hffFFffFF& <> -1")
39 Call ok(&hffFFffFF& = -1, "&hffFFffFF& <> -1")
40 Call ok(--1 = 1, "--1 = " & --1)
41 Call ok(-empty = 0, "-empty = " & (-empty))
42
43 Call ok(true <> false, "true <> false is false")
44 Call ok(not (true <> true), "true <> true is true")
45 Call ok(not ("x" <> "x"), """x"" <> ""x"" is true")
46 Call ok(not (empty <> empty), "empty <> empty is true")
47
48 Call ok(getVT(false) = "VT_BOOL", "getVT(false) is not VT_BOOL")
49 Call ok(getVT(true) = "VT_BOOL", "getVT(true) is not VT_BOOL")
50 Call ok(getVT("") = "VT_BSTR", "getVT("""") is not VT_BSTR")
51 Call ok(getVT("test") = "VT_BSTR", "getVT(""test"") is not VT_BSTR")
52 Call ok(getVT(Empty) = "VT_EMPTY", "getVT(Empty) is not VT_EMPTY")
53 Call ok(getVT(null) = "VT_NULL", "getVT(null) is not VT_NULL")
54 Call ok(getVT(0) = "VT_I2", "getVT(0) is not VT_I2")
55 Call ok(getVT(1) = "VT_I2", "getVT(1) is not VT_I2")
56 Call ok(getVT(0.5) = "VT_R8", "getVT(0.5) is not VT_R8")
57 Call ok(getVT(0.0) = "VT_R8", "getVT(0.0) is not VT_R8")
58 Call ok(getVT(2147483647) = "VT_I4", "getVT(2147483647) is not VT_I4")
59 Call ok(getVT(2147483648) = "VT_R8", "getVT(2147483648) is not VT_R8")
60 Call ok(getVT(&h10&) = "VT_I2", "getVT(&h10&) is not VT_I2")
61 Call ok(getVT(&h10000&) = "VT_I4", "getVT(&h10000&) is not VT_I4")
62 Call ok(getVT(&H10000&) = "VT_I4", "getVT(&H10000&) is not VT_I4")
63 Call ok(getVT(&hffFFffFF&) = "VT_I2", "getVT(&hffFFffFF&) is not VT_I2")
64 Call ok(getVT(1 & 100000) = "VT_BSTR", "getVT(1 & 100000) is not VT_BSTR")
65 Call ok(getVT(-empty) = "VT_I2", "getVT(-empty) = " & getVT(-empty))
66 Call ok(getVT(-null) = "VT_NULL", "getVT(-null) = " & getVT(-null))
67
68 Call ok("ab" & "cd" = "abcd", """ab"" & ""cd"" <> ""abcd""")
69 Call ok("ab " & null = "ab ", """ab"" & null = " & ("ab " & null))
70 Call ok("ab " & empty = "ab ", """ab"" & empty = " & ("ab " & empty))
71 Call ok(1 & 100000 = "1100000", "1 & 100000 = " & (1 & 100000))
72
73 'if(isEnglishLocale) then
74 '    Call ok("" & true = "True", """"" & true = " & true)
75 '    Call ok(true & false = "TrueFalse", "true & false = " & (true & false))
76 'end if
77
78 Call ok(2+2 = 4, "2+2 = " & (2+2))
79 Call ok(false + 6 + true = 5, "false + 6 + true <> 5")
80 Call ok(getVT(2+null) = "VT_NULL", "getVT(2+null) = " & getVT(2+null))
81 Call ok(2+empty = 2, "2+empty = " & (2+empty))
82
83 Call ok(5-1 = 4, "5-1 = " & (5-1))
84 Call ok(3+5-true = 9, "3+5-true <> 9")
85 Call ok(getVT(2-null) = "VT_NULL", "getVT(2-null) = " & getVT(2-null))
86 Call ok(2-empty = 2, "2-empty = " & (2-empty))
87
88 reportSuccess()