Jacek Caban : jscript: Added conditional compilation tests.

Alexandre Julliard julliard at winehq.org
Tue Dec 28 10:48:21 CST 2010


Module: wine
Branch: master
Commit: 10b1a7edf61cd077198b58836d9943eebcd2d4c0
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=10b1a7edf61cd077198b58836d9943eebcd2d4c0

Author: Jacek Caban <jacek at codeweavers.com>
Date:   Tue Dec 28 15:40:39 2010 +0100

jscript: Added conditional compilation tests.

---

 dlls/jscript/tests/api.js  |    4 ++
 dlls/jscript/tests/cc.js   |   75 ++++++++++++++++++++++++++++++++++++++++++++
 dlls/jscript/tests/rsrc.rc |    3 ++
 dlls/jscript/tests/run.c   |   15 +++++++++
 4 files changed, 97 insertions(+), 0 deletions(-)

diff --git a/dlls/jscript/tests/api.js b/dlls/jscript/tests/api.js
index 6c62276..482d8b2 100644
--- a/dlls/jscript/tests/api.js
+++ b/dlls/jscript/tests/api.js
@@ -1899,6 +1899,7 @@ var exception_array = {
     E_RBRACKET:          { type: "SyntaxError",  number: -2146827282 },
     E_SEMICOLON:         { type: "SyntaxError",  number: -2146827284 },
     E_UNTERMINATED_STR:  { type: "SyntaxError",  number: -2146827273 },
+    E_DISABLED_CC:       { type: "SyntaxError",  number: -2146827258 },
 
     E_ILLEGAL_ASSIGN:  { type: "ReferenceError", number: -2146823280 },
 
@@ -1986,6 +1987,9 @@ testSyntaxError("while(", "E_SYNTAX_ERROR");
 testSyntaxError("if(", "E_SYNTAX_ERROR");
 testSyntaxError("'unterminated", "E_UNTERMINATED_STR");
 testSyntaxError("*", "E_SYNTAX_ERROR");
+testSyntaxError("@_jscript_version", "E_DISABLED_CC");
+testSyntaxError("@a", "E_DISABLED_CC");
+testSyntaxError("/* @cc_on @*/ @_jscript_version", "E_DISABLED_CC");
 
 // ReferenceError tests
 testException(function() {test = function() {}}, "E_ILLEGAL_ASSIGN");
diff --git a/dlls/jscript/tests/cc.js b/dlls/jscript/tests/cc.js
new file mode 100644
index 0000000..1fee93f
--- /dev/null
+++ b/dlls/jscript/tests/cc.js
@@ -0,0 +1,75 @@
+/*
+ * Copyright 2010 Jacek Caban for CodeWeavers
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
+ */
+
+eval("@_jscript_version");
+
+var tmp;
+
+/*@ */
+//@cc_on @*/
+
+ at _jscript_version;
+
+ at cc_on
+@*/
+
+// Standard predefined variabled
+if(isWin64) {
+    ok(@_win64 === true, "@_win64 = " + @_win64);
+    ok(@_amd64 === true, "@_amd64 = " + @_amd64);
+    ok(isNaN(@_win32), "@_win32 = " + @_win32);
+    ok(isNaN(@_x86), "@_x86 = " + @_x86);
+}else {
+    ok(@_win32 === true, "@_win32 = " + @_win32);
+    ok(@_x86 === true, "@_x86 = " + @_x86);
+    ok(isNaN(@_win64), "@_win64 = " + @_win64);
+    ok(isNaN(@_amd64), "@_amd64 = " + @_amd64);
+}
+
+ok(@_jscript === true, "@_jscript = " + @_jscript);
+ok(@_jscript_build === ScriptEngineBuildVersion(),
+   "@_jscript_build = " + @_jscript_build + " expected " + ScriptEngineBuildVersion());
+tmp = ScriptEngineMajorVersion() + ScriptEngineMinorVersion()/10;
+ok(@_jscript_version === tmp, "@_jscript_version = " + @_jscript_version + " expected " + tmp);
+ok(isNaN(@_win16), "@_win16 = " + @_win16);
+ok(isNaN(@_mac), "@_mac = " + @_mac);
+ok(isNaN(@_alpha), "@_alpha = " + @_alpha);
+ok(isNaN(@_mc680x0), "@_mc680x0 = " + @_mc680x0);
+ok(isNaN(@_PowerPC), "@_PowerPC = " + @_PowerPC);
+
+// Undefined variable
+ok(isNaN(@xxx), "@xxx = " + @xxx);
+ok(isNaN(@x$_xx), "@x$_xx = " + @x$_xx);
+
+tmp = false;
+try {
+    eval("/*@cc_on */");
+}catch(e) {
+    tmp = true;
+}
+ok(tmp, "expected syntax exception");
+
+tmp = false;
+try {
+    eval("/*@_jscript_version */");
+}catch(e) {
+    tmp = true;
+}
+ok(tmp, "expected syntax exception");
+
+reportSuccess();
diff --git a/dlls/jscript/tests/rsrc.rc b/dlls/jscript/tests/rsrc.rc
index ecb4212..457dc4f 100644
--- a/dlls/jscript/tests/rsrc.rc
+++ b/dlls/jscript/tests/rsrc.rc
@@ -19,6 +19,9 @@
 /* @makedep: api.js */
 api.js 40 "api.js"
 
+/* @makedep: cc.js */
+cc.js 40 "cc.js"
+
 /* @makedep: lang.js */
 lang.js 40 "lang.js"
 
diff --git a/dlls/jscript/tests/run.c b/dlls/jscript/tests/run.c
index 61e371c..7b198df 100644
--- a/dlls/jscript/tests/run.c
+++ b/dlls/jscript/tests/run.c
@@ -87,6 +87,7 @@ DEFINE_EXPECT(invoke_func);
 #define DISPID_GLOBAL_CREATEARRAY   0x100c
 #define DISPID_GLOBAL_PROPGETFUNC   0x100d
 #define DISPID_GLOBAL_OBJECT_FLAG   0x100e
+#define DISPID_GLOBAL_ISWIN64       0x100f
 
 #define DISPID_TESTOBJ_PROP         0x2000
 
@@ -387,6 +388,12 @@ static HRESULT WINAPI Global_GetDispID(IDispatchEx *iface, BSTR bstrName, DWORD
         return S_OK;
     }
 
+    if(!strcmp_wa(bstrName, "isWin64")) {
+        test_grfdex(grfdex, fdexNameCaseSensitive);
+        *pid = DISPID_GLOBAL_ISWIN64;
+        return S_OK;
+    }
+
     if(strict_dispid_check)
         ok(0, "unexpected call %s\n", wine_dbgstr_w(bstrName));
     return DISP_E_UNKNOWNNAME;
@@ -543,6 +550,13 @@ static HRESULT WINAPI Global_InvokeEx(IDispatchEx *iface, DISPID id, LCID lcid,
         }
         return S_OK;
 
+    case DISPID_GLOBAL_ISWIN64:
+        if(pvarRes) {
+            V_VT(pvarRes) = VT_BOOL;
+            V_BSTR(pvarRes) = sizeof(void*) == 8 ? VARIANT_TRUE : VARIANT_FALSE;
+        }
+        return S_OK;
+
     case DISPID_GLOBAL_NULL_DISP:
         ok(wFlags == INVOKE_PROPERTYGET, "wFlags = %x\n", wFlags);
         ok(pdp != NULL, "pdp == NULL\n");
@@ -1420,6 +1434,7 @@ static void run_tests(void)
     run_from_res("lang.js");
     run_from_res("api.js");
     run_from_res("regexp.js");
+    run_from_res("cc.js");
 
     test_isvisible(FALSE);
     test_isvisible(TRUE);




More information about the wine-cvs mailing list