GSoC 2014 proposal - Implement VBScript built-in functions

孟帅 mengshuaicalendr at gmail.com
Thu Mar 20 06:33:04 CDT 2014


Hi all!
I'm Shuai Meng, a student from software school of Beihang University,
China, GMT+08:00. I'm pursuing a master degree and now in grade one.
You can call me shuaimeng, that's my nickname used in irc. Now I'm
here to apply for GSoC to work for Wine. I'm familiar with C, and I
can code with python as well. Besides, I know a little about html and
vbscript. From May to August, I have plenty of free time.

About one year ago I started my way to linux, it's not smooth for a
person who had got used to windows then embrace linux. Soon I got a
problem: QQ(the most popular IM software in China) doesn't support
linux, but I really need it. Fortunately I knew wine through searching
google, it helped me solve this problem.Since then I have become a
wine user.

In the past three months, I had focused on dlls/vbscript/global.c,
searching MSDN for related documents[1]~[4]. Accordding those
documents, I added more tests in dlls/vbscript/tests/api.vbs, then got
some similar bugs and only reported one[5]. In order to fix them, I
read wine source code in dlls/vbscript/global.c, again and again.
Finally I finished a few draft patches[6] and I will send them to
wine-patches later.

As I have made so much effort in this module and gain a little
experience, during GSoC this part will go on to occupy most of my
attention. On the basis of difficulty to be implemented, I divide all
the functions in dlls/vbscript/global.c into four groups as following:

1: Abs ScriptEngine ScriptEngineBuildVersion ScriptEngineMajorVersion
IsArray IsDate IsNumeric IsObject Sgn TypeName VarType

These are the easiest to implement, I will take about one week to
finish the unimplemented.

2: FormatCurrency FormatDateTime FormatPercent Hour FormatNumber Join
Minute Month Oct Rnd Second Space TimeValue Year

The second group will occupy two weeks of the whole GSoC time. They
are not as easy as the first group and there are more to be
accomplished. Most of them are involved in time functions while a few
is about strings.

3: Asc Ant Cos DateAdd DateDiff DatePart DateSerial Day Exp LBound Log
Replace Sin Sqr String Tan TimeSerial UBound Weekday CBool CByte CCur
CDate CDbl CInt CLng CSng CStr InStrRev Int Fix StrComp Timer

These are more difficult. However a large part is conversion functions
and they have been implemented or improved by me. You can find the
details in attchment. Optimistically speaking, I need at least three
weeks to complete all of them. When I finish that, this bug[7] will be
fixed.

4: Array Date DateValue Escape Eval Filter GetLocale GetRef InputBox
LoadPicture Now RGB SetLocale
Split Time Unescape

Here come the most difficult ones. I am not so sure whether I can fix
or even understand them, but I will try my best. Maybe after I have
finish the above three groups, I can gain a little confidence to face
them. This group would cost me four weeks or even longer. If I have a
good luck, maybe I can fix this bug[8].

To be prudent, I'll spare at least one week to do a review on all my
codes. Write a summary as a guidence for my work to be continued after
GSoC.

Though I have a rough plan now, as a greenhand to wine, I hava too
much to learn and I badly need advice from all of you. I hope I can
make a proper schedule after communicating with my mentor.

Any comment or advice is greatly appreciated.
Thank you!


[1]http://msdn.microsoft.com/en-us/library/9e7a57cf(v=vs.84).aspx
[2]http://msdn.microsoft.com/en-us/library/t7zd6etz(v=vs.84).aspx
[3]http://msdn.microsoft.com/en-us/library/3ca8tfek(v=vs.84).aspx
[4]http://msdn.microsoft.com/en-us/library/10wcf65z(v=vs.84).aspx
[5]http://bugs.winehq.org/show_bug.cgi?id=35441
[6]In the attachment
[7]http://bugs.winehq.org/show_bug.cgi?id=34913
[8]http://bugs.winehq.org/show_bug.cgi?id=35472
-------------- next part --------------
From 38ac1226f5b8cbf4c2a445d0e9b2352105ce48d1 Mon Sep 17 00:00:00 2001
From: Shuai Meng <mengshuaicalendr at gmail.com>
Date: Sat, 15 Mar 2014 22:13:15 +0800
Subject: [PATCH 01/11] oleaut32: Fixed VarIntFromFloat.

---
 dlls/oleaut32/tests/vartype.c | 42 ++++++++++++++++++++++++++++++++++++++++++
 dlls/oleaut32/vartype.c       | 12 ++++++------
 2 files changed, 48 insertions(+), 6 deletions(-)

diff --git a/dlls/oleaut32/tests/vartype.c b/dlls/oleaut32/tests/vartype.c
index 61ad45e..ea5065f 100644
--- a/dlls/oleaut32/tests/vartype.c
+++ b/dlls/oleaut32/tests/vartype.c
@@ -739,11 +739,15 @@ static void test_VarI1FromR4(void)
 
   CHECKPTR(VarI1FromR4);
   CONVERT(VarI1FromR4, -129.0f); EXPECT_OVERFLOW;
+  CONVERT(VarI1FromR4, -128.51f); EXPECT_OVERFLOW;
+  CONVERT(VarI1FromR4, -128.5f); EXPECT(-128);
   CONVERT(VarI1FromR4, -128.0f); EXPECT(-128);
   CONVERT(VarI1FromR4, -1.0f);   EXPECT(-1);
   CONVERT(VarI1FromR4, 0.0f);    EXPECT(0);
   CONVERT(VarI1FromR4, 1.0f);    EXPECT(1);
   CONVERT(VarI1FromR4, 127.0f);  EXPECT(127);
+  CONVERT(VarI1FromR4, 127.49f);  EXPECT(127);
+  CONVERT(VarI1FromR4, 127.5f);  EXPECT_OVERFLOW;
   CONVERT(VarI1FromR4, 128.0f);  EXPECT_OVERFLOW;
 
   CONVERT(VarI1FromR4, -1.5f); EXPECT(-2);
@@ -762,11 +766,15 @@ static void test_VarI1FromR8(void)
 
   CHECKPTR(VarI1FromR8);
   CONVERT(VarI1FromR8, -129.0); EXPECT_OVERFLOW;
+  CONVERT(VarI1FromR8, -128.51); EXPECT_OVERFLOW;
+  CONVERT(VarI1FromR8, -128.5); EXPECT(-128);
   CONVERT(VarI1FromR8, -128.0); EXPECT(-128);
   CONVERT(VarI1FromR8, -1.0);   EXPECT(-1);
   CONVERT(VarI1FromR8, 0.0);    EXPECT(0);
   CONVERT(VarI1FromR8, 1.0);    EXPECT(1);
   CONVERT(VarI1FromR8, 127.0);  EXPECT(127);
+  CONVERT(VarI1FromR8, 127.49);  EXPECT(127);
+  CONVERT(VarI1FromR8, 127.5);  EXPECT_OVERFLOW;
   CONVERT(VarI1FromR8, 128.0);  EXPECT_OVERFLOW;
 
   CONVERT(VarI1FromR8, -1.5); EXPECT(-2);
@@ -983,9 +991,13 @@ static void test_VarUI1FromR4(void)
 
   CHECKPTR(VarUI1FromR4);
   CONVERT(VarUI1FromR4, -1.0f);  EXPECT_OVERFLOW;
+  CONVERT(VarUI1FromR4, -0.51f);  EXPECT_OVERFLOW;
+  CONVERT(VarUI1FromR4, -0.5f);   EXPECT(0);
   CONVERT(VarUI1FromR4, 0.0f);   EXPECT(0);
   CONVERT(VarUI1FromR4, 1.0f);   EXPECT(1);
   CONVERT(VarUI1FromR4, 255.0f); EXPECT(255);
+  CONVERT(VarUI1FromR4, 255.49f); EXPECT(255);
+  CONVERT(VarUI1FromR4, 255.5f); EXPECT_OVERFLOW;
   CONVERT(VarUI1FromR4, 256.0f); EXPECT_OVERFLOW;
 
   /* Rounding */
@@ -1005,9 +1017,13 @@ static void test_VarUI1FromR8(void)
 
   CHECKPTR(VarUI1FromR8);
   CONVERT(VarUI1FromR8, -1.0);  EXPECT_OVERFLOW;
+  CONVERT(VarUI1FromR8, -0.51);  EXPECT_OVERFLOW;
+  CONVERT(VarUI1FromR8, -0.5);   EXPECT(0);
   CONVERT(VarUI1FromR8, 0.0);   EXPECT(0);
   CONVERT(VarUI1FromR8, 1.0);   EXPECT(1);
   CONVERT(VarUI1FromR8, 255.0); EXPECT(255);
+  CONVERT(VarUI1FromR8, 255.49); EXPECT(255);
+  CONVERT(VarUI1FromR8, 255.5); EXPECT_OVERFLOW;
   CONVERT(VarUI1FromR8, 256.0); EXPECT_OVERFLOW;
 
   /* Rounding */
@@ -1281,11 +1297,15 @@ static void test_VarI2FromR4(void)
 
   CHECKPTR(VarI2FromR4);
   CONVERT(VarI2FromR4, -32769.0f); EXPECT_OVERFLOW;
+  CONVERT(VarI2FromR4, -32768.51f); EXPECT_OVERFLOW;
+  CONVERT(VarI2FromR4, -32768.5f); EXPECT(-32768);
   CONVERT(VarI2FromR4, -32768.0f); EXPECT(-32768);
   CONVERT(VarI2FromR4, -1.0f);     EXPECT(-1);
   CONVERT(VarI2FromR4, 0.0f);      EXPECT(0);
   CONVERT(VarI2FromR4, 1.0f);      EXPECT(1);
   CONVERT(VarI2FromR4, 32767.0f);  EXPECT(32767);
+  CONVERT(VarI2FromR4, 32767.49f);  EXPECT(32767);
+  CONVERT(VarI2FromR4, 32767.5f);  EXPECT_OVERFLOW;
   CONVERT(VarI2FromR4, 32768.0f);  EXPECT_OVERFLOW;
 
   /* Rounding */
@@ -1305,11 +1325,15 @@ static void test_VarI2FromR8(void)
 
   CHECKPTR(VarI2FromR8);
   CONVERT(VarI2FromR8, -32769.0); EXPECT_OVERFLOW;
+  CONVERT(VarI2FromR8, -32768.51); EXPECT_OVERFLOW;
+  CONVERT(VarI2FromR8, -32768.5); EXPECT(-32768);
   CONVERT(VarI2FromR8, -32768.0); EXPECT(-32768);
   CONVERT(VarI2FromR8, -1.0);     EXPECT(-1);
   CONVERT(VarI2FromR8, 0.0);      EXPECT(0);
   CONVERT(VarI2FromR8, 1.0);      EXPECT(1);
   CONVERT(VarI2FromR8, 32767.0);  EXPECT(32767);
+  CONVERT(VarI2FromR8, 32767.49);  EXPECT(32767);
+  CONVERT(VarI2FromR8, 32767.5);  EXPECT_OVERFLOW;
   CONVERT(VarI2FromR8, 32768.0);  EXPECT_OVERFLOW;
 
   /* Rounding */
@@ -1529,9 +1553,13 @@ static void test_VarUI2FromR4(void)
 
   CHECKPTR(VarUI2FromR4);
   CONVERT(VarUI2FromR4, -1.0f);    EXPECT_OVERFLOW;
+  CONVERT(VarUI2FromR4, -0.51f);    EXPECT_OVERFLOW;
+  CONVERT(VarUI2FromR4, -0.5f);     EXPECT(0);
   CONVERT(VarUI2FromR4, 0.0f);     EXPECT(0);
   CONVERT(VarUI2FromR4, 1.0f);     EXPECT(1);
   CONVERT(VarUI2FromR4, 65535.0f); EXPECT(65535);
+  CONVERT(VarUI2FromR4, 65535.49f); EXPECT(65535);
+  CONVERT(VarUI2FromR4, 65535.5f); EXPECT_OVERFLOW;
   CONVERT(VarUI2FromR4, 65536.0f); EXPECT_OVERFLOW;
 
   /* Rounding */
@@ -1551,9 +1579,13 @@ static void test_VarUI2FromR8(void)
 
   CHECKPTR(VarUI2FromR8);
   CONVERT(VarUI2FromR8, -1.0);    EXPECT_OVERFLOW;
+  CONVERT(VarUI2FromR8, -0.51);    EXPECT_OVERFLOW;
+  CONVERT(VarUI2FromR8, -0.5);     EXPECT(0);
   CONVERT(VarUI2FromR8, 0.0);     EXPECT(0);
   CONVERT(VarUI2FromR8, 1.0);     EXPECT(1);
   CONVERT(VarUI2FromR8, 65535.0); EXPECT(65535);
+  CONVERT(VarUI2FromR8, 65535.49); EXPECT(65535);
+  CONVERT(VarUI2FromR8, 65535.5); EXPECT_OVERFLOW;
   CONVERT(VarUI2FromR8, 65536.0); EXPECT_OVERFLOW;
 
   /* Rounding */
@@ -1792,11 +1824,15 @@ static void test_VarI4FromR8(void)
 
   CHECKPTR(VarI4FromR8);
   CONVERT(VarI4FromR8, -2147483649.0); EXPECT_OVERFLOW;
+  CONVERT(VarI4FromR8, -2147483648.51); EXPECT_OVERFLOW;
+  CONVERT(VarI4FromR8, -2147483648.5); EXPECT(-2147483647 - 1);
   CONVERT(VarI4FromR8, -2147483648.0); EXPECT(-2147483647 - 1);
   CONVERT(VarI4FromR8, -1.0);          EXPECT(-1);
   CONVERT(VarI4FromR8, 0.0);           EXPECT(0);
   CONVERT(VarI4FromR8, 1.0);           EXPECT(1);
   CONVERT(VarI4FromR8, 2147483647.0);  EXPECT(2147483647);
+  CONVERT(VarI4FromR8, 2147483647.49);  EXPECT(2147483647);
+  CONVERT(VarI4FromR8, 2147483647.5);  EXPECT_OVERFLOW;
   CONVERT(VarI4FromR8, 2147483648.0);  EXPECT_OVERFLOW;
 
   CONVERT(VarI4FromR8, -1.5); EXPECT(-2);
@@ -2017,6 +2053,8 @@ static void test_VarUI4FromR4(void)
   CHECKPTR(VarUI4FromR4);
   /* We can't test max values as they are not exactly representable in a float */
   CONVERT(VarUI4FromR4, -1.0f); EXPECT_OVERFLOW;
+  CONVERT(VarUI4FromR4, -0.51f); EXPECT_OVERFLOW;
+  CONVERT(VarUI4FromR4, -0.5f);  EXPECT(0);
   CONVERT(VarUI4FromR4, 0.0f);  EXPECT(0);
   CONVERT(VarUI4FromR4, 1.0f);  EXPECT(1);
 
@@ -2037,9 +2075,13 @@ static void test_VarUI4FromR8(void)
 
   CHECKPTR(VarUI4FromR8);
   CONVERT(VarUI4FromR8, -1.0);         EXPECT_OVERFLOW;
+  CONVERT(VarUI4FromR4, -0.51f);       EXPECT_OVERFLOW;
+  CONVERT(VarUI4FromR4, -0.5f);        EXPECT(0);
   CONVERT(VarUI4FromR8, 0.0);          EXPECT(0);
   CONVERT(VarUI4FromR8, 1.0);          EXPECT(1);
   CONVERT(VarUI4FromR8, 4294967295.0); EXPECT(4294967295ul);
+  CONVERT(VarUI4FromR8, 4294967295.49); EXPECT(4294967295ul);
+  CONVERT(VarUI4FromR8, 4294967295.5); EXPECT_OVERFLOW;
   CONVERT(VarUI4FromR8, 4294967296.0); EXPECT_OVERFLOW;
 
   CONVERT(VarUI4FromR8, -1.5); EXPECT_OVERFLOW;
diff --git a/dlls/oleaut32/vartype.c b/dlls/oleaut32/vartype.c
index 43902c5..dbc4892 100644
--- a/dlls/oleaut32/vartype.c
+++ b/dlls/oleaut32/vartype.c
@@ -362,7 +362,7 @@ HRESULT WINAPI VarI1FromR4(FLOAT fltIn, signed char* pcOut)
  */
 HRESULT WINAPI VarI1FromR8(double dblIn, signed char* pcOut)
 {
-  if (dblIn < (double)I1_MIN || dblIn > (double)I1_MAX)
+  if (dblIn < (double)(I1_MIN - 0.5) || dblIn >= (double)(I1_MAX + 0.5))
     return DISP_E_OVERFLOW;
   VARIANT_DutchRound(CHAR, dblIn, *pcOut);
   return S_OK;
@@ -652,7 +652,7 @@ HRESULT WINAPI VarUI1FromR4(FLOAT fltIn, BYTE* pbOut)
  */
 HRESULT WINAPI VarUI1FromR8(double dblIn, BYTE* pbOut)
 {
-  if (dblIn < -0.5 || dblIn > (double)UI1_MAX)
+  if (dblIn < -0.5 || dblIn >= (double)(UI1_MAX + 0.5))
     return DISP_E_OVERFLOW;
   VARIANT_DutchRound(BYTE, dblIn, *pbOut);
   return S_OK;
@@ -958,7 +958,7 @@ HRESULT WINAPI VarI2FromR4(FLOAT fltIn, SHORT* psOut)
  */
 HRESULT WINAPI VarI2FromR8(double dblIn, SHORT* psOut)
 {
-  if (dblIn < (double)I2_MIN || dblIn > (double)I2_MAX)
+  if (dblIn < (double)(I2_MIN - 0.5) || dblIn >= (double)(I2_MAX + 0.5))
     return DISP_E_OVERFLOW;
   VARIANT_DutchRound(SHORT, dblIn, *psOut);
   return S_OK;
@@ -1270,7 +1270,7 @@ HRESULT WINAPI VarUI2FromR4(FLOAT fltIn, USHORT* pusOut)
  */
 HRESULT WINAPI VarUI2FromR8(double dblIn, USHORT* pusOut)
 {
-  if (dblIn < -0.5 || dblIn > (double)UI2_MAX)
+  if (dblIn < -0.5 || dblIn >= (double)(UI2_MAX + 0.5))
     return DISP_E_OVERFLOW;
   VARIANT_DutchRound(USHORT, dblIn, *pusOut);
   return S_OK;
@@ -1550,7 +1550,7 @@ HRESULT WINAPI VarI4FromR4(FLOAT fltIn, LONG *piOut)
  */
 HRESULT WINAPI VarI4FromR8(double dblIn, LONG *piOut)
 {
-  if (dblIn < (double)I4_MIN || dblIn > (double)I4_MAX)
+  if (dblIn < (double)(I4_MIN - 0.5) || dblIn >= (double)(I4_MAX + 0.5))
     return DISP_E_OVERFLOW;
   VARIANT_DutchRound(LONG, dblIn, *piOut);
   return S_OK;
@@ -1859,7 +1859,7 @@ HRESULT WINAPI VarUI4FromR4(FLOAT fltIn, ULONG *pulOut)
  */
 HRESULT WINAPI VarUI4FromR8(double dblIn, ULONG *pulOut)
 {
-  if (dblIn < -0.5 || dblIn > (double)UI4_MAX)
+  if (dblIn < -0.5 || dblIn >= (double)(UI4_MAX + 0.5))
     return DISP_E_OVERFLOW;
   VARIANT_DutchRound(ULONG, dblIn, *pulOut);
   return S_OK;
-- 
1.8.1.2

-------------- next part --------------
From 1e40d7125025d8174a536e586f6890d11a2e97bd Mon Sep 17 00:00:00 2001
From: Shuai Meng <mengshuaicalendr at gmail.com>
Date: Sun, 16 Mar 2014 00:11:49 +0800
Subject: [PATCH 02/11] vbscript: Fixed CBool.

---
 dlls/vbscript/global.c | 33 ++-------------------------------
 1 file changed, 2 insertions(+), 31 deletions(-)

diff --git a/dlls/vbscript/global.c b/dlls/vbscript/global.c
index 9d8f021..3315185 100644
--- a/dlls/vbscript/global.c
+++ b/dlls/vbscript/global.c
@@ -114,16 +114,6 @@ static HRESULT return_int(VARIANT *res, int val)
     return S_OK;
 }
 
-static HRESULT return_bool(VARIANT *res, int val)
-{
-    if(res) {
-        V_VT(res) = VT_BOOL;
-        V_BOOL(res) = val != 0 ? VARIANT_TRUE : VARIANT_FALSE;
-    }
-
-    return S_OK;
-}
-
 static inline HRESULT return_double(VARIANT *res, double val)
 {
     if(res) {
@@ -413,30 +403,11 @@ static HRESULT Global_CLng(vbdisp_t *This, VARIANT *arg, unsigned args_cnt, VARI
 
 static HRESULT Global_CBool(vbdisp_t *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
 {
-    int val;
     TRACE("%s\n", debugstr_variant(arg));
-
     assert(args_cnt == 1);
 
-    switch(V_VT(arg)) {
-    case VT_I2:
-        val = V_I2(arg);
-        break;
-    case VT_I4:
-        val = V_I4(arg);
-        break;
-    case VT_R4:
-	val = V_R4(arg) > 0.0 || V_R4(arg) < 0.0;
-        break;
-    case VT_R8:
-        val = V_R8(arg) > 0.0 || V_R8(arg) < 0.0;
-        break;
-    default:
-        ERR("Not a numeric value: %s\n", debugstr_variant(arg));
-        return E_FAIL;
-    }
-
-    return return_bool(res, val);
+    V_VT(res) = VT_EMPTY;
+    return VariantChangeType(res, arg, VARIANT_LOCALBOOL, VT_BOOL);
 }
 
 static HRESULT Global_CByte(vbdisp_t *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
-- 
1.8.1.2

-------------- next part --------------
From 3c2ef9fb632cf1503160dece8175a85446b85c58 Mon Sep 17 00:00:00 2001
From: Shuai Meng <mengshuaicalendr at gmail.com>
Date: Sun, 16 Mar 2014 00:10:31 +0800
Subject: [PATCH 03/11] vbscript: Implemented CByte.

---
 dlls/vbscript/global.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/dlls/vbscript/global.c b/dlls/vbscript/global.c
index 3315185..1ddc76c 100644
--- a/dlls/vbscript/global.c
+++ b/dlls/vbscript/global.c
@@ -412,8 +412,11 @@ static HRESULT Global_CBool(vbdisp_t *This, VARIANT *arg, unsigned args_cnt, VAR
 
 static HRESULT Global_CByte(vbdisp_t *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
 {
-    FIXME("\n");
-    return E_NOTIMPL;
+    TRACE("%s\n", debugstr_variant(arg));
+    assert(args_cnt == 1);
+
+    V_VT(res) = VT_EMPTY;
+    return VariantChangeType(res, arg, VARIANT_LOCALBOOL, VT_UI1);
 }
 
 static HRESULT Global_CDate(vbdisp_t *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
-- 
1.8.1.2

-------------- next part --------------
From 6c31674545b1aa7dfa7729d0427b3f1d4ba48226 Mon Sep 17 00:00:00 2001
From: Shuai Meng <mengshuaicalendr at gmail.com>
Date: Sun, 16 Mar 2014 00:03:30 +0800
Subject: [PATCH 04/11] vbscript: Implemented CCur.

---
 dlls/vbscript/global.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/dlls/vbscript/global.c b/dlls/vbscript/global.c
index 1ddc76c..071f052 100644
--- a/dlls/vbscript/global.c
+++ b/dlls/vbscript/global.c
@@ -375,8 +375,11 @@ static HRESULT show_msgbox(script_ctx_t *ctx, BSTR prompt, VARIANT *res)
 
 static HRESULT Global_CCur(vbdisp_t *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
 {
-    FIXME("\n");
-    return E_NOTIMPL;
+    TRACE("%s\n", debugstr_variant(arg));
+    assert(args_cnt == 1);
+
+    V_VT(res) = VT_EMPTY;
+    return VariantChangeType(res, arg, VARIANT_LOCALBOOL, VT_CY);
 }
 
 static HRESULT Global_CInt(vbdisp_t *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
-- 
1.8.1.2

-------------- next part --------------
From 4156816857fc80db6b6a72b014f43e08c9e25d25 Mon Sep 17 00:00:00 2001
From: Shuai Meng <mengshuaicalendr at gmail.com>
Date: Sun, 16 Mar 2014 00:12:49 +0800
Subject: [PATCH 05/11] vbscript: Implemented CDate.

---
 dlls/vbscript/global.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/dlls/vbscript/global.c b/dlls/vbscript/global.c
index 071f052..d422ef9 100644
--- a/dlls/vbscript/global.c
+++ b/dlls/vbscript/global.c
@@ -424,8 +424,11 @@ static HRESULT Global_CByte(vbdisp_t *This, VARIANT *arg, unsigned args_cnt, VAR
 
 static HRESULT Global_CDate(vbdisp_t *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
 {
-    FIXME("\n");
-    return E_NOTIMPL;
+    TRACE("%s\n", debugstr_variant(arg));
+    assert(args_cnt == 1);
+
+    V_VT(res) = VT_EMPTY;
+    return VariantChangeType(res, arg, VARIANT_LOCALBOOL, VT_DATE);
 }
 
 static HRESULT Global_CDbl(vbdisp_t *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
-- 
1.8.1.2

-------------- next part --------------
From 187f0d12ab7576d1ac65a55300cc0493b2b02990 Mon Sep 17 00:00:00 2001
From: Shuai Meng <mengshuaicalendr at gmail.com>
Date: Sun, 16 Mar 2014 00:13:36 +0800
Subject: [PATCH 06/11] vbscript: Implemented CDbl.

---
 dlls/vbscript/global.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/dlls/vbscript/global.c b/dlls/vbscript/global.c
index d422ef9..b968f14 100644
--- a/dlls/vbscript/global.c
+++ b/dlls/vbscript/global.c
@@ -433,8 +433,11 @@ static HRESULT Global_CDate(vbdisp_t *This, VARIANT *arg, unsigned args_cnt, VAR
 
 static HRESULT Global_CDbl(vbdisp_t *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
 {
-    FIXME("\n");
-    return E_NOTIMPL;
+    TRACE("%s\n", debugstr_variant(arg));
+    assert(args_cnt == 1);
+
+    V_VT(res) = VT_EMPTY;
+    return VariantChangeType(res, arg, VARIANT_LOCALBOOL, VT_R8);
 }
 
 static HRESULT Global_CSng(vbdisp_t *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
-- 
1.8.1.2

-------------- next part --------------
From fb39246de3efff701a43a29beb1c0a050a0869f8 Mon Sep 17 00:00:00 2001
From: Shuai Meng <mengshuaicalendr at gmail.com>
Date: Sun, 16 Mar 2014 11:26:02 +0800
Subject: [PATCH 07/11] vbscript: Fixed CInt.

---
 dlls/vbscript/global.c | 11 ++---------
 1 file changed, 2 insertions(+), 9 deletions(-)

diff --git a/dlls/vbscript/global.c b/dlls/vbscript/global.c
index b968f14..06810c4 100644
--- a/dlls/vbscript/global.c
+++ b/dlls/vbscript/global.c
@@ -384,18 +384,11 @@ static HRESULT Global_CCur(vbdisp_t *This, VARIANT *arg, unsigned args_cnt, VARI
 
 static HRESULT Global_CInt(vbdisp_t *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
 {
-    int val;
-    HRESULT hres;
-
     TRACE("%s\n", debugstr_variant(arg));
-
     assert(args_cnt == 1);
 
-    hres = to_int(arg, &val);
-    if(FAILED(hres))
-        return hres;
-
-    return return_int(res, val);
+    V_VT(res) = VT_EMPTY;
+    return VariantChangeType(res, arg, VARIANT_LOCALBOOL, VT_I2);
 }
 
 static HRESULT Global_CLng(vbdisp_t *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
-- 
1.8.1.2

-------------- next part --------------
From f20f2237c0eb2c64bd282c02cd8858a4826ea4f4 Mon Sep 17 00:00:00 2001
From: Shuai Meng <mengshuaicalendr at gmail.com>
Date: Sun, 16 Mar 2014 00:05:52 +0800
Subject: [PATCH 08/11] vbscript: Implemented CLng.

---
 dlls/vbscript/global.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/dlls/vbscript/global.c b/dlls/vbscript/global.c
index 06810c4..98c783c 100644
--- a/dlls/vbscript/global.c
+++ b/dlls/vbscript/global.c
@@ -393,8 +393,12 @@ static HRESULT Global_CInt(vbdisp_t *This, VARIANT *arg, unsigned args_cnt, VARI
 
 static HRESULT Global_CLng(vbdisp_t *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
 {
-    FIXME("\n");
-    return E_NOTIMPL;
+    TRACE("%s\n", debugstr_variant(arg));
+    assert(args_cnt == 1);
+
+    V_VT(res) = VT_EMPTY;
+    return VariantChangeType(res, arg, VARIANT_LOCALBOOL, VT_I4);
+
 }
 
 static HRESULT Global_CBool(vbdisp_t *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
-- 
1.8.1.2

-------------- next part --------------
From 8d6907e85853e14eda1e727df5e9f6bce1c8e68c Mon Sep 17 00:00:00 2001
From: Shuai Meng <mengshuaicalendr at gmail.com>
Date: Sun, 16 Mar 2014 00:14:23 +0800
Subject: [PATCH 09/11] vbscript: Implemented CSng.

---
 dlls/vbscript/global.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/dlls/vbscript/global.c b/dlls/vbscript/global.c
index 98c783c..8415450 100644
--- a/dlls/vbscript/global.c
+++ b/dlls/vbscript/global.c
@@ -439,8 +439,11 @@ static HRESULT Global_CDbl(vbdisp_t *This, VARIANT *arg, unsigned args_cnt, VARI
 
 static HRESULT Global_CSng(vbdisp_t *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
 {
-    FIXME("\n");
-    return E_NOTIMPL;
+    TRACE("%s\n", debugstr_variant(arg));
+    assert(args_cnt == 1);
+
+    V_VT(res) = VT_EMPTY;
+    return VariantChangeType(res, arg, VARIANT_LOCALBOOL, VT_R4);
 }
 
 static HRESULT Global_CStr(vbdisp_t *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
-- 
1.8.1.2

-------------- next part --------------
From ad8115fd2e2aee3ee1037862b5298220cbe9b90d Mon Sep 17 00:00:00 2001
From: Shuai Meng <mengshuaicalendr at gmail.com>
Date: Sun, 16 Mar 2014 11:25:27 +0800
Subject: [PATCH 10/11] vbscript: Fixed CStr.

---
 dlls/vbscript/global.c | 11 +++--------
 1 file changed, 3 insertions(+), 8 deletions(-)

diff --git a/dlls/vbscript/global.c b/dlls/vbscript/global.c
index 8415450..dd65869 100644
--- a/dlls/vbscript/global.c
+++ b/dlls/vbscript/global.c
@@ -448,16 +448,11 @@ static HRESULT Global_CSng(vbdisp_t *This, VARIANT *arg, unsigned args_cnt, VARI
 
 static HRESULT Global_CStr(vbdisp_t *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
 {
-    BSTR str;
-    HRESULT hres;
-
     TRACE("%s\n", debugstr_variant(arg));
+    assert(args_cnt == 1);
 
-    hres = to_string(arg, &str);
-    if(FAILED(hres))
-        return hres;
-
-    return return_bstr(res, str);
+    V_VT(res) = VT_EMPTY;
+    return VariantChangeType(res, arg, VARIANT_LOCALBOOL, VT_BSTR);
 }
 
 static inline WCHAR hex_char(unsigned n)
-- 
1.8.1.2

-------------- next part --------------
From b28bf173585aae8e6f8cfd128e96d513d5435780 Mon Sep 17 00:00:00 2001
From: Shuai Meng <mengshuaicalendr at gmail.com>
Date: Sat, 15 Mar 2014 22:15:24 +0800
Subject: [PATCH 11/11] vbscript/tests: Added tests for convert functions.

---
 dlls/vbscript/tests/api.vbs | 190 ++++++++++++++++++++++++++++++++++++++++++++
 dlls/vbscript/tests/run.c   |   6 ++
 2 files changed, 196 insertions(+)

diff --git a/dlls/vbscript/tests/api.vbs b/dlls/vbscript/tests/api.vbs
index 7c3927e..e50750d 100644
--- a/dlls/vbscript/tests/api.vbs
+++ b/dlls/vbscript/tests/api.vbs
@@ -463,4 +463,194 @@ Call ok(getVT(CBool(0)) = "VT_BOOL", "getVT(CBool(0)) = " & getVT(CBool(0)))
 Call ok(CBool(-5) = true, "CBool(-5) = " & CBool(-5))
 Call ok(getVT(CBool(-5)) = "VT_BOOL", "getVT(CBool(-5)) = " & getVT(CBool(-5)))
 
+Call ok(CBool(Empty) = False, "CBool(Empty) = " & CBool(Empty))
+Call ok(getVT(CBool(Empty)) = "VT_BOOL", "getVT(CBool(Empty)) = " & getVT(CBool(Empty)))
+Call ok(CBool(1) = True, "CBool(1) = " & CBool(1))
+Call ok(getVT(CBool(1)) = "VT_BOOL", "getVT(CBool(1)) = " & getVT(CBool(1)))
+Call ok(CBool(CLng(0)) = False, "CBool(CLng(0)) = " & CBool(CLng(0)))
+Call ok(getVT(CBool(CLng(0))) = "VT_BOOL", "getVT(CBool(CLng(0))) = " & getVT(CBool(CLng(0))))
+Call ok(CBool(CSng(0.5)) = True, "CBool(CSng(0.5)) = " & CBool(CSng(0.5)))
+Call ok(getVT(CBool(CSng(0.5))) = "VT_BOOL", "getVT(CBool(CSng(0.5))) = " & getVT(CBool(CSng(0.5))))
+Call ok(CBool(-0.56) = True, "CBool(-0.56) = " & CBool(-0.56))
+Call ok(getVT(CBool(-0.56)) = "VT_BOOL", "getVT(CBool(-0.56)) = " & getVT(CBool(-0.56)))
+Call ok(CBool(CCur(8.55)) = True, "CBool(CCur(8.55)) = " & CBool(CCur(8.55)))
+Call ok(getVT(CBool(CCur(8.55))) = "VT_BOOL", "getVT(CBool(CCur(8.55))) = " & getVT(CBool(CCur(8.55))))
+Call ok(CBool(CDate(0)) = False, "CBool(CDate(0)) = " & CBool(CDate(0)))
+Call ok(getVT(CBool(CDate(0))) = "VT_BOOL", "getVT(CBool(CDate(0))) = " & getVT(CBool(CDate(0))))
+Call ok(CBool(CDate(3.33)) = True, "CBool(CDate(3.33)) = " & CBool(CDate(3.33)))
+Call ok(getVT(CBool(CDate(3.33))) = "VT_BOOL", "getVT(CBool(CDate(3.33))) = " & getVT(CBool(CDate(3.33))))
+Call ok(CBool("6666.78") = True, "CBool(""6666.78"") = " & CBool("6666.78"))
+Call ok(getVT(CBool("6666.78")) = "VT_BOOL", "getVT(CBool(""6666.78"")) = " & getVT(CBool("6666.78")))
+Call ok(CBool(CByte(-0.1)) = False, "CBool(CByte(-0.1)) = " & CBool(CByte(-0.1)))
+Call ok(getVT(CBool(CByte(-0.1))) = "VT_BOOL", "getVT(CBool(CByte(-0.1))) = " & getVT(CBool(CByte(-0.1))))
+
+Call ok(CByte(Empty) = 0, "CByte(Empty) = " & CByte(Empty))
+Call ok(getVT(CByte(Empty)) = "VT_UI1", "getVT(CByte(Empty)) = " & getVT(CByte(Empty)))
+Call ok(CByte(255) = 255, "CByte(255) = " & CByte(255))
+Call ok(getVT(CByte(255)) = "VT_UI1", "getVT(CByte(255)) = " & getVT(CByte(255)))
+Call ok(CByte(CLng(0)) = 0, "CByte(CLng(0)) = " & CByte(CLng(0)))
+Call ok(getVT(CByte(CLng(0))) = "VT_UI1", "getVT(CByte(CLng(0))) = " & getVT(CByte(CLng(0))))
+Call ok(CByte(CSng(-0.5)) = 0, "CByte(CSng(-0.5)) = " & CByte(CSng(-0.5)))
+Call ok(getVT(CByte(CSng(-0.5))) = "VT_UI1", "getVT(CByte(CSng(-0.5))) = " & getVT(CByte(CSng(-0.5))))
+Call ok(CByte(255.49) = 255, "CByte(255.49) = " & CByte(255.49))
+Call ok(getVT(CByte(255.49)) = "VT_UI1", "getVT(CByte(255.49)) = " & getVT(CByte(255.49)))
+Call ok(CByte(CCur(8.55)) = 9, "CByte(CCur(8.55)) = " & CByte(CCur(8.55)))
+Call ok(getVT(CByte(CCur(8.55))) = "VT_UI1", "getVT(CByte(CCur(8.55))) = " & getVT(CByte(CCur(8.55))))
+Call ok(CByte(CDate(0)) = 0, "CByte(CDate(0)) = " & CByte(CDate(0)))
+Call ok(getVT(CByte(CDate(0))) = "VT_UI1", "getVT(CByte(CDate(0))) = " & getVT(CByte(CDate(0))))
+Call ok(CByte(CDate(3.33)) = 3, "CByte(CDate(3.33)) = " & CByte(CDate(3.33)))
+Call ok(getVT(CByte(CDate(3.33))) = "VT_UI1", "getVT(CByte(CDate(3.33))) = " & getVT(CByte(CDate(3.33))))
+Call ok(CByte("6.78") = 7, "CByte(""6.78"") = " & CByte("6.78"))
+Call ok(getVT(CByte("6.78")) = "VT_UI1", "getVT(CByte(""6.78"")) = " & getVT(CByte("6.78")))
+Call ok(CByte(True) = 255, "CByte(True) = " & CByte(True))
+Call ok(getVT(CByte(True)) = "VT_UI1", "getVT(CByte(True)) = " & getVT(CByte(True)))
+Call ok(CByte(False) = 0, "CByte(False) = " & CByte(False))
+Call ok(getVT(CByte(False)) = "VT_UI1", "getVT(CByte(False)) = " & getVT(CByte(False)))
+
+Call ok(CCur(Empty) = 0, "CCur(Empty) = " & CCur(Empty))
+Call ok(getVT(CCur(Empty)) = "VT_CY", "getVT(CCur(Empty)) = " & getVT(CCur(Empty)))
+Call ok(CCur(0) = 0, "CCur(CCur(0)) = " & CCur(0))
+Call ok(getVT(CCur(0)) = "VT_CY", "getVT(CCur(CCur(0))) = " & getVT(CCur(0)))
+Call ok(CCur(CLng(0)) = 0, "CCur(CLng(0)) = " & CCur(CLng(0)))
+Call ok(getVT(CCur(CLng(0))) = "VT_CY", "getVT(CCur(CLng(0))) = " & getVT(CCur(CLng(0))))
+Call ok(CCur(CSng(4.5)) = 4.5, "CCur(CSng(4.5)) = " & CCur(CSng(4.5)))
+Call ok(getVT(CCur(CSng(4.5))) = "VT_CY", "getVT(CCur(CSng(4.5))) = " & getVT(CCur(CSng(4.5))))
+Call ok(CCur(-0.56) = -0.56, "CCur(-0.56) = " & CCur(-0.56))
+Call ok(getVT(CCur(-0.56)) = "VT_CY", "getVT(CCur(-0.56)) = " & getVT(CCur(-0.56)))
+Call ok(CCur(CDate(0)) = 0, "CCur(CDate(0)) = " & CCur(CDate(0)))
+Call ok(getVT(CCur(CDate(0))) = "VT_CY", "getVT(CCur(CDate(0))) = " & getVT(CCur(CDate(0))))
+Call ok(CCur("6.78") = 6.78, "CCur(""6.78"") = " & CCur("6.78"))
+Call ok(getVT(CCur("6.78")) = "VT_CY", "getVT(CCur(""6.78"")) = " & getVT(CCur("6.78")))
+Call ok(CCur(True) = -1, "CCur(True) = " & CCur(True))
+Call ok(getVT(CCur(True)) = "VT_CY", "getVT(CCur(True)) = " & getVT(CCur(True)))
+Call ok(CCur(False) = 0, "CCur(False) = " & CCur(False))
+Call ok(getVT(CCur(False)) = "VT_CY", "getVT(CCur(False)) = " & getVT(CCur(False)))
+Call ok(CCur(CByte(5.49)) = 5, "CCur(CByte(5.49)) = " & CCur(CByte(5.49)))
+Call ok(getVT(CCur(CByte(5.49))) = "VT_CY", "getVT(CCur(CByte(5.49))) = " & getVT(CCur(CByte(5.49))))
+
+Call ok(CDbl(Empty) = 0, "CDbl(Empty) = " & CDbl(Empty))
+Call ok(getVT(CDbl(Empty)) = "VT_R8", "getVT(CDbl(Empty)) = " & getVT(CDbl(Empty)))
+Call ok(CDbl(0) = 0, "CDbl(0) = " & CDbl(0))
+Call ok(getVT(CDbl(0)) = "VT_R8", "getVT(CDbl(0)) = " & getVT(CDbl(0)))
+Call ok(CDbl(CLng(2147483647)) = 2147483647, "CDbl(CLng(2147483647)) = " & CDbl(CLng(2147483647)))
+Call ok(getVT(CDbl(CLng(2147483647))) = "VT_R8", "getVT(CDbl(CLng(2147483647))) = " & getVT(CDbl(CLng(2147483647))))
+Call ok(CDbl(CSng(32767)) = 32767, "CDbl(CSng(32767)) = " & CDbl(CSng(32767)))
+Call ok(getVT(CDbl(CSng(32767))) = "VT_R8", "getVT(CDbl(CSng(32767))) = " & getVT(CDbl(CSng(32767))))
+Call ok(CDbl(-2147483647.5) = -2147483647.5, "CDbl(-2147483647.5) = " & CDbl(-2147483647.5))
+Call ok(getVT(CDbl(-2147483647.5)) = "VT_R8", "getVT(CDbl(-2147483647.5)) = " & getVT(CDbl(-2147483647.5)))
+Call ok(CDbl(CCur(7.5)) = 7.5, "CDbl(CCur(7.5)) = " & CDbl(CCur(7.5)))
+Call ok(getVT(CDbl(CCur(7.5))) = "VT_R8", "getVT(CDbl(CCur(7.5))) = " & getVT(CDbl(CCur(7.5))))
+Call ok(CDbl(CDate(0)) = 0, "CDbl(CDate(0)) = " & CDbl(CDate(0)))
+Call ok(getVT(CDbl(CDate(0))) = "VT_R8", "getVT(CDbl(CDate(0))) = " & getVT(CDbl(CDate(0))))
+Call ok(CDbl(CDate(6.49)) = 6.49, "CDbl(CDate(6.49)) = " & CDbl(CDate(6.49)))
+Call ok(getVT(CDbl(CDate(6.49))) = "VT_R8", "getVT(CDbl(CDate(6.49))) = " & getVT(CDbl(CDate(6.49))))
+Call ok(CDbl("6.5") = 6.5, "CDbl(""6.5"") = " & CDbl("6.5"))
+Call ok(getVT(CDbl("6.5")) = "VT_R8", "getVT(CDbl(""6.5"")) = " & getVT(CDbl("6.5")))
+Call ok(CDbl(True) = -1, "CDbl(True) = " & CDbl(True))
+Call ok(getVT(CDbl(True)) = "VT_R8", "getVT(CDbl(True)) = " & getVT(CDbl(True)))
+Call ok(CDbl(False) = 0, "CDbl(False) = " & CDbl(False))
+Call ok(getVT(CDbl(False)) = "VT_R8", "getVT(CDbl(False)) = " & getVT(CDbl(False)))
+Call ok(CDbl(CByte(7)) = 7, "CDbl(CByte(7)) = " & CDbl(CByte(7)))
+Call ok(getVT(CDbl(CByte(7))) = "VT_R8", "getVT(CDbl(CByte(7))) = " & getVT(CDbl(CByte(7))))
+
+Call ok(CInt(Empty) = 0, "CInt(Empty) = " & CInt(Empty))
+Call ok(getVT(CInt(Empty)) = "VT_I2", "getVT(CInt(Empty)) = " & getVT(CInt(Empty)))
+Call ok(CInt(CLng(32767)) = 32767, "CInt(CLng(32767)) = " & CInt(CLng(32767)))
+Call ok(getVT(CInt(CLng(32767))) = "VT_I2", "getVT(CInt(CLng(32767))) = " & getVT(CInt(CLng(32767))))
+Call ok(CInt(CSng(32767.49)) = 32767, "CInt(CSng(32767.49)) = " & CInt(CSng(32767.49)))
+Call ok(getVT(CInt(CSng(32767.49))) = "VT_I2", "getVT(CInt(CSng(32767.49))) = " & getVT(CInt(CSng(32767.49))))
+Call ok(CInt(-32768.5) = -32768, "CInt(-32768.5) = " & CInt(-32768.5))
+Call ok(getVT(CInt(-32768.5)) = "VT_I2", "getVT(CInt(-32768.5)) = " & getVT(CInt(-32768.5)))
+Call ok(CInt(CCur(7.5)) = 8, "CInt(CCur(7.5)) = " & CInt(CCur(7.5)))
+Call ok(getVT(CInt(CCur(7.5))) = "VT_I2", "getVT(CInt(CCur(7.5))) = " & getVT(CInt(CCur(7.5))))
+Call ok(CInt(CDate(0)) = 0, "CInt(CDate(0)) = " & CInt(CDate(0)))
+Call ok(getVT(CInt(CDate(0))) = "VT_I2", "getVT(CInt(CDate(0))) = " & getVT(CInt(CDate(0))))
+Call ok(CInt(CDate(6.49)) = 6, "CInt(CDate(6.49)) = " & CInt(CDate(6.49)))
+Call ok(getVT(CInt(CDate(6.49))) = "VT_I2", "getVT(CInt(CDate(6.49))) = " & getVT(CInt(CDate(6.49))))
+Call ok(CInt("6.5") = 6, "CInt(""6.5"") = " & CInt("6.5"))
+Call ok(getVT(CInt("6.5")) = "VT_I2", "getVT(CInt(""6.5"")) = " & getVT(CInt("6.5")))
+Call ok(CInt(True) = -1, "CInt(True) = " & CInt(True))
+Call ok(getVT(CInt(True)) = "VT_I2", "getVT(CInt(True)) = " & getVT(CInt(True)))
+Call ok(CInt(False) = 0, "CInt(False) = " & CInt(False))
+Call ok(getVT(CInt(False)) = "VT_I2", "getVT(CInt(False)) = " & getVT(CInt(False)))
+Call ok(CInt(CByte(6.51)) = 7, "CInt(CByte(6.51)) = " & CInt(CByte(6.51)))
+Call ok(getVT(CInt(CByte(6.51))) = "VT_I2", "getVT(CInt(CByte(6.51))) = " & getVT(CInt(CByte(6.51))))
+
+Call ok(CLng(Empty) = 0, "CLng(Empty) = " & CLng(Empty))
+Call ok(getVT(CLng(Empty)) = "VT_I4", "getVT(CLng(Empty)) = " & getVT(CLng(Empty)))
+Call ok(CLng(32767) = 32767, "CLng(32767) = " & CLng(32767))
+Call ok(getVT(CLng(32767)) = "VT_I4", "getVT(CLng(32767)) = " & getVT(CLng(32767)))
+Call ok(CLng(2147483647) = 2147483647, "CLng(2147483647) = " & CLng(2147483647))
+Call ok(getVT(CLng(2147483647)) = "VT_I4", "getVT(CLng(2147483647)) = " & getVT(CLng(2147483647)))
+Call ok(CLng(CSng(32767.12)) = 32767, "CLng(CSng(32767.12)) = " & CLng(CSng(32767.12)))
+Call ok(getVT(CLng(CSng(32767.12))) = "VT_I4", "getVT(CLng(CSng(32767.12))) = " & getVT(CLng(CSng(32767.12))))
+Call ok(CLng(-2147483648.5) = -2147483648, "CLng(-2147483648.5) = " & CLng(-2147483648.5))
+Call ok(getVT(CLng(-2147483648.5)) = "VT_I4", "getVT(CLng(-2147483648.5)) = " & getVT(CLng(-2147483648.5)))
+Call ok(CLng(CCur(-2147483648)) = -2147483648, "CLng(CCur(-2147483648)) = " & CLng(CCur(-2147483648)))
+Call ok(getVT(CLng(CCur(-2147483648))) = "VT_I4", "getVT(CLng(CCur(-2147483648))) = " & getVT(CLng(CCur(-2147483648))))
+Call ok(CLng(CDate(0)) = 0, "CLng(CDate(0)) = " & CLng(CDate(0)))
+Call ok(getVT(CLng(CDate(0))) = "VT_I4", "getVT(CLng(CDate(0))) = " & getVT(CLng(CDate(0))))
+Call ok(CLng(CDate(6.49)) = 6, "CLng(CDate(6.49)) = " & CLng(CDate(6.49)))
+Call ok(getVT(CLng(CDate(6.49))) = "VT_I4", "getVT(CLng(CDate(6.49))) = " & getVT(CLng(CDate(6.49))))
+Call ok(CLng("6.5") = 6, "CLng(""6.5"") = " & CLng("6.5"))
+Call ok(getVT(CLng("6.5")) = "VT_I4", "getVT(CLng(""6.5"")) = " & getVT(CLng("6.5")))
+Call ok(CLng(True) = -1, "CLng(True) = " & CLng(True))
+Call ok(getVT(CLng(True)) = "VT_I4", "getVT(CLng(True)) = " & getVT(CLng(True)))
+Call ok(CLng(False) = 0, "CLng(False) = " & CLng(False))
+Call ok(getVT(CLng(False)) = "VT_I4", "getVT(CLng(False)) = " & getVT(CLng(False)))
+Call ok(CLng(CByte(6.51)) = 7, "CLng(CByte(6.51)) = " & CLng(CByte(6.51)))
+Call ok(getVT(CLng(CByte(6.51))) = "VT_I4", "getVT(CLng(CByte(6.51))) = " & getVT(CLng(CByte(6.51))))
+
+Call ok(CSng(Empty) = 0, "CSng(Empty) = " & CSng(Empty))
+Call ok(getVT(CSng(Empty)) = "VT_R4", "getVT(CSng(Empty)) = " & getVT(CSng(Empty)))
+Call ok(CSng(0) = 0, "CSng(0) = " & CSng(0))
+Call ok(getVT(CSng(0)) = "VT_R4", "getVT(CSng(0)) = " & getVT(CSng(0)))
+Call ok(CSng(CLng(32767)) = 32767, "CSng(CLng(32767)) = " & CSng(CLng(32767)))
+Call ok(getVT(CSng(CLng(32767))) = "VT_R4", "getVT(CSng(CLng(32767))) = " & getVT(CSng(CLng(32767))))
+Call ok(CSng(CSng(32767.49)) = 32767.49, "CSng(CSng(32767.49)) = " & CSng(CSng(32767.49)))
+Call ok(getVT(CSng(CSng(32767.49))) = "VT_R4", "getVT(CSng(CSng(32767.49))) = " & getVT(CSng(CSng(32767.49))))
+Call ok(CSng(-32768.5) = -32768.5, "CSng(-32768.5) = " & CSng(-32768.5))
+Call ok(getVT(CSng(-32768.5)) = "VT_R4", "getVT(CSng(-32768.5)) = " & getVT(CSng(-32768.5)))
+Call ok(CSng(CCur(7.5)) = 7.5, "CSng(CCur(7.5)) = " & CSng(CCur(7.5)))
+Call ok(getVT(CSng(CCur(7.5))) = "VT_R4", "getVT(CSng(CCur(7.5))) = " & getVT(CSng(CCur(7.5))))
+Call ok(CSng(CDate(0)) = 0, "CSng(CDate(0)) = " & CSng(CDate(0)))
+Call ok(getVT(CSng(CDate(0))) = "VT_R4", "getVT(CSng(CDate(0))) = " & getVT(CSng(CDate(0))))
+Call ok(CSng(CDate(6.49)) = 6.49, "CSng(CDate(6.49)) = " & CSng(CDate(6.49)))
+Call ok(getVT(CSng(CDate(6.49))) = "VT_R4", "getVT(CSng(CDate(6.49))) = " & getVT(CSng(CDate(6.49))))
+Call ok(CSng("6.5") = 6.5, "CSng(""6.5"") = " & CSng("6.5"))
+Call ok(getVT(CSng("6.5")) = "VT_R4", "getVT(CSng(""6.5"")) = " & getVT(CSng("6.5")))
+Call ok(CSng(True) = -1, "CSng(True) = " & CSng(True))
+Call ok(getVT(CSng(True)) = "VT_R4", "getVT(CSng(True)) = " & getVT(CSng(True)))
+Call ok(CSng(False) = 0, "CSng(False) = " & CSng(False))
+Call ok(getVT(CSng(False)) = "VT_R4", "getVT(CSng(False)) = " & getVT(CSng(False)))
+Call ok(CSng(CByte(6.51)) = 7, "CSng(CByte(6.51)) = " & CSng(CByte(6.51)))
+Call ok(getVT(CSng(CByte(6.51))) = "VT_R4", "getVT(CSng(CByte(6.51))) = " & getVT(CSng(CByte(6.51))))
+
+Call ok(CStr(Empty) = "", "CStr(Empty) = " & CStr(Empty))
+Call ok(getVT(CStr(Empty)) = "VT_BSTR", "getVT(CStr(Empty)) = " & getVT(CStr(Empty)))
+Call ok(CStr(0) = "0", "CStr(0) = " & CStr(0))
+Call ok(getVT(CStr(0)) = "VT_BSTR", "getVT(CStr(0)) = " & getVT(CStr(0)))
+Call ok(CStr(CLng(32767)) = "32767", "CStr(CLng(32767)) = " & CStr(CLng(32767)))
+Call ok(getVT(CStr(CLng(32767))) = "VT_BSTR", "getVT(CStr(CLng(32767))) = " & getVT(CStr(CLng(32767))))
+Call ok(CStr(CSng(32767.4)) = "32767.4", "CStr(CSng(32767.4)) = " & CStr(CSng(32767.4)))
+Call ok(getVT(CStr(CSng(32767.4))) = "VT_BSTR", "getVT(CStr(CSng(32767.4))) = " & getVT(CStr(CSng(32767.4))))
+Call ok(CStr(-32768.5) = "-32768.5", "CStr(-32768.5) = " & CStr(-32768.5))
+Call ok(getVT(CStr(-32768.5)) = "VT_BSTR", "getVT(CStr(-32768.5)) = " & getVT(CStr(-32768.5)))
+Call ok(CStr(CCur(7.5)) = "7.5", "CStr(CCur(7.5)) = " & CStr(CCur(7.5)))
+Call ok(getVT(CStr(CCur(7.5))) = "VT_BSTR", "getVT(CStr(CCur(7.5))) = " & getVT(CStr(CCur(7.5))))
+Call ok(CStr(CDate(0.5)) = "12:00:00" Or CStr(CDate(0.5)) = "12:00:00 PM", "CStr(CDate(0.5)) = " & CStr(CDate(0.5)))
+Call ok(getVT(CStr(CDate(0.5))) = "VT_BSTR", "getVT(CStr(CDate(0.5))) = " & getVT(CStr(CDate(0.5))))
+Call ok(CStr(CDate(-0.5)) = "12:00:00" Or CStr(CDate(-0.5)) = "12:00:00 PM", "CStr(CDate(-0.5)) = " & CStr(CDate(-0.5)))
+Call ok(getVT(CStr(CDate(-0.5))) = "VT_BSTR", "getVT(CStr(CDate(-0.5))) = " & getVT(CStr(CDate(-0.5))))
+Call ok(CStr(CDate(1.5)) = "1899-12-31 12:00:00" Or CStr(CDate(1.5)) = "12/31/1899 12:00:00 PM", "CStr(CDate(1.5)) = " & CStr(CDate(1.5)))
+Call ok(getVT(CStr(CDate(1.5))) = "VT_BSTR", "getVT(CStr(CDate(1.5))) = " & getVT(CStr(CDate(1.5))))
+Call ok(CStr(CDate(-1.5)) = "1899-12-29 12:00:00" Or CStr(CDate(-1.5)) = "12/29/1899 12:00:00 PM", "CStr(CDate(-1.5)) = " & CStr(CDate(-1.5)))
+Call ok(getVT(CStr(CDate(-1.5))) = "VT_BSTR", "getVT(CStr(CDate(-1.5))) = " & getVT(CStr(CDate(-1.5))))
+Call ok(CStr(True) = "True", "CStr(True) = " & CStr(True))
+Call ok(getVT(CStr(True)) = "VT_BSTR", "getVT(CStr(True)) = " & getVT(CStr(True)))
+Call ok(CStr(False) = "False", "CStr(False) = " & CStr(False))
+Call ok(getVT(CStr(False)) = "VT_BSTR", "getVT(CStr(False)) = " & getVT(CStr(False)))
+Call ok(CStr(CByte(6.51)) = "7", "CStr(CByte(6.51)) = " & CStr(CByte(6.51)))
+Call ok(getVT(CStr(CByte(6.51))) = "VT_BSTR", "getVT(CStr(CByte(6.51))) = " & getVT(CStr(CByte(6.51))))
+
 Call reportSuccess()
diff --git a/dlls/vbscript/tests/run.c b/dlls/vbscript/tests/run.c
index b5c3688..ef9db42 100644
--- a/dlls/vbscript/tests/run.c
+++ b/dlls/vbscript/tests/run.c
@@ -163,8 +163,12 @@ static const char *vt2a(VARIANT *v)
         return "VT_I2";
     case VT_I4:
         return "VT_I4";
+    case VT_R4:
+        return "VT_R4";
     case VT_R8:
         return "VT_R8";
+    case VT_CY:
+        return "VT_CY";
     case VT_DATE:
         return "VT_DATE";
     case VT_BSTR:
@@ -177,6 +181,8 @@ static const char *vt2a(VARIANT *v)
         return "VT_ARRAY|VT_VARIANT";
     case VT_ARRAY|VT_BYREF|VT_VARIANT:
         return "VT_ARRAY|VT_BYREF|VT_VARIANT";
+    case VT_UI1:
+        return "VT_UI1";
     default:
         ok(0, "unknown vt %d\n", V_VT(v));
         return NULL;
-- 
1.8.1.2



More information about the wine-devel mailing list