diff options
Diffstat (limited to 'js/test/Ice/slicing/objects/Client.js')
-rw-r--r-- | js/test/Ice/slicing/objects/Client.js | 164 |
1 files changed, 62 insertions, 102 deletions
diff --git a/js/test/Ice/slicing/objects/Client.js b/js/test/Ice/slicing/objects/Client.js index 46d44f6b37f..6e9c8d9eef4 100644 --- a/js/test/Ice/slicing/objects/Client.js +++ b/js/test/Ice/slicing/objects/Client.js @@ -16,13 +16,14 @@ var allTests = function(out, communicator) { - var PreservedI = Ice.Class(Test.Preserved, + class PreservedI extends Test.Preserved { - __init__: function() + constructor() { + super(); ++PreservedI.counter; } - }); + } function PreservedFactoryI(id) { @@ -44,7 +45,7 @@ } catch(err) { - p.fail(err); + p.reject(err); throw err; } } @@ -52,8 +53,7 @@ var failCB = function(){ test(false); }; var ref, base, prx; - Promise.try( - function() + Promise.try(() => { out.write("testing stringToProxy... "); ref = "Test:default -p 12010 -t 10000"; @@ -64,8 +64,7 @@ out.write("testing checked cast... "); return Test.TestIntfPrx.checkedCast(base); } - ).then( - function(obj) + ).then(obj => { prx = obj; test(prx !== null); @@ -74,8 +73,7 @@ out.write("base as Object... "); return prx.SBaseAsObject(); } - ).then( - function(sb) + ).then(sb => { test(sb !== null); test(sb.ice_id() == "::Test::SBase"); @@ -84,16 +82,14 @@ out.write("base as base... "); return prx.SBaseAsSBase(); } - ).then( - function(sb) + ).then(sb => { test(sb.sb == "SBase.sb"); out.writeLine("ok"); out.write("base with known derived as base... "); return prx.SBSKnownDerivedAsSBase(); } - ).then( - function(sb) + ).then(sb => { test(sb !== null); test(sb.sb == "SBSKnownDerived.sb"); @@ -102,71 +98,60 @@ out.write("base with known derived as known derived... "); return prx.SBSKnownDerivedAsSBSKnownDerived(); } - ).then( - function(sb) + ).then(sb => { test(sb.sbskd == "SBSKnownDerived.sbskd"); out.writeLine("ok"); out.write("base with unknown derived as base... "); return prx.SBSUnknownDerivedAsSBase(); } - ).then( - function(sb) + ).then(sb => { test(sb.sb == "SBSUnknownDerived.sb"); var p = new Promise(); if(prx.ice_getEncodingVersion().equals(Ice.Encoding_1_0)) { return prx.SBSUnknownDerivedAsSBaseCompact().then( - function(sb) - { - test(sb.sb == "SBSUnknownDerived.sb"); - }, - function(ex) - { - test(ex instanceof Ice.OperationNotExistException); - }); + sb => test(sb.sb == "SBSUnknownDerived.sb"), + ex => test(ex instanceof Ice.OperationNotExistException)); } else { return prx.SBSUnknownDerivedAsSBaseCompact().then( failCB, - function(ex) + ex => { test(ex instanceof Ice.OperationNotExistException || ex instanceof Ice.NoValueFactoryException); }); } } - ).then( - function() + ).then(() => { out.writeLine("ok"); out.write("unknown with Object as Object... "); return prx.SUnknownAsObject(); } ).then( - function(obj) + obj => { test(!prx.ice_getEncodingVersion().equals(Ice.Encoding_1_0)); test(obj instanceof Ice.UnknownSlicedValue); test(obj.getUnknownTypeId() == "::Test::SUnknown"); return prx.checkSUnknown(obj); }, - function(ex) + ex => { test(ex instanceof Ice.NoValueFactoryException); test(prx.ice_getEncodingVersion().equals(Ice.Encoding_1_0)); } - ).then( - function() + ).then(() => { out.writeLine("ok"); out.write("one-element cycle... "); return prx.oneElementCycle(); } - ).then( - function(b) + ).then(b => { test(b !== null); test(b.ice_id() == "::Test::B"); @@ -176,8 +161,7 @@ out.write("two-element cycle... "); return prx.twoElementCycle(); } - ).then( - function(b1) + ).then(b1 => { test(b1 !== null); test(b1.ice_id() == "::Test::B"); @@ -193,8 +177,7 @@ out.write("known derived pointer slicing as derived... "); return prx.D1AsD1(); } - ).then( - function(d1) + ).then(d1 => { test(d1 !== null); test(d1.ice_id() == "::Test::D1"); @@ -212,8 +195,7 @@ out.write("unknown derived pointer slicing as base... "); return prx.D2AsB(); } - ).then( - function(b2) + ).then(b2 => { test(b2 !== null); test(b2.ice_id() == "::Test::B"); @@ -233,9 +215,9 @@ out.write("param ptr slicing with known first... "); return prx.paramTest1(); } - ).then( - function(b1, b2) + ).then(r => { + var [b1, b2] = r; test(b1 !== null); test(b1.ice_id() == "::Test::D1"); test(b1.sb == "D1.sb"); @@ -252,9 +234,9 @@ out.write("param ptr slicing with unknown first... "); return prx.paramTest2(); } - ).then( - function(b2, b1) + ).then(r => { + var [b2, b1] = r; test(b1 !== null); test(b1.ice_id() == "::Test::D1"); test(b1.sb == "D1.sb"); @@ -271,18 +253,18 @@ out.write("return value identity with known first... "); return prx.returnTest1(); } - ).then( - function(r, p1, p2) + ).then(r => { - test(r === p1); + var [ret, p1, p2] = r; + test(ret === p1); out.writeLine("ok"); out.write("return value identity with unknown first... "); return prx.returnTest2(); } - ).then( - function(r, p1, p2) + ).then(r => { - test(r == p1); + var [ret, p1, p2] = r; + test(ret == p1); out.writeLine("ok"); out.write("return value identity for input params known first... "); @@ -297,8 +279,7 @@ d1.pb = d3; d1.pd1 = d3; - return prx.returnTest3(d1, d3).then( - function(b1) + return prx.returnTest3(d1, d3).then(b1 => { test(b1 !== null); test(b1.sb == "D1.sb"); @@ -321,8 +302,7 @@ test(b2 !== d3); }); } - ).then( - function() + ).then(() => { out.writeLine("ok"); out.write("return value identity for input params unknown first... "); @@ -338,8 +318,7 @@ d1.pb = d3; d1.pd1 = d3; - return prx.returnTest3(d3, d1).then( - function(b1) + return prx.returnTest3(d3, d1).then(b1 => { test(b1 !== null); test(b1.sb == "D3.sb"); @@ -362,16 +341,15 @@ test(b2 !== d3); }); } - ).then( - function() + ).then(() => { out.writeLine("ok"); out.write("remainder unmarshaling (3 instances)... "); return prx.paramTest3(); } - ).then( - function(ret, p1, p2) + ).then(r => { + var [ret, p1, p2] = r; test(p1 !== null); test(p1.sb == "D2.sb (p1 1)"); test(p1.pb === null); @@ -391,9 +369,9 @@ out.write("remainder unmarshaling (4 instances)... "); return prx.paramTest4(); } - ).then( - function(ret, b) + ).then(r => { + var [ret, b] = r; test(b !== null); test(b.sb == "D4.sb (1)"); test(b.pb === null); @@ -423,8 +401,7 @@ return prx.returnTest3(d3, b2); } - ).then( - function(ret) + ).then(ret => { test(ret !== null); test(ret.ice_id() == "::Test::B"); @@ -453,8 +430,7 @@ return prx.returnTest3(d3, d12); } - ).then( - function(ret) + ).then(ret => { test(ret !== null); test(ret.ice_id() == "::Test::B"); @@ -512,8 +488,7 @@ return prx.sequenceTest(ss1, ss2); } - ).then( - function(ss) + ).then(ss => { test(ss.c1 !== null); var ss1b = ss.c1.s[0]; @@ -557,9 +532,9 @@ } return prx.dictionaryTest(bin); } - ).then( - function(ret, boutH) + ).then(r => { + var [ret, boutH] = r; var i, b, s; test(boutH.size === 10); for(i = 0; i < 10; ++i) @@ -592,7 +567,7 @@ } ).then( failCB, - function(ex) + ex => { test(ex instanceof Test.BaseException); test(ex.ice_name() == "Test::BaseException"); @@ -606,7 +581,7 @@ } ).then( failCB, - function(ex) + ex => { test(ex instanceof Test.DerivedException); test(ex.ice_name() == "Test::DerivedException"); @@ -627,7 +602,7 @@ } ).then( failCB, - function(ex) + ex => { test(ex instanceof Test.DerivedException); test(ex.ice_name() == "Test::DerivedException"); @@ -648,7 +623,7 @@ } ).then( failCB, - function(ex) + ex => { test(ex instanceof Test.BaseException); test(ex.ice_name() == "Test::BaseException"); @@ -661,8 +636,7 @@ out.write("forward-declared class... "); return prx.useForward(); } - ).then( - function(f) + ).then(f => { test(f !== null); out.writeLine("ok"); @@ -688,8 +662,7 @@ return prx.exchangePBase(pd); } - ).then( - function(r) + ).then(r => { var p2 = r; test(p2.pi === 3); @@ -705,8 +678,7 @@ return prx.exchangePBase(pu); } - ).then( - function(r) + ).then(r => { test(!(r instanceof Test.PCUnknown)); test(r.pi == 3); @@ -721,8 +693,7 @@ return prx.exchangePBase(pcd); } - ).then( - function(r) + ).then(r => { if(prx.ice_getEncodingVersion().equals(Ice.Encoding_1_0)) { @@ -745,8 +716,7 @@ return prx.exchangePBase(pcd); } - ).then( - function(r) + ).then(r => { var p2; @@ -786,8 +756,7 @@ return prx.exchangePBase(pcd); } - ).then( - function(r) + ).then(r => { if(prx.ice_getEncodingVersion().equals(Ice.Encoding_1_0)) { @@ -817,30 +786,22 @@ // return prx.PBSUnknownAsPreserved(); } - ).then( - function(p) + ).then(p => { - return prx.checkPBSUnknown(p).then( - function(r) + return prx.checkPBSUnknown(p).then(r => { if(!prx.ice_getEncodingVersion().equals(Ice.Encoding_1_0)) { return prx.ice_encodingVersion(Ice.Encoding_1_0).checkPBSUnknown(p); } - } - ); + }); } - ).then( - function() + ).then(() => { out.writeLine("ok"); return prx.shutdown(); } - ).then( - function() - { - p.succeed(); - }); + ).then(p.resolve, p.reject); return p; }; @@ -850,8 +811,7 @@ function() { var c = Ice.initialize(id); - return allTests(out, c).finally( - function() + return allTests(out, c).finally(() => { if(c) { |