THRIFT-3627 fix missing basic code style consistency of JavaScript.
Client: js
This closes #858
This closes #1243
diff --git a/lib/js/src/thrift.js b/lib/js/src/thrift.js
index 3ea57c8..37ba690 100644
--- a/lib/js/src/thrift.js
+++ b/lib/js/src/thrift.js
@@ -20,21 +20,21 @@
/*jshint evil:true*/
/**
- * The Thrift namespace houses the Apache Thrift JavaScript library
- * elements providing JavaScript bindings for the Apache Thrift RPC
- * system. End users will typically only directly make use of the
- * Transport (TXHRTransport/TWebSocketTransport) and Protocol
+ * The Thrift namespace houses the Apache Thrift JavaScript library
+ * elements providing JavaScript bindings for the Apache Thrift RPC
+ * system. End users will typically only directly make use of the
+ * Transport (TXHRTransport/TWebSocketTransport) and Protocol
* (TJSONPRotocol/TBinaryProtocol) constructors.
- *
- * Object methods beginning with a __ (e.g. __onOpen()) are internal
+ *
+ * Object methods beginning with a __ (e.g. __onOpen()) are internal
* and should not be called outside of the object's own methods.
- *
+ *
* This library creates one global object: Thrift
* Code in this library must never create additional global identifiers,
* all features must be scoped within the Thrift namespace.
* @namespace
* @example
- * var transport = new Thrift.Transport("http://localhost:8585");
+ * var transport = new Thrift.Transport('http://localhost:8585');
* var protocol = new Thrift.Protocol(transport);
* var client = new MyThriftSvcClient(protocol);
* var result = client.MyMethod();
@@ -55,7 +55,7 @@
* @property {number} VOID - No value (only legal for return types).
* @property {number} BOOL - True/False integer.
* @property {number} BYTE - Signed 8 bit integer.
- * @property {number} I08 - Signed 8 bit integer.
+ * @property {number} I08 - Signed 8 bit integer.
* @property {number} DOUBLE - 64 bit IEEE 854 floating point.
* @property {number} I16 - Signed 16 bit integer.
* @property {number} I32 - Signed 32 bit integer.
@@ -70,23 +70,23 @@
* @property {number} UTF16 - Array of bytes representing a string of UTF16 encoded characters.
*/
Type: {
- 'STOP' : 0,
- 'VOID' : 1,
- 'BOOL' : 2,
- 'BYTE' : 3,
- 'I08' : 3,
- 'DOUBLE' : 4,
- 'I16' : 6,
- 'I32' : 8,
- 'I64' : 10,
- 'STRING' : 11,
- 'UTF7' : 11,
- 'STRUCT' : 12,
- 'MAP' : 13,
- 'SET' : 14,
- 'LIST' : 15,
- 'UTF8' : 16,
- 'UTF16' : 17
+ STOP: 0,
+ VOID: 1,
+ BOOL: 2,
+ BYTE: 3,
+ I08: 3,
+ DOUBLE: 4,
+ I16: 6,
+ I32: 8,
+ I64: 10,
+ STRING: 11,
+ UTF7: 11,
+ STRUCT: 12,
+ MAP: 13,
+ SET: 14,
+ LIST: 15,
+ UTF8: 16,
+ UTF16: 17
},
/**
@@ -98,10 +98,10 @@
* @property {number} ONEWAY - Oneway RPC call from client to server with no response.
*/
MessageType: {
- 'CALL' : 1,
- 'REPLY' : 2,
- 'EXCEPTION' : 3,
- 'ONEWAY' : 4
+ CALL: 1,
+ REPLY: 2,
+ EXCEPTION: 3,
+ ONEWAY: 4
},
/**
@@ -130,7 +130,7 @@
function F() {}
F.prototype = superConstructor.prototype;
constructor.prototype = new F();
- constructor.prototype.name = name || "";
+ constructor.prototype.name = name || '';
}
};
@@ -171,17 +171,17 @@
* @property {number} UNSUPPORTED_CLIENT_TYPE - Unused.
*/
Thrift.TApplicationExceptionType = {
- 'UNKNOWN' : 0,
- 'UNKNOWN_METHOD' : 1,
- 'INVALID_MESSAGE_TYPE' : 2,
- 'WRONG_METHOD_NAME' : 3,
- 'BAD_SEQUENCE_ID' : 4,
- 'MISSING_RESULT' : 5,
- 'INTERNAL_ERROR' : 6,
- 'PROTOCOL_ERROR' : 7,
- 'INVALID_TRANSFORM' : 8,
- 'INVALID_PROTOCOL' : 9,
- 'UNSUPPORTED_CLIENT_TYPE' : 10
+ UNKNOWN: 0,
+ UNKNOWN_METHOD: 1,
+ INVALID_MESSAGE_TYPE: 2,
+ WRONG_METHOD_NAME: 3,
+ BAD_SEQUENCE_ID: 4,
+ MISSING_RESULT: 5,
+ INTERNAL_ERROR: 6,
+ PROTOCOL_ERROR: 7,
+ INVALID_TRANSFORM: 8,
+ INVALID_PROTOCOL: 9,
+ UNSUPPORTED_CLIENT_TYPE: 10
};
/**
@@ -194,7 +194,7 @@
*/
Thrift.TApplicationException = function(message, code) {
this.message = message;
- this.code = typeof code === "number" ? code : 0;
+ this.code = typeof code === 'number' ? code : 0;
};
Thrift.inherits(Thrift.TApplicationException, Thrift.TException, 'TApplicationException');
@@ -298,8 +298,8 @@
* for backward compatibility.
* @constructor
* @param {string} [url] - The URL to connect to.
- * @classdesc The Apache Thrift Transport layer performs byte level I/O
- * between RPC clients and servers. The JavaScript TXHRTransport object
+ * @classdesc The Apache Thrift Transport layer performs byte level I/O
+ * between RPC clients and servers. The JavaScript TXHRTransport object
* uses Http[s]/XHR. Target servers must implement the http[s] transport
* (see: node.js example server_http.js).
* @example
@@ -329,12 +329,12 @@
},
/**
- * Sends the current XRH request if the transport was created with a URL
+ * Sends the current XRH request if the transport was created with a URL
* and the async parameter is false. If the transport was not created with
- * a URL, or the async parameter is True and no callback is provided, or
+ * a URL, or the async parameter is True and no callback is provided, or
* the URL is an empty string, the current send buffer is returned.
* @param {object} async - If true the current send buffer is returned.
- * @param {object} callback - Optional async completion callback
+ * @param {object} callback - Optional async completion callback
* @returns {undefined|string} Nothing or the current send buffer.
* @throws {string} If XHR fails.
*/
@@ -353,9 +353,9 @@
if (callback) {
//Ignore XHR callbacks until the data arrives, then call the
// client's callback
- xreq.onreadystatechange =
+ xreq.onreadystatechange =
(function() {
- var clientCallback = callback;
+ var clientCallback = callback;
return function() {
if (this.readyState == 4 && this.status == 200) {
self.setRecvBuffer(this.responseText);
@@ -459,19 +459,19 @@
* Returns true if the transport is open, XHR always returns true.
* @readonly
* @returns {boolean} Always True.
- */
+ */
isOpen: function() {
return true;
},
/**
* Opens the transport connection, with XHR this is a nop.
- */
+ */
open: function() {},
/**
* Closes the transport connection, with XHR this is a nop.
- */
+ */
close: function() {},
/**
@@ -511,7 +511,7 @@
/**
* Sets the send buffer to buf.
* @param {string} buf - The buffer to send.
- */
+ */
write: function(buf) {
this.send_buf = buf;
},
@@ -520,7 +520,7 @@
* Returns the send buffer.
* @readonly
* @returns {string} The send buffer.
- */
+ */
getSendBuffer: function() {
return this.send_buf;
}
@@ -532,8 +532,8 @@
* Constructor Function for the WebSocket transport.
* @constructor
* @param {string} [url] - The URL to connect to.
- * @classdesc The Apache Thrift Transport layer performs byte level I/O
- * between RPC clients and servers. The JavaScript TWebSocketTransport object
+ * @classdesc The Apache Thrift Transport layer performs byte level I/O
+ * between RPC clients and servers. The JavaScript TWebSocketTransport object
* uses the WebSocket protocol. Target servers must implement WebSocket.
* (see: node.js example server_http.js).
* @example
@@ -556,20 +556,20 @@
},
/**
- * Sends the current WS request and registers callback. The async
- * parameter is ignored (WS flush is always async) and the callback
+ * Sends the current WS request and registers callback. The async
+ * parameter is ignored (WS flush is always async) and the callback
* function parameter is required.
* @param {object} async - Ignored.
* @param {object} callback - The client completion callback.
- * @returns {undefined|string} Nothing (undefined)
+ * @returns {undefined|string} Nothing (undefined)
*/
flush: function(async, callback) {
var self = this;
if (this.isOpen()) {
//Send data and register a callback to invoke the client callback
- this.socket.send(this.send_buf);
+ this.socket.send(this.send_buf);
this.callbacks.push((function() {
- var clientCallback = callback;
+ var clientCallback = callback;
return function(msg) {
self.setRecvBuffer(msg);
clientCallback();
@@ -579,20 +579,20 @@
//Queue the send to go out __onOpen
this.send_pending.push({
buf: this.send_buf,
- cb: callback
+ cb: callback
});
}
},
- __onOpen: function() {
+ __onOpen: function() {
var self = this;
if (this.send_pending.length > 0) {
- //If the user made calls before the connection was fully
+ //If the user made calls before the connection was fully
//open, send them now
this.send_pending.forEach(function(elem) {
this.socket.send(elem.buf);
this.callbacks.push((function() {
- var clientCallback = elem.cb;
+ var clientCallback = elem.cb;
return function(msg) {
self.setRecvBuffer(msg);
clientCallback();
@@ -602,19 +602,19 @@
this.send_pending = [];
}
},
-
- __onClose: function(evt) {
+
+ __onClose: function(evt) {
this.__reset(this.url);
},
-
+
__onMessage: function(evt) {
if (this.callbacks.length) {
this.callbacks.shift()(evt.data);
}
},
-
- __onError: function(evt) {
- console.log("Thrift WebSocket Error: " + evt.toString());
+
+ __onError: function(evt) {
+ console.log('Thrift WebSocket Error: ' + evt.toString());
this.socket.close();
},
@@ -632,15 +632,15 @@
/**
* Returns true if the transport is open
* @readonly
- * @returns {boolean}
- */
+ * @returns {boolean}
+ */
isOpen: function() {
return this.socket && this.socket.readyState == this.socket.OPEN;
},
/**
* Opens the transport connection
- */
+ */
open: function() {
//If OPEN/CONNECTING/CLOSING ignore additional opens
if (this.socket && this.socket.readyState != this.socket.CLOSED) {
@@ -648,15 +648,15 @@
}
//If there is no socket or the socket is closed:
this.socket = new WebSocket(this.url);
- this.socket.onopen = this.__onOpen.bind(this);
- this.socket.onmessage = this.__onMessage.bind(this);
- this.socket.onerror = this.__onError.bind(this);
- this.socket.onclose = this.__onClose.bind(this);
+ this.socket.onopen = this.__onOpen.bind(this);
+ this.socket.onmessage = this.__onMessage.bind(this);
+ this.socket.onerror = this.__onError.bind(this);
+ this.socket.onclose = this.__onClose.bind(this);
},
/**
* Closes the transport connection
- */
+ */
close: function() {
this.socket.close();
},
@@ -698,7 +698,7 @@
/**
* Sets the send buffer to buf.
* @param {string} buf - The buffer to send.
- */
+ */
write: function(buf) {
this.send_buf = buf;
},
@@ -707,7 +707,7 @@
* Returns the send buffer.
* @readonly
* @returns {string} The send buffer.
- */
+ */
getSendBuffer: function() {
return this.send_buf;
}
@@ -718,8 +718,8 @@
* Initializes a Thrift JSON protocol instance.
* @constructor
* @param {Thrift.Transport} transport - The transport to serialize to/from.
- * @classdesc Apache Thrift Protocols perform serialization which enables cross
- * language RPC. The Protocol type is the JavaScript browser implementation
+ * @classdesc Apache Thrift Protocols perform serialization which enables cross
+ * language RPC. The Protocol type is the JavaScript browser implementation
* of the Apache Thrift TJSONProtocol.
* @example
* var protocol = new Thrift.Protocol(transport);
@@ -779,7 +779,7 @@
* Returns the underlying transport.
* @readonly
* @returns {Thrift.Transport} The underlying transport.
- */
+ */
getTransport: function() {
return this.transport;
},
@@ -1021,7 +1021,7 @@
if (ch === '\"') {
escapedString += '\\\"'; // write out as: \"
} else if (ch === '\\') { // a single backslash
- escapedString += '\\\\'; // write out as double backslash
+ escapedString += '\\\\'; // write out as double backslash
} else if (ch === '\b') { // a single backspace: invisible
escapedString += '\\b'; // write out as: \b"
} else if (ch === '\f') { // a single formfeed: invisible
@@ -1063,8 +1063,8 @@
@property {Thrift.MessageType} mtype - The type of message call.
@property {number} rseqid - The sequence number of the message (0 in Thrift RPC).
*/
- /**
- * Deserializes the beginning of a message.
+ /**
+ * Deserializes the beginning of a message.
* @returns {AnonReadMessageBeginReturn}
*/
readMessageBegin: function() {
@@ -1101,11 +1101,11 @@
readMessageEnd: function() {
},
- /**
- * Deserializes the beginning of a struct.
+ /**
+ * Deserializes the beginning of a struct.
* @param {string} [name] - The name of the struct (ignored)
* @returns {object} - An object with an empty string fname property
- */
+ */
readStructBegin: function(name) {
var r = {};
r.fname = '';
@@ -1132,8 +1132,8 @@
@property {Thrift.Type} ftype - The data type of the field.
@property {number} fid - The unique identifier of the field.
*/
- /**
- * Deserializes the beginning of a field.
+ /**
+ * Deserializes the beginning of a field.
* @returns {AnonReadFieldBeginReturn}
*/
readFieldBegin: function() {
@@ -1201,8 +1201,8 @@
@property {Thrift.Type} vtype - The data type of the value.
@property {number} size - The number of elements in the map.
*/
- /**
- * Deserializes the beginning of a map.
+ /**
+ * Deserializes the beginning of a map.
* @returns {AnonReadMapBeginReturn}
*/
readMapBegin: function() {
@@ -1237,8 +1237,8 @@
@property {Thrift.Type} etype - The data type of the element.
@property {number} size - The number of elements in the collection.
*/
- /**
- * Deserializes the beginning of a list.
+ /**
+ * Deserializes the beginning of a list.
* @returns {AnonReadColBeginReturn}
*/
readListBegin: function() {
@@ -1259,8 +1259,8 @@
this.readFieldEnd();
},
- /**
- * Deserializes the beginning of a set.
+ /**
+ * Deserializes the beginning of a set.
* @returns {AnonReadColBeginReturn}
*/
readSetBegin: function(elemType, size) {
@@ -1272,8 +1272,8 @@
return this.readListEnd();
},
- /** Returns an object with a value property set to
- * False unless the next number in the protocol buffer
+ /** Returns an object with a value property set to
+ * False unless the next number in the protocol buffer
* is 1, in which case the value property is True */
readBool: function() {
var r = this.readI32();
@@ -1287,19 +1287,19 @@
return r;
},
- /** Returns the an object with a value property set to the
+ /** Returns the an object with a value property set to the
next value found in the protocol buffer */
readByte: function() {
return this.readI32();
},
- /** Returns the an object with a value property set to the
+ /** Returns the an object with a value property set to the
next value found in the protocol buffer */
readI16: function() {
return this.readI32();
},
- /** Returns the an object with a value property set to the
+ /** Returns the an object with a value property set to the
next value found in the protocol buffer */
readI32: function(f) {
if (f === undefined) {
@@ -1333,26 +1333,26 @@
return r;
},
- /** Returns the an object with a value property set to the
+ /** Returns the an object with a value property set to the
next value found in the protocol buffer */
readI64: function() {
return this.readI32();
},
- /** Returns the an object with a value property set to the
+ /** Returns the an object with a value property set to the
next value found in the protocol buffer */
readDouble: function() {
return this.readI32();
},
- /** Returns the an object with a value property set to the
+ /** Returns the an object with a value property set to the
next value found in the protocol buffer */
readString: function() {
var r = this.readI32();
return r;
},
- /** Returns the an object with a value property set to the
+ /** Returns the an object with a value property set to the
next value found in the protocol buffer */
readBinary: function() {
var r = this.readI32();
@@ -1360,7 +1360,7 @@
return r;
},
- /**
+ /**
* Method to arbitrarily skip over data */
skip: function(type) {
var ret, i;
@@ -1440,23 +1440,23 @@
* Initializes a MutilplexProtocol Implementation as a Wrapper for Thrift.Protocol
* @constructor
*/
-Thrift.MultiplexProtocol = function (srvName, trans, strictRead, strictWrite) {
+Thrift.MultiplexProtocol = function(srvName, trans, strictRead, strictWrite) {
Thrift.Protocol.call(this, trans, strictRead, strictWrite);
this.serviceName = srvName;
};
Thrift.inherits(Thrift.MultiplexProtocol, Thrift.Protocol, 'multiplexProtocol');
/** Override writeMessageBegin method of prototype*/
-Thrift.MultiplexProtocol.prototype.writeMessageBegin = function (name, type, seqid) {
+Thrift.MultiplexProtocol.prototype.writeMessageBegin = function(name, type, seqid) {
if (type === Thrift.MessageType.CALL || type === Thrift.MessageType.ONEWAY) {
- Thrift.Protocol.prototype.writeMessageBegin.call(this, this.serviceName + ":" + name, type, seqid);
+ Thrift.Protocol.prototype.writeMessageBegin.call(this, this.serviceName + ':' + name, type, seqid);
} else {
Thrift.Protocol.prototype.writeMessageBegin.call(this, name, type, seqid);
}
};
-Thrift.Multiplexer = function () {
+Thrift.Multiplexer = function() {
this.seqid = 0;
};
@@ -1471,12 +1471,12 @@
* var protocol = new Thrift.Protocol(transport);
* var client = mp.createClient('AuthService', AuthServiceClient, transport);
*/
-Thrift.Multiplexer.prototype.createClient = function (serviceName, SCl, transport) {
+Thrift.Multiplexer.prototype.createClient = function(serviceName, SCl, transport) {
if (SCl.Client) {
SCl = SCl.Client;
}
var self = this;
- SCl.prototype.new_seqid = function () {
+ SCl.prototype.new_seqid = function() {
self.seqid += 1;
return self.seqid;
};
@@ -1519,7 +1519,7 @@
return result;
};
-copyMap = function(obj, types){
+copyMap = function(obj, types) {
if (!obj) {return obj; }
@@ -1534,8 +1534,8 @@
var Type = type;
var result = {}, val;
- for(var prop in obj) {
- if(obj.hasOwnProperty(prop)) {
+ for (var prop in obj) {
+ if (obj.hasOwnProperty(prop)) {
val = obj[prop];
if (type === null) {
result[prop] = val;
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;