THRIFT-3627 fix missing basic code style consistency of JavaScript.
Client: js
This closes #858
This closes #1243
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();
});
});