THRIFT-3627 fix missing basic code style consistency of JavaScript.
Client: js
This closes #858
This closes #1243
diff --git a/lib/js/test/deep-constructor.test.js b/lib/js/test/deep-constructor.test.js
index 9a19809..336fc15 100644
--- a/lib/js/test/deep-constructor.test.js
+++ b/lib/js/test/deep-constructor.test.js
@@ -1,16 +1,16 @@
function serialize(data) {
- var transport = new Thrift.Transport("/service");
- var protocol = new Thrift.Protocol(transport);
- protocol.writeMessageBegin("", 0, 0);
+ var transport = new Thrift.Transport('/service');
+ var protocol = new Thrift.Protocol(transport);
+ protocol.writeMessageBegin('', 0, 0);
data.write(protocol);
protocol.writeMessageEnd();
return transport.send_buf;
}
function deserialize(serialized, type) {
- var transport = new Thrift.Transport("/service");
+ var transport = new Thrift.Transport('/service');
transport.setRecvBuffer(serialized);
- var protocol = new Thrift.Protocol(transport);
+ var protocol = new Thrift.Protocol(transport);
protocol.readMessageBegin();
var data = new type();
data.read(protocol);
@@ -27,12 +27,12 @@
struct_list_field: [
new Simple({value: 'b'}),
- new Simple({value: 'c'}),
+ new Simple({value: 'c'})
],
struct_set_field: [
new Simple({value: 'd'}),
- new Simple({value: 'e'}),
+ new Simple({value: 'e'})
],
struct_map_field: {
@@ -75,12 +75,12 @@
struct_list_field: [
{value: 'b'},
- {value: 'c'},
+ {value: 'c'}
],
struct_set_field: [
{value: 'd'},
- {value: 'e'},
+ {value: 'e'}
],
struct_map_field: {
@@ -129,7 +129,7 @@
var cases = {
- "Serialize/deserialize simple struct should return equal object": function(assert){
+ 'Serialize/deserialize simple struct should return equal object': function(assert) {
var tObj = new Simple({value: 'a'});
var received = deserialize(serialize(tObj), Simple);
assert.ok(tObj !== received);
@@ -137,21 +137,21 @@
},
- "Serialize/deserialize should return equal object": function(assert){
+ 'Serialize/deserialize should return equal object': function(assert) {
var tObj = createThriftObj();
var received = deserialize(serialize(tObj), Complex);
assert.ok(tObj !== received);
assert.deepEqual(received, tObj);
},
- "Nested structs and containers initialized from plain js objects should serialize same as if initialized from thrift objects": function(assert) {
+ 'Nested structs and containers initialized from plain js objects should serialize same as if initialized from thrift objects': function(assert) {
var tObj1 = createThriftObj();
var tObj2 = new Complex(createJsObj());
assertValues(tObj2, assert);
assert.equal(serialize(tObj2), serialize(tObj1));
},
- "Modifications to args object should not affect constructed Thrift object": function (assert) {
+ 'Modifications to args object should not affect constructed Thrift object': function(assert) {
var args = createJsObj();
assertValues(args, assert);
@@ -174,7 +174,7 @@
assertValues(tObj, assert);
},
- "nulls are ok": function(assert) {
+ 'nulls are ok': function(assert) {
var tObj = new Complex({
struct_field: null,
struct_list_field: null,
diff --git a/lib/js/test/phantom-client.js b/lib/js/test/phantom-client.js
index f75b256..d517e71 100644
--- a/lib/js/test/phantom-client.js
+++ b/lib/js/test/phantom-client.js
@@ -44,10 +44,10 @@
var parseArgs = function(args) {
var skips = [
'--transport=http',
- '--protocol=json',
+ '--protocol=json'
];
var opts = {
- port: '9090',
+ port: '9090'
// protocol: 'json',
};
var keys = {};
@@ -90,8 +90,8 @@
var opts = parseArgs(system.args.slice(1));
var port = opts.port;
var transport = new Thrift.Transport('http://localhost:' + port + '/service');
- var protocol = new Thrift.Protocol(transport);
- var client = new ThriftTest.ThriftTestClient(protocol);
+ var protocol = new Thrift.Protocol(transport);
+ var client = new ThriftTest.ThriftTestClient(protocol);
// TODO: Remove duplicate code with test.js.
@@ -110,17 +110,17 @@
}
}
- test("Void", function() {
+ test('Void', function() {
equal(client.testVoid(), undefined);
});
- test("Binary (String)", function() {
+ test('Binary (String)', function() {
var binary = '';
for (var v = 255; v >= 0; --v) {
binary += String.fromCharCode(v);
}
equal(client.testBinary(binary), binary);
});
- test("Binary (Uint8Array)", function() {
+ test('Binary (Uint8Array)', function() {
var binary = '';
for (var v = 255; v >= 0; --v) {
binary += String.fromCharCode(v);
@@ -131,7 +131,7 @@
}
equal(client.testBinary(arr), binary);
});
- test("String", function() {
+ test('String', function() {
equal(client.testString(''), '');
equal(client.testString(stringTest), stringTest);
@@ -140,41 +140,41 @@
' backspace: \b formfeed: \f newline: \n return: \r tab: ' +
' now-all-of-them-together: "\\\/\b\n\r\t' +
' now-a-bunch-of-junk: !@#$%&()(&%$#{}{}<><><';
- equal(client.testString(specialCharacters),specialCharacters);
+ equal(client.testString(specialCharacters), specialCharacters);
});
- test("Double", function() {
+ test('Double', function() {
equal(client.testDouble(0), 0);
equal(client.testDouble(-1), -1);
equal(client.testDouble(3.14), 3.14);
- equal(client.testDouble(Math.pow(2,60)), Math.pow(2,60));
+ equal(client.testDouble(Math.pow(2, 60)), Math.pow(2, 60));
});
- test("Bool", function() {
+ test('Bool', function() {
equal(client.testBool(true), true);
equal(client.testBool(false), false);
});
- test("I8", function() {
+ test('I8', function() {
equal(client.testByte(0), 0);
equal(client.testByte(0x01), 0x01);
});
- test("I32", function() {
+ test('I32', function() {
equal(client.testI32(0), 0);
- equal(client.testI32(Math.pow(2,30)), Math.pow(2,30));
- equal(client.testI32(-Math.pow(2,30)), -Math.pow(2,30));
+ equal(client.testI32(Math.pow(2, 30)), Math.pow(2, 30));
+ equal(client.testI32(-Math.pow(2, 30)), -Math.pow(2, 30));
});
- test("I64", function() {
+ test('I64', function() {
equal(client.testI64(0), 0);
//This is usually 2^60 but JS cannot represent anything over 2^52 accurately
- equal(client.testI64(Math.pow(2,52)), Math.pow(2,52));
- equal(client.testI64(-Math.pow(2,52)), -Math.pow(2,52));
+ equal(client.testI64(Math.pow(2, 52)), Math.pow(2, 52));
+ equal(client.testI64(-Math.pow(2, 52)), -Math.pow(2, 52));
});
- test("Struct", function() {
+ test('Struct', function() {
var structTestInput = new ThriftTest.Xtruct();
structTestInput.string_thing = 'worked';
structTestInput.byte_thing = 0x01;
- structTestInput.i32_thing = Math.pow(2,30);
+ structTestInput.i32_thing = Math.pow(2, 30);
//This is usually 2^60 but JS cannot represent anything over 2^52 accurately
- structTestInput.i64_thing = Math.pow(2,52);
+ structTestInput.i64_thing = Math.pow(2, 52);
var structTestOutput = client.testStruct(structTestInput);
@@ -186,18 +186,18 @@
equal(JSON.stringify(structTestOutput), JSON.stringify(structTestInput));
});
- test("Nest", function() {
+ test('Nest', function() {
var xtrTestInput = new ThriftTest.Xtruct();
xtrTestInput.string_thing = 'worked';
xtrTestInput.byte_thing = 0x01;
- xtrTestInput.i32_thing = Math.pow(2,30);
+ xtrTestInput.i32_thing = Math.pow(2, 30);
//This is usually 2^60 but JS cannot represent anything over 2^52 accurately
- xtrTestInput.i64_thing = Math.pow(2,52);
+ xtrTestInput.i64_thing = Math.pow(2, 52);
var nestTestInput = new ThriftTest.Xtruct2();
nestTestInput.byte_thing = 0x02;
nestTestInput.struct_thing = xtrTestInput;
- nestTestInput.i32_thing = Math.pow(2,15);
+ nestTestInput.i32_thing = Math.pow(2, 15);
var nestTestOutput = client.testNest(nestTestInput);
@@ -211,8 +211,8 @@
equal(JSON.stringify(nestTestOutput), JSON.stringify(nestTestInput));
});
- test("Map", function() {
- var mapTestInput = {7:77, 8:88, 9:99};
+ test('Map', function() {
+ var mapTestInput = {7: 77, 8: 88, 9: 99};
var mapTestOutput = client.testMap(mapTestInput);
@@ -221,10 +221,10 @@
}
});
- test("StringMap", function() {
+ test('StringMap', function() {
var mapTestInput = {
- "a":"123", "a b":"with spaces ", "same":"same", "0":"numeric key",
- "longValue":stringTest, stringTest:"long key"
+ 'a': '123', 'a b': 'with spaces ', 'same': 'same', '0': 'numeric key',
+ 'longValue': stringTest, stringTest: 'long key'
};
var mapTestOutput = client.testStringMap(mapTestInput);
@@ -234,30 +234,30 @@
}
});
- test("Set", function() {
- var setTestInput = [1,2,3];
+ test('Set', function() {
+ var setTestInput = [1, 2, 3];
ok(client.testSet(setTestInput), setTestInput);
});
- test("List", function() {
- var listTestInput = [1,2,3];
+ test('List', function() {
+ var listTestInput = [1, 2, 3];
ok(client.testList(listTestInput), listTestInput);
});
- test("Enum", function() {
+ test('Enum', function() {
equal(client.testEnum(ThriftTest.Numberz.ONE), ThriftTest.Numberz.ONE);
});
- test("TypeDef", function() {
+ test('TypeDef', function() {
equal(client.testTypedef(69), 69);
});
- test("Skip", function() {
+ test('Skip', function() {
var structTestInput = new ThriftTest.Xtruct();
var modifiedClient = new ThriftTest.ThriftTestClient(protocol);
modifiedClient.recv_testStruct = function() {
- var input = modifiedClient.input;
+ var input = modifiedClient.input;
var xtruct3 = new ThriftTest.Xtruct3();
input.readMessageBegin();
@@ -278,9 +278,9 @@
};
structTestInput.string_thing = 'worked';
- structTestInput.byte_thing = 0x01;
- structTestInput.i32_thing = Math.pow(2,30);
- structTestInput.i64_thing = Math.pow(2,52);
+ structTestInput.byte_thing = 0x01;
+ structTestInput.i32_thing = Math.pow(2, 30);
+ structTestInput.i64_thing = Math.pow(2, 52);
var structTestOutput = modifiedClient.testStruct(structTestInput);
@@ -291,10 +291,10 @@
equal(structTestOutput.i64_thing, structTestInput.i64_thing);
});
- test("MapMap", function() {
+ test('MapMap', function() {
var mapMapTestExpectedResult = {
- "4":{"1":1,"2":2,"3":3,"4":4},
- "-4":{"-4":-4, "-3":-3, "-2":-2, "-1":-1}
+ '4': {'1': 1, '2': 2, '3': 3, '4': 4},
+ '-4': {'-4': -4, '-3': -3, '-2': -2, '-1': -1}
};
var mapMapTestOutput = client.testMapMap(1);
@@ -309,55 +309,55 @@
checkRecursively(mapMapTestOutput, mapMapTestExpectedResult);
});
- test("Xception", function() {
+ test('Xception', function() {
try {
- client.testException("Xception");
+ client.testException('Xception');
ok(false);
} catch (e) {
equal(e.errorCode, 1001);
- equal(e.message, "Xception");
+ equal(e.message, 'Xception');
}
});
- test("no Exception", function() {
+ test('no Exception', function() {
try {
- client.testException("no Exception");
+ client.testException('no Exception');
} catch (e) {
ok(false);
}
});
- test("TException", function() {
+ test('TException', function() {
try {
- client.testException("TException");
+ client.testException('TException');
ok(false);
- } catch(e) {
+ } catch (e) {
ok(ok);
}
});
var crazy = {
- "userMap":{ "5":5, "8":8 },
- "xtructs":[{
- "string_thing":"Goodbye4",
- "byte_thing":4,
- "i32_thing":4,
- "i64_thing":4
+ 'userMap': { '5': 5, '8': 8 },
+ 'xtructs': [{
+ 'string_thing': 'Goodbye4',
+ 'byte_thing': 4,
+ 'i32_thing': 4,
+ 'i64_thing': 4
},
{
- "string_thing":"Hello2",
- "byte_thing":2,
- "i32_thing":2,
- "i64_thing":2
+ 'string_thing': 'Hello2',
+ 'byte_thing': 2,
+ 'i32_thing': 2,
+ 'i64_thing': 2
}]
};
- test("Insanity", function() {
+ test('Insanity', function() {
var insanity = {
- "1":{
- "2":crazy,
- "3":crazy
+ '1': {
+ '2': crazy,
+ '3': crazy
},
- "2":{ "6":{ "userMap":null, "xtructs":null } }
+ '2': { '6': { 'userMap': null, 'xtructs': null } }
};
var res = client.testInsanity(new ThriftTest.Insanity(crazy));
ok(res, JSON.stringify(res));
diff --git a/lib/js/test/phantomjs-qunit.js b/lib/js/test/phantomjs-qunit.js
index a840db6..c1d7a5b 100755
--- a/lib/js/test/phantomjs-qunit.js
+++ b/lib/js/test/phantomjs-qunit.js
@@ -28,18 +28,18 @@
start = new Date().getTime(),
condition = false,
interval = setInterval(function() {
- if ( (new Date().getTime() - start < maxtimeOutMillis) && !condition ) {
+ if ((new Date().getTime() - start < maxtimeOutMillis) && !condition) {
// If not time-out yet and condition not yet fulfilled
- condition = (typeof(testFx) === "string" ? eval(testFx) : testFx()); //< defensive code
+ condition = (typeof(testFx) === 'string' ? eval(testFx) : testFx()); //< defensive code
} else {
- if(!condition) {
+ if (!condition) {
// If condition still not fulfilled (timeout but condition is 'false')
console.log("'waitFor()' timeout");
phantom.exit(1);
} else {
// Condition fulfilled (timeout and/or condition is 'true')
- console.log("'waitFor()' finished in " + (new Date().getTime() - start) + "ms.");
- if (typeof(onReady) === "string") {
+ console.log("'waitFor()' finished in " + (new Date().getTime() - start) + 'ms.');
+ if (typeof(onReady) === 'string') {
eval(onReady);
} else {
onReady(); //< Do what it's supposed to do once the condition is fulfilled
@@ -63,21 +63,21 @@
console.log(msg);
};
-page.open(system.args[1], function(status){
- if (status !== "success") {
- console.log("Unable to access network");
+page.open(system.args[1], function(status) {
+ if (status !== 'success') {
+ console.log('Unable to access network');
phantom.exit(1);
} else {
- waitFor(function(){
- return page.evaluate(function(){
+ waitFor(function() {
+ return page.evaluate(function() {
var el = document.getElementById('qunit-testresult');
if (el && el.innerText.match('completed')) {
return true;
}
return false;
});
- }, function(){
- var failedNum = page.evaluate(function(){
+ }, function() {
+ var failedNum = page.evaluate(function() {
var el = document.getElementById('qunit-testresult');
console.log(el.innerText);
try {
diff --git a/lib/js/test/server_http.js b/lib/js/test/server_http.js
index e195e80..1115474 100644
--- a/lib/js/test/server_http.js
+++ b/lib/js/test/server_http.js
@@ -18,11 +18,11 @@
*/
//This HTTP server is designed to serve the test.html browser
-// based JavaScript test page (which must be in the current directory).
+// based JavaScript test page (which must be in the current directory).
// This server also supplies the Thrift based test service, which depends
// on the standard ThriftTest.thrift IDL service (which must be compiled
// for Node and browser based JavaScript in ./gen-nodejs and ./gen-js
-// respectively).
+// respectively).
var thrift = require('../../nodejs/lib/thrift');
var ThriftTestSvc = require('./gen-nodejs/ThriftTest.js');
@@ -36,14 +36,14 @@
};
var ThriftWebServerOptions = {
- files: ".",
+ files: '.',
services: {
- "/service": ThriftTestSvcOpt
+ '/service': ThriftTestSvcOpt
}
};
var server = thrift.createWebServer(ThriftWebServerOptions);
var port = 8088;
server.listen(port);
-console.log("Serving files from: " + __dirname);
-console.log("Http/Thrift Server running on port: " + port);
+console.log('Serving files from: ' + __dirname);
+console.log('Http/Thrift Server running on port: ' + port);
diff --git a/lib/js/test/server_https.js b/lib/js/test/server_https.js
index af1745b..7e78d9e 100644
--- a/lib/js/test/server_https.js
+++ b/lib/js/test/server_https.js
@@ -18,7 +18,7 @@
*/
//This HTTP server is designed to server the test.html browser
-// based JavaScript test page (which must be in the current directory).
+// based JavaScript test page (which must be in the current directory).
// This server also supplies the Thrift based test service, which depends
// on the standard ThriftTest.thrift IDL service (which must be compiled
// for Node and browser based JavaScript in ./gen-nodejs and ./gen-js
@@ -26,7 +26,7 @@
// support libraries for test.html (jquery.js, qunit.js and qunit.css
// in ./build/js/lib).
-var fs = require("fs");
+var fs = require('fs');
var thrift = require('../../nodejs/lib/thrift');
var ThriftTestSvc = require('./gen-nodejs/ThriftTest.js');
var ThriftTestHandler = require('./test_handler').ThriftTestHandler;
@@ -40,18 +40,18 @@
};
var ThriftWebServerOptions = {
- files: ".",
+ files: '.',
tls: {
- key: fs.readFileSync("../../../test/keys/server.key"),
- cert: fs.readFileSync("../../../test/keys/server.crt")
- },
+ key: fs.readFileSync('../../../test/keys/server.key'),
+ cert: fs.readFileSync('../../../test/keys/server.crt')
+ },
services: {
- "/service": ThriftTestSvcOpt
+ '/service': ThriftTestSvcOpt
}
};
var server = thrift.createWebServer(ThriftWebServerOptions);
var port = 8089;
server.listen(port);
-console.log("Serving files from: " + __dirname);
-console.log("Http/Thrift Server running on port: " + port);
+console.log('Serving files from: ' + __dirname);
+console.log('Http/Thrift Server running on port: ' + port);
diff --git a/lib/js/test/test-async.js b/lib/js/test/test-async.js
index 336e2bc..b56f2a2 100644
--- a/lib/js/test/test-async.js
+++ b/lib/js/test/test-async.js
@@ -17,9 +17,9 @@
* under the License.
*/
/* jshint -W100 */
-
+
/*
- * Fully Async JavaScript test suite for ThriftTest.thrift.
+ * Fully Async JavaScript test suite for ThriftTest.thrift.
* These tests are designed to exercise the WebSocket transport
* (which is exclusively async).
*
@@ -31,7 +31,7 @@
// all Languages in UTF-8
var stringTest = "Afrikaans, Alemannisch, Aragonés, العربية, مصرى, Asturianu, Aymar aru, Azərbaycan, Башҡорт, Boarisch, Žemaitėška, Беларуская, Беларуская (тарашкевіца), Български, Bamanankan, বাংলা, Brezhoneg, Bosanski, Català, Mìng-dĕ̤ng-ngṳ̄, Нохчийн, Cebuano, ᏣᎳᎩ, Česky, Словѣ́ньскъ / ⰔⰎⰑⰂⰡⰐⰠⰔⰍⰟ, Чӑвашла, Cymraeg, Dansk, Zazaki, ދިވެހިބަސް, Ελληνικά, Emiliàn e rumagnòl, English, Esperanto, Español, Eesti, Euskara, فارسی, Suomi, Võro, Føroyskt, Français, Arpetan, Furlan, Frysk, Gaeilge, 贛語, Gàidhlig, Galego, Avañe'ẽ, ગુજરાતી, Gaelg, עברית, हिन्दी, Fiji Hindi, Hrvatski, Kreyòl ayisyen, Magyar, Հայերեն, Interlingua, Bahasa Indonesia, Ilokano, Ido, Íslenska, Italiano, 日本語, Lojban, Basa Jawa, ქართული, Kongo, Kalaallisut, ಕನ್ನಡ, 한국어, Къарачай-Малкъар, Ripoarisch, Kurdî, Коми, Kernewek, Кыргызча, Latina, Ladino, Lëtzebuergesch, Limburgs, Lingála, ລາວ, Lietuvių, Latviešu, Basa Banyumasan, Malagasy, Македонски, മലയാളം, मराठी, Bahasa Melayu, مازِرونی, Nnapulitano, Nedersaksisch, नेपाल भाषा, Nederlands, Norsk (nynorsk), Norsk (bokmål), Nouormand, Diné bizaad, Occitan, Иронау, Papiamentu, Deitsch, Norfuk / Pitkern, Polski, پنجابی, پښتو, Português, Runa Simi, Rumantsch, Romani, Română, Русский, Саха тыла, Sardu, Sicilianu, Scots, Sámegiella, Simple English, Slovenčina, Slovenščina, Српски / Srpski, Seeltersk, Svenska, Kiswahili, தமிழ், తెలుగు, Тоҷикӣ, ไทย, Türkmençe, Tagalog, Türkçe, Татарча/Tatarça, Українська, اردو, Tiếng Việt, Volapük, Walon, Winaray, 吴语, isiXhosa, ייִדיש, Yorùbá, Zeêuws, 中文, Bân-lâm-gú, 粵語";
-
+
function checkRecursively(map1, map2) {
if (typeof map1 !== 'function' && typeof map2 !== 'function') {
if (!map1 || typeof map1 !== 'object') {
@@ -44,25 +44,25 @@
}
}
-module("Base Types");
+module('Base Types');
- asyncTest("Void", function() {
- expect( 1 );
+ asyncTest('Void', function() {
+ expect(1);
client.testVoid(function(result) {
equal(result, undefined);
QUnit.start();
});
});
-
-
- asyncTest("String", function() {
- expect( 3 );
+
+
+ asyncTest('String', function() {
+ expect(3);
QUnit.stop(2);
- client.testString('', function(result){
+ client.testString('', function(result) {
equal(result, '');
QUnit.start();
});
- client.testString(stringTest, function(result){
+ client.testString(stringTest, function(result) {
equal(result, stringTest);
QUnit.start();
});
@@ -72,34 +72,34 @@
' backspace: \b formfeed: \f newline: \n return: \r tab: ' +
' now-all-of-them-together: "\\\/\b\n\r\t' +
' now-a-bunch-of-junk: !@#$%&()(&%$#{}{}<><><';
- client.testString(specialCharacters, function(result){
+ client.testString(specialCharacters, function(result) {
equal(result, specialCharacters);
QUnit.start();
});
});
- asyncTest("Double", function() {
- expect( 4 );
+ asyncTest('Double', function() {
+ expect(4);
QUnit.stop(3);
- client.testDouble(0, function(result){
+ client.testDouble(0, function(result) {
equal(result, 0);
QUnit.start();
});
- client.testDouble(-1, function(result){
+ client.testDouble(-1, function(result) {
equal(result, -1);
QUnit.start();
});
- client.testDouble(3.14, function(result){
+ client.testDouble(3.14, function(result) {
equal(result, 3.14);
QUnit.start();
});
- client.testDouble(Math.pow(2,60), function(result){
- equal(result, Math.pow(2,60));
+ client.testDouble(Math.pow(2, 60), function(result) {
+ equal(result, Math.pow(2, 60));
QUnit.start();
});
});
- // TODO: add testBinary()
- asyncTest("Byte", function() {
- expect( 2 );
+ // TODO: add testBinary()
+ asyncTest('Byte', function() {
+ expect(2);
QUnit.stop();
client.testByte(0, function(result) {
equal(result, 0);
@@ -110,110 +110,95 @@
QUnit.start();
});
});
- asyncTest("I32", function() {
- expect( 3 );
+ asyncTest('I32', function() {
+ expect(3);
QUnit.stop(2);
- client.testI32(0, function(result){
+ client.testI32(0, function(result) {
equal(result, 0);
QUnit.start();
});
- client.testI32(Math.pow(2,30), function(result){
- equal(result, Math.pow(2,30));
+ client.testI32(Math.pow(2, 30), function(result) {
+ equal(result, Math.pow(2, 30));
QUnit.start();
});
- client.testI32(-Math.pow(2,30), function(result){
- equal(result, -Math.pow(2,30));
+ client.testI32(-Math.pow(2, 30), function(result) {
+ equal(result, -Math.pow(2, 30));
QUnit.start();
});
});
- asyncTest("I64", function() {
- expect( 3 );
+ asyncTest('I64', function() {
+ expect(3);
QUnit.stop(2);
- client.testI64(0, function(result){
+ client.testI64(0, function(result) {
equal(result, 0);
QUnit.start();
});
//This is usually 2^60 but JS cannot represent anything over 2^52 accurately
- client.testI64(Math.pow(2,52), function(result){
- equal(result, Math.pow(2,52));
+ client.testI64(Math.pow(2, 52), function(result) {
+ equal(result, Math.pow(2, 52));
QUnit.start();
});
- client.testI64(-Math.pow(2,52), function(result){
- equal(result, -Math.pow(2,52));
+ client.testI64(-Math.pow(2, 52), function(result) {
+ equal(result, -Math.pow(2, 52));
QUnit.start();
});
});
-
-
-module("Structured Types");
- asyncTest("Struct", function() {
- expect( 5 );
+
+module('Structured Types');
+
+ asyncTest('Struct', function() {
+ expect(5);
var structTestInput = new ThriftTest.Xtruct();
structTestInput.string_thing = 'worked';
structTestInput.byte_thing = 0x01;
- structTestInput.i32_thing = Math.pow(2,30);
+ structTestInput.i32_thing = Math.pow(2, 30);
//This is usually 2^60 but JS cannot represent anything over 2^52 accurately
- structTestInput.i64_thing = Math.pow(2,52);
+ structTestInput.i64_thing = Math.pow(2, 52);
- client.testStruct(structTestInput, function(result){
+ client.testStruct(structTestInput, function(result) {
equal(result.string_thing, structTestInput.string_thing);
equal(result.byte_thing, structTestInput.byte_thing);
equal(result.i32_thing, structTestInput.i32_thing);
equal(result.i64_thing, structTestInput.i64_thing);
equal(JSON.stringify(result), JSON.stringify(structTestInput));
- QUnit.start();
+ QUnit.start();
});
});
- asyncTest("Nest", function() {
- expect( 7 );
+ asyncTest('Nest', function() {
+ expect(7);
var xtrTestInput = new ThriftTest.Xtruct();
xtrTestInput.string_thing = 'worked';
xtrTestInput.byte_thing = 0x01;
- xtrTestInput.i32_thing = Math.pow(2,30);
+ xtrTestInput.i32_thing = Math.pow(2, 30);
//This is usually 2^60 but JS cannot represent anything over 2^52 accurately
- xtrTestInput.i64_thing = Math.pow(2,52);
-
+ xtrTestInput.i64_thing = Math.pow(2, 52);
+
var nestTestInput = new ThriftTest.Xtruct2();
nestTestInput.byte_thing = 0x02;
nestTestInput.struct_thing = xtrTestInput;
- nestTestInput.i32_thing = Math.pow(2,15);
-
- client.testNest(nestTestInput, function(result){
+ nestTestInput.i32_thing = Math.pow(2, 15);
+
+ client.testNest(nestTestInput, function(result) {
equal(result.byte_thing, nestTestInput.byte_thing);
equal(result.struct_thing.string_thing, nestTestInput.struct_thing.string_thing);
equal(result.struct_thing.byte_thing, nestTestInput.struct_thing.byte_thing);
equal(result.struct_thing.i32_thing, nestTestInput.struct_thing.i32_thing);
equal(result.struct_thing.i64_thing, nestTestInput.struct_thing.i64_thing);
- equal(result.i32_thing, nestTestInput.i32_thing);
+ equal(result.i32_thing, nestTestInput.i32_thing);
equal(JSON.stringify(result), JSON.stringify(nestTestInput));
- QUnit.start();
+ QUnit.start();
});
});
- asyncTest("Map", function() {
- expect( 3 );
- var mapTestInput = {7:77, 8:88, 9:99};
+ asyncTest('Map', function() {
+ expect(3);
+ var mapTestInput = {7: 77, 8: 88, 9: 99};
- client.testMap(mapTestInput, function(result){
- for (var key in result) {
- equal(result[key], mapTestInput[key]);
- }
- QUnit.start();
- });
- });
-
- asyncTest("StringMap", function() {
- expect( 6 );
- var mapTestInput = {
- "a":"123", "a b":"with spaces ", "same":"same", "0":"numeric key",
- "longValue":stringTest, stringTest:"long key"
- };
-
- client.testStringMap(mapTestInput, function(result){
+ client.testMap(mapTestInput, function(result) {
for (var key in result) {
equal(result[key], mapTestInput[key]);
}
@@ -221,51 +206,66 @@
});
});
- asyncTest("Set", function() {
- expect( 1 );
- var setTestInput = [1,2,3];
- client.testSet(setTestInput, function(result){
+ asyncTest('StringMap', function() {
+ expect(6);
+ var mapTestInput = {
+ 'a': '123', 'a b': 'with spaces ', 'same': 'same', '0': 'numeric key',
+ 'longValue': stringTest, stringTest: 'long key'
+ };
+
+ client.testStringMap(mapTestInput, function(result) {
+ for (var key in result) {
+ equal(result[key], mapTestInput[key]);
+ }
+ QUnit.start();
+ });
+ });
+
+ asyncTest('Set', function() {
+ expect(1);
+ var setTestInput = [1, 2, 3];
+ client.testSet(setTestInput, function(result) {
ok(result, setTestInput);
QUnit.start();
});
});
- asyncTest("List", function() {
- expect( 1 );
- var listTestInput = [1,2,3];
- client.testList(listTestInput, function(result){
+ asyncTest('List', function() {
+ expect(1);
+ var listTestInput = [1, 2, 3];
+ client.testList(listTestInput, function(result) {
ok(result, listTestInput);
QUnit.start();
});
});
- asyncTest("Enum", function() {
- expect( 1 );
- client.testEnum(ThriftTest.Numberz.ONE, function(result){
+ asyncTest('Enum', function() {
+ expect(1);
+ client.testEnum(ThriftTest.Numberz.ONE, function(result) {
equal(result, ThriftTest.Numberz.ONE);
QUnit.start();
});
});
- asyncTest("TypeDef", function() {
- expect( 1 );
- client.testTypedef(69, function(result){
+ asyncTest('TypeDef', function() {
+ expect(1);
+ client.testTypedef(69, function(result) {
equal(result, 69);
QUnit.start();
});
});
-module("deeper!");
+module('deeper!');
- asyncTest("MapMap", function() {
- expect( 16 );
+ asyncTest('MapMap', function() {
+ expect(16);
var mapMapTestExpectedResult = {
- "4":{"1":1,"2":2,"3":3,"4":4},
- "-4":{"-4":-4, "-3":-3, "-2":-2, "-1":-1}
+ '4': {'1': 1, '2': 2, '3': 3, '4': 4},
+ '-4': {'-4': -4, '-3': -3, '-2': -2, '-1': -1}
};
- client.testMapMap(1, function(result){
+ client.testMapMap(1, function(result) {
for (var key in result) {
for (var key2 in result[key]) {
equal(result[key][key2], mapMapTestExpectedResult[key][key2]);
@@ -277,67 +277,67 @@
});
-module("Exception");
+module('Exception');
- asyncTest("Xception", function() {
+ asyncTest('Xception', function() {
expect(2);
- client.testException("Xception", function(e){
+ client.testException('Xception', function(e) {
equal(e.errorCode, 1001);
- equal(e.message, "Xception");
+ equal(e.message, 'Xception');
QUnit.start();
});
});
- asyncTest("no Exception", 0, function() {
- expect( 1 );
- client.testException("no Exception", function(e){
+ asyncTest('no Exception', 0, function() {
+ expect(1);
+ client.testException('no Exception', function(e) {
ok(!e);
QUnit.start();
});
});
-module("Insanity");
+module('Insanity');
- asyncTest("testInsanity", function() {
- expect( 24 );
+ asyncTest('testInsanity', function() {
+ expect(24);
var insanity = {
- "1":{
- "2":{
- "userMap":{ "5":5, "8":8 },
- "xtructs":[{
- "string_thing":"Goodbye4",
- "byte_thing":4,
- "i32_thing":4,
- "i64_thing":4
+ '1': {
+ '2': {
+ 'userMap': { '5': 5, '8': 8 },
+ 'xtructs': [{
+ 'string_thing': 'Goodbye4',
+ 'byte_thing': 4,
+ 'i32_thing': 4,
+ 'i64_thing': 4
},
{
- "string_thing":"Hello2",
- "byte_thing":2,
- "i32_thing":2,
- "i64_thing":2
+ 'string_thing': 'Hello2',
+ 'byte_thing': 2,
+ 'i32_thing': 2,
+ 'i64_thing': 2
}
]
},
- "3":{
- "userMap":{ "5":5, "8":8 },
- "xtructs":[{
- "string_thing":"Goodbye4",
- "byte_thing":4,
- "i32_thing":4,
- "i64_thing":4
+ '3': {
+ 'userMap': { '5': 5, '8': 8 },
+ 'xtructs': [{
+ 'string_thing': 'Goodbye4',
+ 'byte_thing': 4,
+ 'i32_thing': 4,
+ 'i64_thing': 4
},
{
- "string_thing":"Hello2",
- "byte_thing":2,
- "i32_thing":2,
- "i64_thing":2
+ 'string_thing': 'Hello2',
+ 'byte_thing': 2,
+ 'i32_thing': 2,
+ 'i64_thing': 2
}
]
}
},
- "2":{ "6":{ "userMap":null, "xtructs":null } }
+ '2': { '6': { 'userMap': null, 'xtructs': null } }
};
- client.testInsanity(new ThriftTest.Insanity(), function(res){
+ client.testInsanity(new ThriftTest.Insanity(), function(res) {
ok(res, JSON.stringify(res));
ok(insanity, JSON.stringify(insanity));
checkRecursively(res, insanity);
diff --git a/lib/js/test/test-jq.js b/lib/js/test/test-jq.js
index 23ed60f..d8649a0 100644
--- a/lib/js/test/test-jq.js
+++ b/lib/js/test/test-jq.js
@@ -33,27 +33,27 @@
//////////////////////////////////
//jQuery asynchronous tests
jQuery.ajaxSetup({ timeout: 0 });
-$(document).ajaxError( function() { QUnit.start(); } );
+$(document).ajaxError(function() { QUnit.start(); });
-module("jQ Async Manual");
+module('jQ Async Manual');
- test("testI32", function() {
- expect( 2 );
+ test('testI32', function() {
+ expect(2);
QUnit.stop();
var transport = new Thrift.Transport();
- var protocol = new Thrift.Protocol(transport);
- var client = new ThriftTest.ThriftTestClient(protocol);
+ var protocol = new Thrift.Protocol(transport);
+ var client = new ThriftTest.ThriftTestClient(protocol);
var jqxhr = jQuery.ajax({
- url: "/service",
- data: client.send_testI32(Math.pow(-2,31)),
- type: "POST",
+ url: '/service',
+ data: client.send_testI32(Math.pow(-2, 31)),
+ type: 'POST',
cache: false,
- dataType: "text",
- success: function(res){
- transport.setRecvBuffer( res );
- equal(client.recv_testI32(), Math.pow(-2,31));
+ dataType: 'text',
+ success: function(res) {
+ transport.setRecvBuffer(res);
+ equal(client.recv_testI32(), Math.pow(-2, 31));
},
error: function() { ok(false); },
complete: function() {
@@ -63,25 +63,25 @@
});
});
- test("testI64", function() {
- expect( 2 );
+ test('testI64', function() {
+ expect(2);
QUnit.stop();
var transport = new Thrift.Transport();
- var protocol = new Thrift.Protocol(transport);
- var client = new ThriftTest.ThriftTestClient(protocol);
+ var protocol = new Thrift.Protocol(transport);
+ var client = new ThriftTest.ThriftTestClient(protocol);
jQuery.ajax({
- url: "/service",
+ url: '/service',
//This is usually 2^61 but JS cannot represent anything over 2^52 accurately
- data: client.send_testI64(Math.pow(-2,52)),
- type: "POST",
+ data: client.send_testI64(Math.pow(-2, 52)),
+ type: 'POST',
cache: false,
- dataType: "text",
- success: function(res){
- transport.setRecvBuffer( res );
+ dataType: 'text',
+ success: function(res) {
+ transport.setRecvBuffer(res);
//This is usually 2^61 but JS cannot represent anything over 2^52 accurately
- equal(client.recv_testI64(), Math.pow(-2,52));
+ equal(client.recv_testI64(), Math.pow(-2, 52));
},
error: function() { ok(false); },
complete: function() {
@@ -92,46 +92,46 @@
});
-module("jQ Async");
- test("I32", function() {
- expect( 3 );
+module('jQ Async');
+ test('I32', function() {
+ expect(3);
QUnit.stop();
- client.testI32(Math.pow(2,30), function(result) {
- equal(result, Math.pow(2,30));
+ client.testI32(Math.pow(2, 30), function(result) {
+ equal(result, Math.pow(2, 30));
QUnit.start();
});
QUnit.stop();
- var jqxhr = client.testI32(Math.pow(-2,31), function(result) {
- equal(result, Math.pow(-2,31));
+ var jqxhr = client.testI32(Math.pow(-2, 31), function(result) {
+ equal(result, Math.pow(-2, 31));
});
jqxhr.success(function(result) {
- equal(result, Math.pow(-2,31));
+ equal(result, Math.pow(-2, 31));
QUnit.start();
});
});
- test("I64", function() {
- expect( 4 );
+ test('I64', function() {
+ expect(4);
QUnit.stop();
//This is usually 2^60 but JS cannot represent anything over 2^52 accurately
- client.testI64(Math.pow(2,52), function(result) {
- equal(result, Math.pow(2,52));
+ client.testI64(Math.pow(2, 52), function(result) {
+ equal(result, Math.pow(2, 52));
QUnit.start();
});
QUnit.stop();
//This is usually 2^60 but JS cannot represent anything over 2^52 accurately
- client.testI64(Math.pow(-2,52), function(result) {
- equal(result, Math.pow(-2,52));
+ client.testI64(Math.pow(-2, 52), function(result) {
+ equal(result, Math.pow(-2, 52));
})
- .error( function(xhr, status, e) { ok(false, e.message); } )
+ .error(function(xhr, status, e) { ok(false, e.message); })
.success(function(result) {
//This is usually 2^60 but JS cannot represent anything over 2^52 accurately
- equal(result, Math.pow(-2,52));
+ equal(result, Math.pow(-2, 52));
})
.complete(function() {
ok(true);
@@ -139,18 +139,18 @@
});
});
- test("Xception", function() {
- expect( 2 );
+ test('Xception', function() {
+ expect(2);
QUnit.stop();
- var dfd = client.testException("Xception", function(result) {
+ var dfd = client.testException('Xception', function(result) {
ok(false);
QUnit.start();
})
- .error(function(xhr, status, e){
+ .error(function(xhr, status, e) {
equal(e.errorCode, 1001);
- equal(e.message, "Xception");
+ equal(e.message, 'Xception');
//QUnit.start();
//Note start is not required here because:
//$(document).ajaxError( function() { QUnit.start(); } );
diff --git a/lib/js/test/test-nojq.js b/lib/js/test/test-nojq.js
index 19f9e61..c4f3cf7 100644
--- a/lib/js/test/test-nojq.js
+++ b/lib/js/test/test-nojq.js
@@ -17,7 +17,7 @@
* under the License.
*/
/* jshint -W100 */
-
+
/*
* JavaScript test suite for ThriftTest.thrift. These tests
* will run only with normal "-gen js" Apache Thrift interfaces.
@@ -25,7 +25,7 @@
* $ thrift -gen js ThriftTest.thrift
*
* See also:
- * ++ test.js for generic tests
+ * ++ test.js for generic tests
* ++ test-jq.js for "-gen js:jquery" only tests
*/
@@ -33,16 +33,16 @@
//////////////////////////////////
//Async exception tests
-module("NojQ Async");
+module('NojQ Async');
- test("Xception", function() {
- expect( 2 );
+ test('Xception', function() {
+ expect(2);
QUnit.stop();
- client.testException("Xception", function(result) {
+ client.testException('Xception', function(result) {
equal(result.errorCode, 1001);
- equal(result.message, "Xception");
+ equal(result.message, 'Xception');
QUnit.start();
});
});
diff --git a/lib/js/test/test.js b/lib/js/test/test.js
index 2d8ec9b..e3b8d51 100755
--- a/lib/js/test/test.js
+++ b/lib/js/test/test.js
@@ -23,7 +23,7 @@
* will run against Normal (-gen js) and jQuery (-gen js:jquery)
* Apache Thrift interfaces.
*
- * Synchronous blocking calls should be identical in both
+ * Synchronous blocking calls should be identical in both
* Normal and jQuery interfaces. All synchronous tests belong
* here.
*
@@ -47,9 +47,9 @@
* ++ test-jq.js for "-gen js:jquery" only tests
*/
-var transport = new Thrift.Transport("/service");
-var protocol = new Thrift.Protocol(transport);
-var client = new ThriftTest.ThriftTestClient(protocol);
+var transport = new Thrift.Transport('/service');
+var protocol = new Thrift.Protocol(transport);
+var client = new ThriftTest.ThriftTestClient(protocol);
// Work around for old API used by QUnitAdapter of jsTestDriver
if (typeof QUnit.log == 'function') {
@@ -81,19 +81,19 @@
}
}
-module("Base Types");
+module('Base Types');
- test("Void", function() {
+ test('Void', function() {
equal(client.testVoid(), undefined);
});
- test("Binary (String)", function() {
+ test('Binary (String)', function() {
var binary = '';
for (var v = 255; v >= 0; --v) {
binary += String.fromCharCode(v);
}
equal(client.testBinary(binary), binary);
});
- test("Binary (Uint8Array)", function() {
+ test('Binary (Uint8Array)', function() {
var binary = '';
for (var v = 255; v >= 0; --v) {
binary += String.fromCharCode(v);
@@ -104,7 +104,7 @@
}
equal(client.testBinary(arr), binary);
});
- test("String", function() {
+ test('String', function() {
equal(client.testString(''), '');
equal(client.testString(stringTest), stringTest);
@@ -113,40 +113,40 @@
' backspace: \b formfeed: \f newline: \n return: \r tab: ' +
' now-all-of-them-together: "\\\/\b\n\r\t' +
' now-a-bunch-of-junk: !@#$%&()(&%$#{}{}<><><';
- equal(client.testString(specialCharacters),specialCharacters);
+ equal(client.testString(specialCharacters), specialCharacters);
});
- test("Double", function() {
+ test('Double', function() {
equal(client.testDouble(0), 0);
equal(client.testDouble(-1), -1);
equal(client.testDouble(3.14), 3.14);
- equal(client.testDouble(Math.pow(2,60)), Math.pow(2,60));
+ equal(client.testDouble(Math.pow(2, 60)), Math.pow(2, 60));
});
- test("Byte", function() {
+ test('Byte', function() {
equal(client.testByte(0), 0);
equal(client.testByte(0x01), 0x01);
});
- test("I32", function() {
+ test('I32', function() {
equal(client.testI32(0), 0);
- equal(client.testI32(Math.pow(2,30)), Math.pow(2,30));
- equal(client.testI32(-Math.pow(2,30)), -Math.pow(2,30));
+ equal(client.testI32(Math.pow(2, 30)), Math.pow(2, 30));
+ equal(client.testI32(-Math.pow(2, 30)), -Math.pow(2, 30));
});
- test("I64", function() {
+ test('I64', function() {
equal(client.testI64(0), 0);
//This is usually 2^60 but JS cannot represent anything over 2^52 accurately
- equal(client.testI64(Math.pow(2,52)), Math.pow(2,52));
- equal(client.testI64(-Math.pow(2,52)), -Math.pow(2,52));
+ equal(client.testI64(Math.pow(2, 52)), Math.pow(2, 52));
+ equal(client.testI64(-Math.pow(2, 52)), -Math.pow(2, 52));
});
-module("Structured Types");
+module('Structured Types');
- test("Struct", function() {
+ test('Struct', function() {
var structTestInput = new ThriftTest.Xtruct();
structTestInput.string_thing = 'worked';
structTestInput.byte_thing = 0x01;
- structTestInput.i32_thing = Math.pow(2,30);
+ structTestInput.i32_thing = Math.pow(2, 30);
//This is usually 2^60 but JS cannot represent anything over 2^52 accurately
- structTestInput.i64_thing = Math.pow(2,52);
+ structTestInput.i64_thing = Math.pow(2, 52);
var structTestOutput = client.testStruct(structTestInput);
@@ -158,18 +158,18 @@
equal(JSON.stringify(structTestOutput), JSON.stringify(structTestInput));
});
- test("Nest", function() {
+ test('Nest', function() {
var xtrTestInput = new ThriftTest.Xtruct();
xtrTestInput.string_thing = 'worked';
xtrTestInput.byte_thing = 0x01;
- xtrTestInput.i32_thing = Math.pow(2,30);
+ xtrTestInput.i32_thing = Math.pow(2, 30);
//This is usually 2^60 but JS cannot represent anything over 2^52 accurately
- xtrTestInput.i64_thing = Math.pow(2,52);
+ xtrTestInput.i64_thing = Math.pow(2, 52);
var nestTestInput = new ThriftTest.Xtruct2();
nestTestInput.byte_thing = 0x02;
nestTestInput.struct_thing = xtrTestInput;
- nestTestInput.i32_thing = Math.pow(2,15);
+ nestTestInput.i32_thing = Math.pow(2, 15);
var nestTestOutput = client.testNest(nestTestInput);
@@ -183,8 +183,8 @@
equal(JSON.stringify(nestTestOutput), JSON.stringify(nestTestInput));
});
- test("Map", function() {
- var mapTestInput = {7:77, 8:88, 9:99};
+ test('Map', function() {
+ var mapTestInput = {7: 77, 8: 88, 9: 99};
var mapTestOutput = client.testMap(mapTestInput);
@@ -193,10 +193,10 @@
}
});
- test("StringMap", function() {
+ test('StringMap', function() {
var mapTestInput = {
- "a":"123", "a b":"with spaces ", "same":"same", "0":"numeric key",
- "longValue":stringTest, stringTest:"long key"
+ 'a': '123', 'a b': 'with spaces ', 'same': 'same', '0': 'numeric key',
+ 'longValue': stringTest, stringTest: 'long key'
};
var mapTestOutput = client.testStringMap(mapTestInput);
@@ -206,30 +206,30 @@
}
});
- test("Set", function() {
- var setTestInput = [1,2,3];
+ test('Set', function() {
+ var setTestInput = [1, 2, 3];
ok(client.testSet(setTestInput), setTestInput);
});
- test("List", function() {
- var listTestInput = [1,2,3];
+ test('List', function() {
+ var listTestInput = [1, 2, 3];
ok(client.testList(listTestInput), listTestInput);
});
- test("Enum", function() {
+ test('Enum', function() {
equal(client.testEnum(ThriftTest.Numberz.ONE), ThriftTest.Numberz.ONE);
});
- test("TypeDef", function() {
+ test('TypeDef', function() {
equal(client.testTypedef(69), 69);
});
- test("Skip", function() {
+ test('Skip', function() {
var structTestInput = new ThriftTest.Xtruct();
var modifiedClient = new ThriftTest.ThriftTestClient(protocol);
modifiedClient.recv_testStruct = function() {
- var input = modifiedClient.input;
+ var input = modifiedClient.input;
var xtruct3 = new ThriftTest.Xtruct3();
input.readMessageBegin();
@@ -250,9 +250,9 @@
};
structTestInput.string_thing = 'worked';
- structTestInput.byte_thing = 0x01;
- structTestInput.i32_thing = Math.pow(2,30);
- structTestInput.i64_thing = Math.pow(2,52);
+ structTestInput.byte_thing = 0x01;
+ structTestInput.i32_thing = Math.pow(2, 30);
+ structTestInput.i64_thing = Math.pow(2, 52);
var structTestOutput = modifiedClient.testStruct(structTestInput);
@@ -264,12 +264,12 @@
});
-module("deeper!");
+module('deeper!');
- test("MapMap", function() {
+ test('MapMap', function() {
var mapMapTestExpectedResult = {
- "4":{"1":1,"2":2,"3":3,"4":4},
- "-4":{"-4":-4, "-3":-3, "-2":-2, "-1":-1}
+ '4': {'1': 1, '2': 2, '3': 3, '4': 4},
+ '-4': {'-4': -4, '-3': -3, '-2': -2, '-1': -1}
};
var mapMapTestOutput = client.testMapMap(1);
@@ -285,64 +285,64 @@
});
-module("Exception");
+module('Exception');
- test("Xception", function() {
+ test('Xception', function() {
expect(2);
- try{
- client.testException("Xception");
- }catch(e){
+ try {
+ client.testException('Xception');
+ }catch (e) {
equal(e.errorCode, 1001);
- equal(e.message, "Xception");
+ equal(e.message, 'Xception');
}
});
- test("no Exception", 0, function() {
- try{
- client.testException("no Exception");
- }catch(e){
+ test('no Exception', 0, function() {
+ try {
+ client.testException('no Exception');
+ }catch (e) {
ok(false);
}
});
- test("TException", function() {
+ test('TException', function() {
//ThriftTest does not list TException as a legal exception so it will
// generate an exception on the server that does not propagate back to
// the client. This test has been modified to equate to "no exception"
expect(1);
- try{
- client.testException("TException");
- } catch(e) {
+ try {
+ client.testException('TException');
+ } catch (e) {
//ok(false);
}
ok(true);
});
-module("Insanity");
+module('Insanity');
var crazy = {
- "userMap":{ "5":5, "8":8 },
- "xtructs":[{
- "string_thing":"Goodbye4",
- "byte_thing":4,
- "i32_thing":4,
- "i64_thing":4
+ 'userMap': { '5': 5, '8': 8 },
+ 'xtructs': [{
+ 'string_thing': 'Goodbye4',
+ 'byte_thing': 4,
+ 'i32_thing': 4,
+ 'i64_thing': 4
},
{
- "string_thing":"Hello2",
- "byte_thing":2,
- "i32_thing":2,
- "i64_thing":2
+ 'string_thing': 'Hello2',
+ 'byte_thing': 2,
+ 'i32_thing': 2,
+ 'i64_thing': 2
}]
};
- test("testInsanity", function() {
+ test('testInsanity', function() {
var insanity = {
- "1":{
- "2":crazy,
- "3":crazy
+ '1': {
+ '2': crazy,
+ '3': crazy
},
- "2":{ "6":{ "userMap":null, "xtructs":null } }
+ '2': { '6': { 'userMap': null, 'xtructs': null } }
};
var res = client.testInsanity(new ThriftTest.Insanity(crazy));
ok(res, JSON.stringify(res));
@@ -355,10 +355,10 @@
//////////////////////////////////
//Run same tests asynchronously
-module("Async");
+module('Async');
- test("Double", function() {
- expect( 1 );
+ test('Double', function() {
+ expect(1);
QUnit.stop();
client.testDouble(3.14159265, function(result) {
@@ -367,8 +367,8 @@
});
});
- test("Byte", function() {
- expect( 1 );
+ test('Byte', function() {
+ expect(1);
QUnit.stop();
client.testByte(0x01, function(result) {
@@ -377,36 +377,36 @@
});
});
- test("I32", function() {
- expect( 2 );
+ test('I32', function() {
+ expect(2);
QUnit.stop();
- client.testI32(Math.pow(2,30), function(result) {
- equal(result, Math.pow(2,30));
+ client.testI32(Math.pow(2, 30), function(result) {
+ equal(result, Math.pow(2, 30));
QUnit.start();
});
QUnit.stop();
- client.testI32(Math.pow(-2,31), function(result) {
- equal(result, Math.pow(-2,31));
+ client.testI32(Math.pow(-2, 31), function(result) {
+ equal(result, Math.pow(-2, 31));
QUnit.start();
});
});
- test("I64", function() {
- expect( 2 );
+ test('I64', function() {
+ expect(2);
QUnit.stop();
//This is usually 2^60 but JS cannot represent anything over 2^52 accurately
- client.testI64(Math.pow(2,52), function(result) {
- equal(result, Math.pow(2,52));
+ client.testI64(Math.pow(2, 52), function(result) {
+ equal(result, Math.pow(2, 52));
QUnit.start();
});
QUnit.stop();
//This is usually 2^60 but JS cannot represent anything over 2^52 accurately
- client.testI64(Math.pow(-2,52), function(result) {
- equal(result, Math.pow(-2,52));
+ client.testI64(Math.pow(-2, 52), function(result) {
+ equal(result, Math.pow(-2, 52));
QUnit.start();
});
});
diff --git a/lib/js/test/test_handler.js b/lib/js/test/test_handler.js
index e1fa74f..496b5e0 100644
--- a/lib/js/test/test_handler.js
+++ b/lib/js/test/test_handler.js
@@ -17,7 +17,7 @@
* under the License.
*/
-//This is the server side Node test handler for the standard
+//This is the server side Node test handler for the standard
// Apache Thrift test service.
var ttypes = require('./gen-nodejs/ThriftTest_types');
@@ -162,7 +162,7 @@
result(null, hello);
},
testException: function(arg, result) {
- console.log('testException('+arg+')');
+ console.log('testException(' + arg + ')');
if (arg === 'Xception') {
var x = new ttypes.Xception();
x.errorCode = 1001;