diff options
author | Jose <jose@zeroc.com> | 2017-10-02 18:12:06 +0200 |
---|---|---|
committer | Jose <jose@zeroc.com> | 2017-10-02 18:12:06 +0200 |
commit | 336828d5ded57be680eee0fb8139ddfa0c422be0 (patch) | |
tree | d9021a80ad8be9b7545925cdef16fc356b60ba15 | |
parent | JavaScript style fixes (diff) | |
download | ice-336828d5ded57be680eee0fb8139ddfa0c422be0.tar.bz2 ice-336828d5ded57be680eee0fb8139ddfa0c422be0.tar.xz ice-336828d5ded57be680eee0fb8139ddfa0c422be0.zip |
JavaScript testsuite improvements and simplifications
23 files changed, 242 insertions, 206 deletions
diff --git a/js/test/Glacier2/router/Client.js b/js/test/Glacier2/router/Client.js index 3f6aa74ecf3..267a73198eb 100644 --- a/js/test/Glacier2/router/Client.js +++ b/js/test/Glacier2/router/Client.js @@ -13,13 +13,18 @@ const Glacier2 = require("ice").Glacier2; const Test = require("Callback").Test; - function test(value) + function test(value, ex) { if(!value) { - throw new Error("test failed"); + let message = "test failed"; + if(ex) + { + message += "\n" + ex.toString(); + } + throw new Error(message); } - }; + } const CallbackPrx = Test.CallbackPrx; const CallbackReceiverPrx = Test.CallbackReceiverPrx; @@ -88,7 +93,7 @@ } catch(ex) { - test(ex instanceof Ice.ConnectionLostException); + test(ex instanceof Ice.ConnectionLostException, ex); } out.writeLine("ok"); @@ -100,7 +105,7 @@ } catch(ex) { - test(ex instanceof Glacier2.PermissionDeniedException); + test(ex instanceof Glacier2.PermissionDeniedException, ex); } out.writeLine("ok"); @@ -112,7 +117,7 @@ } catch(ex) { - test(ex instanceof Glacier2.SessionNotExistException); + test(ex instanceof Glacier2.SessionNotExistException, ex); } out.writeLine("ok"); @@ -128,7 +133,7 @@ } catch(ex) { - test(ex instanceof Glacier2.CannotCreateSessionException); + test(ex instanceof Glacier2.CannotCreateSessionException, ex); } out.writeLine("ok"); @@ -192,7 +197,7 @@ } catch(ex) { - test(ex instanceof Test.CallbackException); + test(ex instanceof Test.CallbackException, ex); test(ex.someValue == 3.14); test(ex.someString == "3.14"); } @@ -210,7 +215,7 @@ } catch(ex) { - test(ex instanceof Ice.ObjectNotExistException); + test(ex instanceof Ice.ObjectNotExistException, ex); } out.writeLine("ok"); @@ -233,7 +238,7 @@ } catch(ex) { - test(ex instanceof Ice.ObjectNotExistException); + test(ex instanceof Ice.ObjectNotExistException, ex); } out.writeLine("ok"); @@ -266,7 +271,7 @@ } catch(ex) { - test(ex instanceof Ice.ConnectionLostException); + test(ex instanceof Ice.ConnectionLostException, ex); } out.writeLine("ok"); @@ -294,7 +299,7 @@ } catch(ex) { - test(ex instanceof Ice.LocalException); + test(ex instanceof Ice.LocalException, ex); } out.writeLine("ok"); } diff --git a/js/test/Ice/acm/Client.js b/js/test/Ice/acm/Client.js index aad7c24c378..0eb27122639 100644 --- a/js/test/Ice/acm/Client.js +++ b/js/test/Ice/acm/Client.js @@ -435,25 +435,19 @@ await proxy.startHeartbeatCount(); await proxy.waitForHeartbeatCount(2); - { - const p = new Promise( - (resolve, reject) => - { - con.setCloseCallback(() => resolve()); - }); - con.close(Ice.ConnectionClose.Gracefully); - await p; - } - - { - const p = new Promise( - (resolve, reject) => - { - con.setCloseCallback(() => resolve()); - }); - await p; - con.setHeartbeatCallback(c => test(false)); - } + await new Promise( + (resolve, reject) => + { + con.setCloseCallback(() => resolve()); + con.close(Ice.ConnectionClose.Gracefully); + }); + + await new Promise( + (resolve, reject) => + { + con.setCloseCallback(() => resolve()); + }); + con.setHeartbeatCallback(c => test(false)); } } @@ -511,7 +505,6 @@ { initData.properties.setProperty("Ice.Warn.Connections", "0"); communicator = Ice.initialize(initData); - await allTests(out, communicator); } finally diff --git a/js/test/Ice/exceptions/AMDThrowerI.js b/js/test/Ice/exceptions/AMDThrowerI.js index 3f00bcba269..ae6662f71d4 100644 --- a/js/test/Ice/exceptions/AMDThrowerI.js +++ b/js/test/Ice/exceptions/AMDThrowerI.js @@ -18,7 +18,7 @@ { throw new Error("test failed"); } - }; + } class AMDThrowerI extends Test.Thrower { diff --git a/js/test/Ice/exceptions/Client.js b/js/test/Ice/exceptions/Client.js index fabf3cf8f96..003e40b81b9 100644 --- a/js/test/Ice/exceptions/Client.js +++ b/js/test/Ice/exceptions/Client.js @@ -41,7 +41,7 @@ let message = "test failed"; if(ex) { - message += ": " + ex.toString(); + message += "\n" + ex.toString(); } throw new Error(message); } @@ -470,7 +470,7 @@ } catch(ex) { - test(ex instanceof Test.A); + test(ex instanceof Test.A, ex); } out.writeLine("ok"); diff --git a/js/test/Ice/exceptions/ThrowerI.js b/js/test/Ice/exceptions/ThrowerI.js index 89cabaa2875..501b89b5edd 100644 --- a/js/test/Ice/exceptions/ThrowerI.js +++ b/js/test/Ice/exceptions/ThrowerI.js @@ -134,7 +134,6 @@ throw new Test.A(); } } - exports.ThrowerI = ThrowerI; } (typeof(global) !== "undefined" && typeof(global.process) !== "undefined" ? module : undefined, diff --git a/js/test/Ice/inheritance/Client.js b/js/test/Ice/inheritance/Client.js index 83e2239e9a6..15ae2d6aaae 100644 --- a/js/test/Ice/inheritance/Client.js +++ b/js/test/Ice/inheritance/Client.js @@ -35,7 +35,6 @@ out.writeLine("ok"); out.write("getting proxies for class hierarchy... "); - let ca = await initial.caop(); let cb = await initial.cbop(); let cc = await initial.ccop(); diff --git a/js/test/Ice/location/Client.js b/js/test/Ice/location/Client.js index c7ea800e75f..0440783e66f 100644 --- a/js/test/Ice/location/Client.js +++ b/js/test/Ice/location/Client.js @@ -14,11 +14,16 @@ async function allTests(out, communicator) { - function test(value) + function test(value, ex) { if(!value) { - throw new Error("test failed"); + let message = "test failed"; + if(ex) + { + message += "\n" + ex.toString(); + } + throw new Error(message); } } @@ -139,7 +144,7 @@ } catch(ex) { - test(ex instanceof Ice.NotRegisteredException); + test(ex instanceof Ice.NotRegisteredException, ex); test(ex.kindOfObject == "object"); test(ex.id == "unknown/unknown"); } @@ -153,7 +158,7 @@ } catch(ex) { - test(ex instanceof Ice.NotRegisteredException); + test(ex instanceof Ice.NotRegisteredException, ex); test(ex.kindOfObject == "object adapter"); test(ex.id == "TestAdapterUnknown"); } @@ -240,7 +245,7 @@ }, (ex) => { - test(ex instanceof Ice.NotRegisteredException); + test(ex instanceof Ice.NotRegisteredException, ex); })); } await Promise.all(results); @@ -262,7 +267,7 @@ } catch(ex) { - test(ex instanceof Ice.NotRegisteredException); + test(ex instanceof Ice.NotRegisteredException, ex); test(ex.kindOfObject == "object adapter"); test(ex.id == "TestAdapter3"); } @@ -275,7 +280,7 @@ } catch(ex) { - test(false); + test(false, ex); } try @@ -285,7 +290,7 @@ } catch(ex) { - test(ex instanceof Ice.LocalException); + test(ex instanceof Ice.LocalException, ex); } try { @@ -294,7 +299,7 @@ } catch(ex) { - test(ex instanceof Ice.LocalException); + test(ex instanceof Ice.LocalException, ex); } await registry.setAdapterDirectProxy("TestAdapter3", await locator.findAdapterById("TestAdapter")); try @@ -303,7 +308,7 @@ } catch(ex) { - test(false); + test(false, ex); } out.writeLine("ok"); @@ -317,6 +322,7 @@ } catch(ex) { + test(ex instanceof Ice.NotRegisteredException, ex); test(ex.kindOfObject == "object adapter"); test(ex.id == "TestUnknown"); } @@ -329,7 +335,7 @@ } catch(ex) { - test(ex instanceof Ice.LocalException); + test(ex instanceof Ice.LocalException, ex); } await registry.setAdapterDirectProxy("TestAdapter4", await locator.findAdapterById("TestAdapter")); @@ -339,7 +345,7 @@ } catch(ex) { - test(false); + test(false, ex); } await registry.setAdapterDirectProxy("TestAdapter4", communicator.stringToProxy("dummy:default")); @@ -349,7 +355,7 @@ } catch(ex) { - test(false); + test(false, ex); } try @@ -359,7 +365,7 @@ } catch(ex) { - test(ex instanceof Ice.LocalException); + test(ex instanceof Ice.LocalException, ex); } try @@ -369,6 +375,7 @@ } catch(ex) { + test(ex instanceof Ice.LocalException); } try @@ -378,7 +385,7 @@ } catch(ex) { - test(ex instanceof Ice.LocalException); + test(ex instanceof Ice.LocalException, ex); } await registry.addObject(communicator.stringToProxy("test3@TestAdapter")); @@ -388,7 +395,7 @@ } catch(ex) { - test(false); + test(false, ex); } await registry.addObject(communicator.stringToProxy("test4")); @@ -399,6 +406,7 @@ } catch(ex) { + test(ex instanceof Ice.NoEndpointException, ex); } out.writeLine("ok"); @@ -441,7 +449,7 @@ catch(ex) { // Expected to fail once they endpoints have been updated in the background. - test(ex instanceof Ice.LocalException); + test(ex instanceof Ice.LocalException, ex); } try { @@ -454,7 +462,7 @@ catch(ex) { // Expected to fail once they endpoints have been updated in the background. - test(ex instanceof Ice.LocalException); + test(ex instanceof Ice.LocalException, ex); } await ic.destroy(); } diff --git a/js/test/Ice/number/Client.js b/js/test/Ice/number/Client.js index 62f91fb600c..bd01243563a 100644 --- a/js/test/Ice/number/Client.js +++ b/js/test/Ice/number/Client.js @@ -11,9 +11,9 @@ { const Ice = require("ice").Ice; - function test(b) + function test(value) { - if(!b) + if(!value) { throw new Error("test failed"); } diff --git a/js/test/Ice/objects/Client.js b/js/test/Ice/objects/Client.js index 8b271f640f6..08ebae479f3 100644 --- a/js/test/Ice/objects/Client.js +++ b/js/test/Ice/objects/Client.js @@ -142,11 +142,16 @@ async function allTests(out, communicator) { - function test(value) + function test(value, ex) { if(!value) { - throw new Error("test failed"); + let message = "test failed"; + if(ex) + { + message += "\n" + ex.toString(); + } + throw new Error(message); } } @@ -298,7 +303,7 @@ } catch(ex) { - test(ex instanceof Test.EDerived); + test(ex instanceof Test.EDerived, ex); test(ex.a1.name == "a1"); test(ex.a2.name == "a2"); test(ex.a3.name == "a3"); @@ -344,7 +349,7 @@ { test((ex instanceof Ice.UnknownLocalException) || // Expected marshal exception from the server (max class graph depth reached) (ex instanceof Ice.UnknownException) || // Expected stack overflow from the server (Java only) - (ex instanceof Error)); // Expected, JavaScript stack overflow + (ex instanceof Error), ex); // Expected, JavaScript stack overflow } await initial.setRecursive(new Test.Recursive()); out.writeLine("ok"); @@ -374,7 +379,7 @@ } catch(ex) { - test(ex instanceof Ice.UnexpectedObjectException); + test(ex instanceof Ice.UnexpectedObjectException, ex); test(ex.type == "::Test::AlsoEmpty"); test(ex.expectedType == "::Test::Empty"); } @@ -395,6 +400,7 @@ } catch(ex) { + test(ex instanceof Test.Inner.Ex, ex); test(ex.reason == "Inner::Ex"); } @@ -405,6 +411,7 @@ } catch(ex) { + test(ex instanceof Test.Inner.Sub.Ex, ex); test(ex.reason == "Inner::Sub::Ex"); } out.writeLine("ok"); diff --git a/js/test/Ice/operations/Oneways.js b/js/test/Ice/operations/Oneways.js index 597543a693b..015629287e1 100644 --- a/js/test/Ice/operations/Oneways.js +++ b/js/test/Ice/operations/Oneways.js @@ -14,11 +14,16 @@ async function run(communicator, prx, Test, bidir) { - function test(value) + function test(value, ex) { if(!value) { - throw new Error("test failed"); + let message = "test failed"; + if(ex) + { + message + "\n" + ex.toString(); + } + throw new Error(message); } } @@ -33,7 +38,7 @@ catch(ex) { // Expected: twoway proxy required - test(ex instanceof Ice.TwowayOnlyException); + test(ex instanceof Ice.TwowayOnlyException, ex); } try @@ -44,7 +49,7 @@ catch(ex) { // Expected: twoway proxy required - test(ex instanceof Ice.TwowayOnlyException); + test(ex instanceof Ice.TwowayOnlyException, ex); } try @@ -55,7 +60,7 @@ catch(ex) { // Expected: twoway proxy required - test(ex instanceof Ice.TwowayOnlyException); + test(ex instanceof Ice.TwowayOnlyException, ex); } await prx.opVoid(); @@ -72,7 +77,7 @@ catch(ex) { // Expected: twoway proxy required - test(ex instanceof Ice.TwowayOnlyException); + test(ex instanceof Ice.TwowayOnlyException, ex); } } diff --git a/js/test/Ice/operations/Server.js b/js/test/Ice/operations/Server.js index 6d9b42c080d..1992bf843fb 100644 --- a/js/test/Ice/operations/Server.js +++ b/js/test/Ice/operations/Server.js @@ -27,9 +27,7 @@ echo.ice_getCachedConnection().setAdapter(adapter); adapter.activate(); ready.resolve(); - await communicator.waitForShutdown(); - } finally { diff --git a/js/test/Ice/operations/ServerAMD.js b/js/test/Ice/operations/ServerAMD.js index 5f55d240dcd..7a8e9f575b0 100644 --- a/js/test/Ice/operations/ServerAMD.js +++ b/js/test/Ice/operations/ServerAMD.js @@ -27,9 +27,7 @@ echo.ice_getCachedConnection().setAdapter(adapter); adapter.activate(); ready.resolve(); - await communicator.waitForShutdown(); - await echo.shutdown(); } finally @@ -38,7 +36,7 @@ { await communicator.destroy(); } - }; + } } exports._serveramd = run; diff --git a/js/test/Ice/operations/Twoways.js b/js/test/Ice/operations/Twoways.js index 08697e61275..dcc31a46787 100644 --- a/js/test/Ice/operations/Twoways.js +++ b/js/test/Ice/operations/Twoways.js @@ -14,11 +14,16 @@ async function run(communicator, prx, Test, bidir) { - function test(value) + function test(value, ex) { if(!value) { - throw new Error("test failed"); + let message = "test failed"; + if(ex) + { + message += "\n" + ex.toString(); + } + throw new Error(message); } } @@ -147,7 +152,7 @@ } catch(ex) { - test(ex instanceof Ice.MarshalException); + test(ex instanceof Ice.MarshalException, ex); } try @@ -157,7 +162,7 @@ } catch(ex) { - test(ex instanceof Ice.MarshalException); + test(ex instanceof Ice.MarshalException, ex); } try @@ -167,7 +172,7 @@ } catch(ex) { - test(ex instanceof Ice.MarshalException); + test(ex instanceof Ice.MarshalException, ex); } try @@ -177,7 +182,7 @@ } catch(ex) { - test(ex instanceof Ice.MarshalException); + test(ex instanceof Ice.MarshalException, ex); } try @@ -187,7 +192,7 @@ } catch(ex) { - test(ex instanceof Ice.MarshalException); + test(ex instanceof Ice.MarshalException, ex); } try @@ -197,7 +202,7 @@ } catch(ex) { - test(ex instanceof RangeError); + test(ex instanceof RangeError, ex); } try @@ -207,7 +212,7 @@ } catch(ex) { - test(ex instanceof RangeError); + test(ex instanceof RangeError, ex); } try @@ -217,7 +222,7 @@ } catch(ex) { - test(ex instanceof RangeError); + test(ex instanceof RangeError, ex); } try @@ -227,7 +232,7 @@ } catch(ex) { - test(ex instanceof Ice.MarshalException); + test(ex instanceof Ice.MarshalException, ex); } try @@ -237,7 +242,7 @@ } catch(ex) { - test(ex instanceof Ice.MarshalException); + test(ex instanceof Ice.MarshalException, ex); } try @@ -247,7 +252,7 @@ } catch(ex) { - test(ex instanceof Ice.MarshalException); + test(ex instanceof Ice.MarshalException, ex); } await prx.opFloatDouble(Number.NaN, Number.NaN); diff --git a/js/test/Ice/optional/AMDInitialI.js b/js/test/Ice/optional/AMDInitialI.js index 211c6856f46..745eadeed45 100644 --- a/js/test/Ice/optional/AMDInitialI.js +++ b/js/test/Ice/optional/AMDInitialI.js @@ -12,14 +12,6 @@ const Ice = require("ice").Ice; const Test = require("Test").Test; - function test(value) - { - if(!value) - { - throw new Error("test failed"); - } - } - class AMDInitialI extends Test.Initial { async shutdown(current) diff --git a/js/test/Ice/optional/Client.js b/js/test/Ice/optional/Client.js index fb4b1ad4560..5bb927250ae 100644 --- a/js/test/Ice/optional/Client.js +++ b/js/test/Ice/optional/Client.js @@ -17,11 +17,16 @@ async function allTests(out, communicator, Test) { - function test(value) + function test(value, ex) { if(!value) { - throw new Error("test failed"); + let message = "test failed"; + if(ex) + { + message += "\n" + ex.toString(); + } + throw new Error(message); } } @@ -692,7 +697,7 @@ } catch(ex) { - test(ex instanceof Test.OptionalException); + test(ex instanceof Test.OptionalException, ex); test(ex.a === undefined); test(ex.b === undefined); test(ex.o === undefined); @@ -705,7 +710,7 @@ } catch(ex) { - test(ex instanceof Test.OptionalException); + test(ex instanceof Test.OptionalException, ex); test(ex.a === 30); test(ex.b == "test"); test(ex.o.a == 53); @@ -718,7 +723,7 @@ } catch(ex) { - test(ex instanceof Test.DerivedException); + test(ex instanceof Test.DerivedException, ex); test(ex.a === undefined); test(ex.b === undefined); test(ex.o === undefined); @@ -733,7 +738,7 @@ } catch(ex) { - test(ex instanceof Test.DerivedException); + test(ex instanceof Test.DerivedException, ex); test(ex.a === 30); test(ex.b == "test2"); test(ex.o.a === 53); diff --git a/js/test/Ice/optional/InitialI.js b/js/test/Ice/optional/InitialI.js index a852d1e03a6..90db690a7eb 100644 --- a/js/test/Ice/optional/InitialI.js +++ b/js/test/Ice/optional/InitialI.js @@ -12,14 +12,6 @@ const Ice = require("ice").Ice; const Test = require("Test").Test; - function test(value) - { - if(!value) - { - throw new Error("test failed"); - } - } - class InitialI extends Test.Initial { shutdown(current) diff --git a/js/test/Ice/proxy/Client.js b/js/test/Ice/proxy/Client.js index 0200df7dee1..815d7e1b840 100644 --- a/js/test/Ice/proxy/Client.js +++ b/js/test/Ice/proxy/Client.js @@ -15,19 +15,24 @@ async function allTests(communicator, out) { - class TestFailureException extends Error + class TestError extends Error { - constructor() + constructor(message) { - super("test failed"); + super(message); } } - function test(value) + function test(value, ex) { if(!value) { - throw new TestFailureException(); + let message = "test failed"; + if(ex) + { + message += "\n" + ex.toString(); + } + throw new TestError(message); } } @@ -61,7 +66,7 @@ } catch(ex) { - test(ex instanceof Ice.ProxyParseException); + test(ex instanceof Ice.ProxyParseException, ex); } b1 = communicator.stringToProxy("\"test -f facet\""); @@ -81,7 +86,7 @@ } catch(ex) { - test(ex instanceof Ice.ProxyParseException); + test(ex instanceof Ice.ProxyParseException, ex); } b1 = communicator.stringToProxy("test\\040test"); @@ -94,7 +99,7 @@ } catch(ex) { - test(ex instanceof Ice.IdentityParseException); + test(ex instanceof Ice.IdentityParseException, ex); } b1 = communicator.stringToProxy("test\\40test"); @@ -129,7 +134,7 @@ } catch(ex) { - test(ex instanceof Ice.ProxyParseException); + test(ex instanceof Ice.ProxyParseException, ex); } try @@ -139,7 +144,7 @@ } catch(ex) { - test(ex instanceof Ice.EndpointParseException); + test(ex instanceof Ice.EndpointParseException, ex); } b1 = communicator.stringToProxy("test@adapter"); @@ -152,7 +157,7 @@ } catch(ex) { - test(ex instanceof Ice.ProxyParseException); + test(ex instanceof Ice.ProxyParseException, ex); } b1 = communicator.stringToProxy("category/test@adapter"); @@ -194,7 +199,7 @@ } catch(ex) { - test(ex instanceof Ice.ProxyParseException); + test(ex instanceof Ice.ProxyParseException, ex); } try @@ -204,7 +209,7 @@ } catch(ex) { - test(ex instanceof Ice.ProxyParseException); + test(ex instanceof Ice.ProxyParseException, ex); } b1 = communicator.stringToProxy("test -f facet:" + defaultProtocol); @@ -230,7 +235,7 @@ } catch(ex) { - test(ex instanceof Ice.ProxyParseException); + test(ex instanceof Ice.ProxyParseException, ex); } b1 = communicator.stringToProxy("test"); test(b1.ice_isTwoway()); @@ -270,7 +275,7 @@ } catch(ex) { - test(ex instanceof Ice.EndpointParseException); + test(ex instanceof Ice.EndpointParseException, ex); } // This is an unknown endpoint warning, not a parse exception. @@ -290,7 +295,7 @@ } catch(ex) { - test(ex instanceof Ice.EndpointParseException); + test(ex instanceof Ice.EndpointParseException, ex); } // @@ -334,7 +339,7 @@ } catch(ex) { - test(ex instanceof Ice.IdentityParseException); + test(ex instanceof Ice.IdentityParseException, ex); } // Testing bytes 127 (\x7F) and € @@ -555,7 +560,7 @@ } catch(ex) { - test(!(ex instanceof TestFailureException)); + test(!(ex instanceof TestError), ex); } try @@ -564,17 +569,17 @@ } catch(ex) { - test(false); + test(false, ex); } try { base.ice_timeout(-2); - test(false); + test(false, ex); } catch(ex) { - test(!(ex instanceof TestFailureException)); + test(!(ex instanceof TestError), ex); } try @@ -584,7 +589,7 @@ } catch(ex) { - test(!(ex instanceof TestFailureException)); + test(!(ex instanceof TestError), ex); } try @@ -603,7 +608,7 @@ } catch(ex) { - test(!(ex instanceof TestFailureException)); + test(!(ex instanceof TestError), ex); } try @@ -612,7 +617,7 @@ } catch(ex) { - test(false); + test(false, ex); } try @@ -621,7 +626,7 @@ } catch(ex) { - test(false); + test(false, ex); } try @@ -631,7 +636,7 @@ } catch(ex) { - test(!(ex instanceof TestFailureException)); + test(!(ex instanceof TestError), ex); } out.writeLine("ok"); @@ -765,7 +770,7 @@ } catch(ex) { - test(ex instanceof Ice.UnsupportedEncodingException); + test(ex instanceof Ice.UnsupportedEncodingException, ex); } let ref10 = "test -e 1.0:default -p 12010"; @@ -795,7 +800,7 @@ catch(ex) { // Server 2.0 proxy doesn't support 1.0 version. - test(ex instanceof Ice.UnsupportedProtocolException); + test(ex instanceof Ice.UnsupportedProtocolException, ex); } ref10 = "test -p 1.0:default -p 12010"; @@ -819,7 +824,7 @@ } catch(ex) { - test(ex instanceof Ice.EndpointParseException); + test(ex instanceof Ice.EndpointParseException, ex); } try @@ -830,7 +835,7 @@ } catch(ex) { - test(ex instanceof Ice.EndpointParseException); + test(ex instanceof Ice.EndpointParseException, ex); } try @@ -841,7 +846,7 @@ } catch(ex) { - test(ex instanceof Ice.EndpointParseException); + test(ex instanceof Ice.EndpointParseException, ex); } try @@ -852,7 +857,7 @@ } catch(ex) { - test(ex instanceof Ice.EndpointParseException); + test(ex instanceof Ice.EndpointParseException, ex); } try @@ -863,7 +868,7 @@ } catch(ex) { - test(ex instanceof Ice.EndpointParseException); + test(ex instanceof Ice.EndpointParseException, ex); } try @@ -874,7 +879,7 @@ } catch(ex) { - test(ex instanceof Ice.EndpointParseException); + test(ex instanceof Ice.EndpointParseException, ex); } try @@ -885,7 +890,7 @@ } catch(ex) { - test(ex instanceof Ice.EndpointParseException); + test(ex instanceof Ice.EndpointParseException, ex); } try @@ -896,7 +901,7 @@ } catch(ex) { - test(ex instanceof Ice.EndpointParseException); + test(ex instanceof Ice.EndpointParseException, ex); } try @@ -907,7 +912,7 @@ } catch(ex) { - test(ex instanceof Ice.EndpointParseException); + test(ex instanceof Ice.EndpointParseException, ex); } try @@ -918,7 +923,7 @@ } catch(ex) { - test(ex instanceof Ice.EndpointParseException); + test(ex instanceof Ice.EndpointParseException, ex); } try @@ -929,7 +934,7 @@ } catch(ex) { - test(ex instanceof Ice.EndpointParseException); + test(ex instanceof Ice.EndpointParseException, ex); } // Legal TCP endpoint expressed as opaque endpoint diff --git a/js/test/Ice/retry/Client.js b/js/test/Ice/retry/Client.js index 06f15ccc550..6a399016e20 100644 --- a/js/test/Ice/retry/Client.js +++ b/js/test/Ice/retry/Client.js @@ -14,11 +14,16 @@ async function allTests(out, communicator, communicator2) { - function test(value) + function test(value, ex) { if(!value) { - throw new Error("test failed"); + let message = "test failed"; + if(ex) + { + message += "\n" + ex.toString(); + } + throw new Error(message); } } @@ -53,11 +58,11 @@ { if(typeof(window) === 'undefined' && typeof(WorkerGlobalScope) === 'undefined') // Nodejs { - test(ex instanceof Ice.ConnectionLostException); + test(ex instanceof Ice.ConnectionLostException, ex); } else // Browser { - test(ex instanceof Ice.SocketException); + test(ex instanceof Ice.SocketException, ex); } out.writeLine("ok"); } @@ -79,7 +84,7 @@ } catch(ex) { - test(ex instanceof Ice.LocalException); + test(ex instanceof Ice.LocalException, ex); } out.writeLine("ok"); @@ -92,7 +97,7 @@ } catch(ex) { - test(ex instanceof Ice.InvocationTimeoutException); + test(ex instanceof Ice.InvocationTimeoutException, ex); } await retry2.opIdempotent(-1); diff --git a/js/test/Ice/servantLocator/Client.js b/js/test/Ice/servantLocator/Client.js index 82b0af5eb07..6029060dc85 100644 --- a/js/test/Ice/servantLocator/Client.js +++ b/js/test/Ice/servantLocator/Client.js @@ -14,11 +14,16 @@ async function allTests(communicator, out) { - function test(value) + function test(value, ex) { if(!value) { - throw new Error("test failed"); + let message = "test failed"; + if(ex) + { + message += "\n" + ex.toString(); + } + throw new Error(message); } } @@ -31,7 +36,7 @@ } catch(ex) { - test(ex instanceof Ice.ObjectNotExistException); + test(ex instanceof Ice.ObjectNotExistException, ex); test(ex.id.equals(obj.ice_getIdentity())); test(ex.facet == obj.ice_getFacet()); test(ex.operation == "requestFailedException"); @@ -44,7 +49,7 @@ } catch(ex) { - test(ex instanceof Ice.UnknownUserException); + test(ex instanceof Ice.UnknownUserException, ex); test(ex.unknown == "reason"); } @@ -55,7 +60,7 @@ } catch(ex) { - test(ex instanceof Ice.UnknownLocalException); + test(ex instanceof Ice.UnknownLocalException, ex); test(ex.unknown == "reason"); } @@ -66,7 +71,7 @@ } catch(ex) { - test(ex instanceof Ice.UnknownException); + test(ex instanceof Ice.UnknownException, ex); test(ex.unknown == "reason"); } @@ -79,7 +84,7 @@ { test((ex instanceof Ice.OperationNotExistException) || (ex instanceof Ice.UnknownUserException && - ex.unknown == "::Test::TestIntfUserException")); + ex.unknown == "::Test::TestIntfUserException"), ex); } try @@ -89,7 +94,7 @@ } catch(ex) { - test(ex instanceof Ice.UnknownLocalException); + test(ex instanceof Ice.UnknownLocalException, ex); test(ex.unknown.indexOf("Ice::SocketException") >= 0 || ex.unknown.indexOf("Ice.SocketException") >= 0); } @@ -102,7 +107,7 @@ catch(ex) { test((ex instanceof Ice.OperationNotExistException) || - (ex instanceof Ice.UnknownException || ex.unknown.indexOf("") >= 0)); + (ex instanceof Ice.UnknownException || ex.unknown.indexOf("") >= 0), ex); } try @@ -112,7 +117,7 @@ } catch(ex) { - test(ex instanceof Ice.UnknownException); + test(ex instanceof Ice.UnknownException, ex); test(ex.unknown == "reason"); } @@ -123,7 +128,7 @@ } catch(ex) { - test(ex instanceof Ice.UnknownUserException); + test(ex instanceof Ice.UnknownUserException, ex); } try @@ -133,7 +138,7 @@ } catch(ex) { - test(ex instanceof Ice.UnknownUserException); + test(ex instanceof Ice.UnknownUserException, ex); } try @@ -143,7 +148,7 @@ } catch(ex) { - test(ex instanceof Test.TestImpossibleException); + test(ex instanceof Test.TestImpossibleException, ex); } try @@ -153,7 +158,7 @@ } catch(ex) { - test(ex instanceof Test.TestImpossibleException); + test(ex instanceof Test.TestImpossibleException, ex); } } @@ -178,7 +183,7 @@ } catch(ex) { - test(ex instanceof Ice.UnknownUserException && ex.unknown == "::Test::TestIntfUserException") + test(ex instanceof Ice.UnknownUserException && ex.unknown == "::Test::TestIntfUserException", ex) } try @@ -189,7 +194,7 @@ } catch(ex) { - test(ex instanceof Ice.UnknownUserException && ex.unknown == "::Test::TestIntfUserException"); + test(ex instanceof Ice.UnknownUserException && ex.unknown == "::Test::TestIntfUserException", ex); } out.writeLine("ok"); @@ -204,7 +209,7 @@ } catch(ex) { - test(ex instanceof Ice.ObjectNotExistException); + test(ex instanceof Ice.ObjectNotExistException, ex); } out.writeLine("ok"); @@ -220,7 +225,7 @@ } catch(ex) { - test(ex instanceof Ice.ObjectNotExistException); + test(ex instanceof Ice.ObjectNotExistException, ex); } try @@ -230,7 +235,7 @@ } catch(ex) { - test(ex instanceof Ice.ObjectNotExistException); + test(ex instanceof Ice.ObjectNotExistException, ex); } out.writeLine("ok"); @@ -255,7 +260,7 @@ } catch(ex) { - test(ex instanceof Test.TestImpossibleException); // Called by finished(). + test(ex instanceof Test.TestImpossibleException, ex); // Called by finished(). } try @@ -265,7 +270,7 @@ } catch(ex) { - test(ex instanceof Test.TestImpossibleException); // Called by finished(). + test(ex instanceof Test.TestImpossibleException, ex); // Called by finished(). } out.writeLine("ok"); @@ -280,7 +285,7 @@ } catch(ex) { - test(ex instanceof Ice.ObjectNotExistException); + test(ex instanceof Ice.ObjectNotExistException, ex); } out.writeLine("ok"); diff --git a/js/test/Ice/servantLocator/ServantLocatorI.js b/js/test/Ice/servantLocator/ServantLocatorI.js index 755ec486205..827db4c0fdc 100644 --- a/js/test/Ice/servantLocator/ServantLocatorI.js +++ b/js/test/Ice/servantLocator/ServantLocatorI.js @@ -62,7 +62,7 @@ // // Ensure locate() is only called once per request. // - //test(this._requestId == -1); + test(this._requestId == -1); this._requestId = current.requestId; cookie.value = new CookieI(); return new TestI(); diff --git a/js/test/Ice/slicing/exceptions/Client.js b/js/test/Ice/slicing/exceptions/Client.js index b96993e0c19..ad845abe298 100644 --- a/js/test/Ice/slicing/exceptions/Client.js +++ b/js/test/Ice/slicing/exceptions/Client.js @@ -15,11 +15,16 @@ async function allTests(out, communicator) { - function test(value) + function test(value, ex) { if(!value) { - throw new Error("test failed"); + let message = "test failed"; + if(ex) + { + message += "\n" + ex.toString(); + } + throw new Error(message); } } @@ -43,7 +48,7 @@ } catch(ex) { - test(Object.getPrototypeOf(ex) === Test.Base.prototype); + test(ex instanceof Test.Base, ex); test(ex.b == "Base.b"); test(ex.ice_id() == "::Test::Base"); } @@ -57,7 +62,7 @@ } catch(ex) { - test(Object.getPrototypeOf(ex) === Test.Base.prototype); + test(ex instanceof Test.Base, ex); test(ex.b == "UnknownDerived.b"); test(ex.ice_id() == "::Test::Base"); } @@ -71,7 +76,7 @@ } catch(ex) { - test(Object.getPrototypeOf(ex) === Test.KnownDerived.prototype); + test(ex instanceof Test.KnownDerived, ex); test(ex.b == "KnownDerived.b"); test(ex.kd == "KnownDerived.kd"); test(ex.ice_id() == "::Test::KnownDerived"); @@ -86,7 +91,7 @@ } catch(ex) { - test(Object.getPrototypeOf(ex) === Test.KnownDerived.prototype); + test(ex instanceof Test.KnownDerived, ex); test(ex.b == "KnownDerived.b"); test(ex.kd == "KnownDerived.kd"); test(ex.ice_id() == "::Test::KnownDerived"); @@ -101,7 +106,7 @@ } catch(ex) { - test(Object.getPrototypeOf(ex) === Test.Base.prototype); + test(ex instanceof Test.Base, ex); test(ex.b == "UnknownIntermediate.b"); test(ex.ice_id() == "::Test::Base"); } @@ -115,7 +120,7 @@ } catch(ex) { - test(Object.getPrototypeOf(ex) === Test.KnownIntermediate.prototype); + test(ex instanceof Test.KnownIntermediate, ex); test(ex.b == "KnownIntermediate.b"); test(ex.ki == "KnownIntermediate.ki"); test(ex.ice_id() == "::Test::KnownIntermediate"); @@ -130,7 +135,7 @@ } catch(ex) { - test(Object.getPrototypeOf(ex) === Test.KnownMostDerived.prototype); + test(ex instanceof Test.KnownMostDerived, ex); test(ex.b == "KnownMostDerived.b"); test(ex.ki == "KnownMostDerived.ki"); test(ex.kmd == "KnownMostDerived.kmd"); @@ -146,7 +151,7 @@ } catch(ex) { - test(Object.getPrototypeOf(ex) === Test.KnownIntermediate.prototype); + test(ex instanceof Test.KnownIntermediate, ex); test(ex.b == "KnownIntermediate.b"); test(ex.ki == "KnownIntermediate.ki"); test(ex.ice_id() == "::Test::KnownIntermediate"); @@ -161,7 +166,7 @@ } catch(ex) { - test(Object.getPrototypeOf(ex) === Test.KnownMostDerived.prototype); + test(ex instanceof Test.KnownMostDerived, ex); test(ex.b == "KnownMostDerived.b"); test(ex.ki == "KnownMostDerived.ki"); test(ex.kmd == "KnownMostDerived.kmd"); @@ -177,7 +182,7 @@ } catch(ex) { - test(Object.getPrototypeOf(ex) === Test.KnownMostDerived.prototype); + test(ex instanceof Test.KnownMostDerived, ex); test(ex.b == "KnownMostDerived.b"); test(ex.ki == "KnownMostDerived.ki"); test(ex.kmd == "KnownMostDerived.kmd"); @@ -193,7 +198,7 @@ } catch(ex) { - test(Object.getPrototypeOf(ex) === Test.KnownIntermediate.prototype); + test(ex instanceof Test.KnownIntermediate, ex); test(ex.b == "UnknownMostDerived1.b"); test(ex.ki == "UnknownMostDerived1.ki"); test(ex.ice_id() == "::Test::KnownIntermediate"); @@ -208,7 +213,7 @@ } catch(ex) { - test(Object.getPrototypeOf(ex) === Test.KnownIntermediate.prototype); + test(ex instanceof Test.KnownIntermediate, ex); test(ex.b == "UnknownMostDerived1.b"); test(ex.ki == "UnknownMostDerived1.ki"); test(ex.ice_id() == "::Test::KnownIntermediate"); @@ -223,7 +228,7 @@ } catch(ex) { - test(Object.getPrototypeOf(ex) === Test.Base.prototype); + test(ex instanceof Test.Base, ex); test(ex.b == "UnknownMostDerived2.b"); test(ex.ice_id() == "::Test::Base"); } @@ -237,14 +242,14 @@ } catch(ex) { - if(Object.getPrototypeOf(ex) === Test.Base.prototype) + if(ex instanceof Test.Base) { // // For the 1.0 encoding, the unknown exception is sliced to Base. // test(prx.ice_getEncodingVersion().equals(Ice.Encoding_1_0)); } - else if(Object.getPrototypeOf(ex) === Ice.UnknownUserException.prototype) + else if(ex instanceof Ice.UnknownUserException) { // // An UnknownUserException is raised for the compact format because the @@ -252,9 +257,12 @@ // test(!prx.ice_getEncodingVersion().equals(Ice.Encoding_1_0)); } + else if(ex instanceof Ice.OperationNotExistException) + { + } else { - test(false); + test(false, ex); } } out.writeLine("ok"); @@ -263,9 +271,11 @@ try { await prx.unknownPreservedAsBase(); + test(false); } catch(ex) { + test(ex instanceof Test.Base, ex); if(prx.ice_getEncodingVersion().equals(Ice.Encoding_1_0)) { test(ex.ice_getSlicedData() === null); @@ -287,6 +297,7 @@ } catch(ex) { + test(ex instanceof Test.KnownPreserved, ex); test(ex.kp == "preserved"); if(prx.ice_getEncodingVersion().equals(Ice.Encoding_1_0)) { diff --git a/js/test/Ice/slicing/objects/Client.js b/js/test/Ice/slicing/objects/Client.js index 2c7de640b3d..5ab917d31ee 100644 --- a/js/test/Ice/slicing/objects/Client.js +++ b/js/test/Ice/slicing/objects/Client.js @@ -29,11 +29,16 @@ return id === Test.Preserved.ice_staticId() ? new PreservedI() : null; } - function test(value) + function test(value, ex) { if(!value) { - throw new Error("test failed"); + let message = "test failed"; + if(ex) + { + message += "\n" + ex.toString(); + } + throw new Error(message); } } @@ -96,7 +101,7 @@ } catch(ex) { - test(ex instanceof Ice.OperationNotExistException); + test(ex instanceof Ice.OperationNotExistException, ex); } } else @@ -109,7 +114,7 @@ catch(ex) { test(ex instanceof Ice.OperationNotExistException || - ex instanceof Ice.NoValueFactoryException); + ex instanceof Ice.NoValueFactoryException, ex); } } out.writeLine("ok"); @@ -126,7 +131,7 @@ } catch(ex) { - test(ex instanceof Ice.NoValueFactoryException); + test(ex instanceof Ice.NoValueFactoryException, ex); test(prx.ice_getEncodingVersion().equals(Ice.Encoding_1_0)); } out.writeLine("ok"); @@ -527,7 +532,6 @@ out.writeLine("ok"); out.write("base exception thrown as base exception... "); - try { await prx.throwBaseAsBase(); @@ -535,7 +539,7 @@ } catch(ex) { - test(ex instanceof Test.BaseException); + test(ex instanceof Test.BaseException, ex); test(ex.ice_id() == "::Test::BaseException"); test(ex.sbe == "sbe"); test(ex.pb !== null); @@ -552,7 +556,7 @@ } catch(ex) { - test(ex instanceof Test.DerivedException); + test(ex instanceof Test.DerivedException, ex); test(ex.ice_id() == "::Test::DerivedException"); test(ex.sbe == "sbe"); test(ex.pb !== null); @@ -575,7 +579,7 @@ } catch(ex) { - test(ex instanceof Test.DerivedException); + test(ex instanceof Test.DerivedException, ex); test(ex.ice_id() == "::Test::DerivedException"); test(ex.sbe == "sbe"); test(ex.pb !== null); @@ -598,7 +602,7 @@ } catch(ex) { - test(ex instanceof Test.BaseException); + test(ex instanceof Test.BaseException, ex); test(ex.ice_id() == "::Test::BaseException"); test(ex.sbe == "sbe"); test(ex.pb !== null); diff --git a/js/test/Ice/timeout/Client.js b/js/test/Ice/timeout/Client.js index 8cf8003c028..5170789cdcc 100644 --- a/js/test/Ice/timeout/Client.js +++ b/js/test/Ice/timeout/Client.js @@ -173,7 +173,7 @@ } catch(ex) { - test(false); + test(false, ex); } while(true) @@ -185,7 +185,7 @@ } catch(ex) { - test(ex instanceof Ice.ConnectionManuallyClosedException); // Expected + test(ex instanceof Ice.ConnectionManuallyClosedException, ex); // Expected test(ex.graceful); break; } |