summaryrefslogtreecommitdiff
path: root/js/test/Ice/defaultValue/Client.js
diff options
context:
space:
mode:
authorMark Spruiell <mes@zeroc.com>2014-03-19 12:45:55 -0700
committerMark Spruiell <mes@zeroc.com>2014-03-19 12:45:55 -0700
commitcdcffbcc3c3c052afdeb772ff0167e7a90b525bb (patch)
tree4f16ee41ef7d33394c44e9db81e4d6cd89908250 /js/test/Ice/defaultValue/Client.js
parentfixing testicedist.py for 5487 (diff)
downloadice-cdcffbcc3c3c052afdeb772ff0167e7a90b525bb.tar.bz2
ice-cdcffbcc3c3c052afdeb772ff0167e7a90b525bb.tar.xz
ice-cdcffbcc3c3c052afdeb772ff0167e7a90b525bb.zip
merging javascript branch
Diffstat (limited to 'js/test/Ice/defaultValue/Client.js')
-rw-r--r--js/test/Ice/defaultValue/Client.js181
1 files changed, 181 insertions, 0 deletions
diff --git a/js/test/Ice/defaultValue/Client.js b/js/test/Ice/defaultValue/Client.js
new file mode 100644
index 00000000000..73a6615217a
--- /dev/null
+++ b/js/test/Ice/defaultValue/Client.js
@@ -0,0 +1,181 @@
+// **********************************************************************
+//
+// Copyright (c) 2003-2014 ZeroC, Inc. All rights reserved.
+//
+// This copy of Ice is licensed to you under the terms described in the
+// ICE_LICENSE file included in this distribution.
+//
+// **********************************************************************
+
+(function(global){
+ var require = typeof(module) !== "undefined" ? module.require : function(){};
+ require("Ice/Ice");
+ var Ice = global.Ice;
+
+ require("Test");
+ var Test = global.Test;
+ var Promise = Ice.Promise;
+
+ var run = function(out, id)
+ {
+ var p = new Ice.Promise();
+ var test = function(b)
+ {
+ if(!b)
+ {
+ try
+ {
+ throw new Error("test failed");
+ }
+ catch(err)
+ {
+ p.fail(err);
+ throw err;
+ }
+ }
+ };
+
+ Promise.try(
+ function()
+ {
+ out.write("testing default values... ");
+ var v = new Test.Struct1();
+ test(!v.boolFalse);
+ test(v.boolTrue);
+ test(v.b === 254);
+ test(v.s === 16000);
+ test(v.i === 3);
+ test(v.l.equals(new Ice.Long(0, 4)));
+ test(v.f === 5.1);
+ test(v.d === 6.2);
+ test(v.str === "foo \\ \"bar\n \r\n\t\u000b\f\u0007\b?");
+ test(v.c1 === Test.Color.red);
+ test(v.c2 === Test.Color.green);
+ test(v.c3 === Test.Color.blue);
+ test(v.nc1 === Test.Nested.Color.red);
+ test(v.nc2 === Test.Nested.Color.green);
+ test(v.nc3 === Test.Nested.Color.blue);
+ test(v.noDefault === null);
+ test(v.zeroI === 0);
+ test(v.zeroL.equals(new Ice.Long(0, 0)));
+ test(v.zeroF === 0);
+ test(v.zeroDotF === 0);
+ test(v.zeroD === 0);
+ test(v.zeroDotD === 0);
+
+ v = new Test.Struct2();
+ test(v.boolTrue === Test.ConstBool);
+ test(v.b === Test.ConstByte);
+ test(v.s === Test.ConstShort);
+ test(v.i === Test.ConstInt);
+ test(v.l.equals(Test.ConstLong));
+ test(v.f === Test.ConstFloat);
+ test(v.d === Test.ConstDouble);
+ test(v.str == Test.ConstString);
+ test(v.c1 === Test.ConstColor1);
+ test(v.c2 === Test.ConstColor2);
+ test(v.c3 === Test.ConstColor3);
+ test(v.nc1 === Test.ConstNestedColor1);
+ test(v.nc2 === Test.ConstNestedColor2);
+ test(v.nc3 === Test.ConstNestedColor3);
+
+ v = new Test.Base();
+ test(!v.boolFalse);
+ test(v.boolTrue);
+ test(v.b === 1);
+ test(v.s === 2);
+ test(v.i === 3);
+ test(v.l.equals(new Ice.Long(0, 4)));
+ test(v.f === 5.1);
+ test(v.d === 6.2);
+ test(v.str == "foo \\ \"bar\n \r\n\t\u000b\f\u0007\b?");
+ test(v.noDefault === null);
+ test(v.zeroI === 0);
+ test(v.zeroL.equals(new Ice.Long(0, 0)));
+ test(v.zeroF === 0);
+ test(v.zeroDotF === 0);
+ test(v.zeroD === 0);
+ test(v.zeroDotD === 0);
+
+ v = new Test.Derived();
+ test(!v.boolFalse);
+ test(v.boolTrue);
+ test(v.b === 1);
+ test(v.s === 2);
+ test(v.i === 3);
+ test(v.l.equals(new Ice.Long(0, 4)));
+ test(v.f === 5.1);
+ test(v.d === 6.2);
+ test(v.str == "foo \\ \"bar\n \r\n\t\u000b\f\u0007\b?");
+ test(v.c1 === Test.Color.red);
+ test(v.c2 === Test.Color.green);
+ test(v.c3 === Test.Color.blue);
+ test(v.nc1 === Test.Nested.Color.red);
+ test(v.nc2 === Test.Nested.Color.green);
+ test(v.nc3 === Test.Nested.Color.blue);
+ test(v.noDefault === null);
+ test(v.zeroI === 0);
+ test(v.zeroL.equals(new Ice.Long(0, 0)));
+ test(v.zeroF === 0);
+ test(v.zeroDotF === 0);
+ test(v.zeroD === 0);
+ test(v.zeroDotD === 0);
+
+ v = new Test.BaseEx();
+ test(!v.boolFalse);
+ test(v.boolTrue);
+ test(v.b === 1);
+ test(v.s === 2);
+ test(v.i === 3);
+ test(v.l.equals(new Ice.Long(0, 4)));
+ test(v.f === 5.1);
+ test(v.d === 6.2);
+ test(v.str == "foo \\ \"bar\n \r\n\t\u000b\f\u0007\b?");
+ test(v.noDefault === null);
+ test(v.zeroI === 0);
+ test(v.zeroL.equals(new Ice.Long(0, 0)));
+ test(v.zeroF === 0);
+ test(v.zeroDotF === 0);
+ test(v.zeroD === 0);
+ test(v.zeroDotD === 0);
+
+ v = new Test.DerivedEx();
+ test(!v.boolFalse);
+ test(v.boolTrue);
+ test(v.b === 1);
+ test(v.s === 2);
+ test(v.i === 3);
+ test(v.l.equals(new Ice.Long(0, 4)));
+ test(v.f === 5.1);
+ test(v.d === 6.2);
+ test(v.str == "foo \\ \"bar\n \r\n\t\u000b\f\u0007\b?");
+ test(v.noDefault === null);
+ test(v.c1 === Test.Color.red);
+ test(v.c2 === Test.Color.green);
+ test(v.c3 === Test.Color.blue);
+ test(v.nc1 === Test.Nested.Color.red);
+ test(v.nc2 === Test.Nested.Color.green);
+ test(v.nc3 === Test.Nested.Color.blue);
+ test(v.zeroI === 0);
+ test(v.zeroL.equals(new Ice.Long(0, 0)));
+ test(v.zeroF === 0);
+ test(v.zeroDotF === 0);
+ test(v.zeroD === 0);
+ test(v.zeroDotD === 0);
+
+ out.writeLine("ok");
+ }
+ ).then(
+ function()
+ {
+ p.succeed();
+ },
+ function(ex)
+ {
+ p.fail(ex);
+ }
+ );
+ return p;
+ };
+ global.__test__ = run;
+}(typeof (global) === "undefined" ? window : global));