Upgrading dependency to Thrift 0.12.0
This commit is contained in:
parent
3e4590dcc0
commit
356978cb42
1302 changed files with 101701 additions and 26784 deletions
244
vendor/git.apache.org/thrift.git/lib/js/Gruntfile.js
generated
vendored
244
vendor/git.apache.org/thrift.git/lib/js/Gruntfile.js
generated
vendored
|
@ -3,6 +3,7 @@
|
|||
//Prerequisites:
|
||||
// Node Setup - nodejs.org
|
||||
// Grunt Setup - npm install //reads the ./package.json and installs project dependencies
|
||||
// Run grunt - npx grunt // uses project-local installed version of grunt (from package.json)
|
||||
|
||||
module.exports = function(grunt) {
|
||||
'use strict';
|
||||
|
@ -38,115 +39,213 @@ module.exports = function(grunt) {
|
|||
},
|
||||
shell: {
|
||||
InstallThriftJS: {
|
||||
command: 'mkdir test/build; mkdir test/build/js; cp src/thrift.js test/build/js/thrift.js'
|
||||
command: 'mkdir -p test/build/js/lib; cp src/thrift.js test/build/js/thrift.js'
|
||||
},
|
||||
InstallThriftNodeJSDep: {
|
||||
command: 'cd ../..; npm install'
|
||||
},
|
||||
InstallTestLibs: {
|
||||
command: 'cd test; ant download_jslibs'
|
||||
},
|
||||
ThriftGen: {
|
||||
command: '../../compiler/cpp/thrift -gen js -gen js:node -o test ../../test/ThriftTest.thrift'
|
||||
command: [
|
||||
'mkdir -p test/gen-js',
|
||||
'../../compiler/cpp/thrift -gen js --out test/gen-js ../../test/ThriftTest.thrift',
|
||||
'../../compiler/cpp/thrift -gen js --out test/gen-js ../../test/JsDeepConstructorTest.thrift',
|
||||
'mkdir -p test/gen-js-jquery',
|
||||
'../../compiler/cpp/thrift -gen js:jquery --out test/gen-js-jquery ../../test/ThriftTest.thrift',
|
||||
'mkdir -p test/gen-nodejs',
|
||||
'../../compiler/cpp/thrift -gen js:node --out test/gen-nodejs ../../test/ThriftTest.thrift',
|
||||
'mkdir -p test/gen-js-es6',
|
||||
'../../compiler/cpp/thrift -gen js:es6 --out test/gen-js-es6 ../../test/ThriftTest.thrift',
|
||||
'mkdir -p test/gen-nodejs-es6',
|
||||
'../../compiler/cpp/thrift -gen js:node,es6 --out ./test/gen-nodejs-es6 ../../test/ThriftTest.thrift',
|
||||
].join(' && ')
|
||||
},
|
||||
ThriftGenJQ: {
|
||||
command: '../../compiler/cpp/thrift -gen js:jquery -gen js:node -o test ../../test/ThriftTest.thrift'
|
||||
},
|
||||
ThriftGenDeepConstructor: {
|
||||
command: '../../compiler/cpp/thrift -gen js -o test ../../test/JsDeepConstructorTest.thrift'
|
||||
}
|
||||
},
|
||||
external_daemon: {
|
||||
},
|
||||
ThriftGenDoubleConstants: {
|
||||
command: '../../compiler/cpp/thrift -gen js -o test ../../test/DoubleConstantsTest.thrift'
|
||||
},
|
||||
ThriftTestServer: {
|
||||
options: {
|
||||
startCheck: function(stdout, stderr) {
|
||||
return (/Thrift Server running on port/).test(stdout);
|
||||
},
|
||||
nodeSpawnOptions: {
|
||||
cwd: "test",
|
||||
env: {NODE_PATH: "../../nodejs/lib:../../../node_modules"}
|
||||
}
|
||||
async: true,
|
||||
execOptions: {
|
||||
cwd: "./test",
|
||||
env: {NODE_PATH: "../../nodejs/lib:../../../node_modules"}
|
||||
}
|
||||
},
|
||||
cmd: "node",
|
||||
args: ["server_http.js"]
|
||||
command: "node server_http.js",
|
||||
},
|
||||
ThriftTestServerES6: {
|
||||
options: {
|
||||
async: true,
|
||||
execOptions: {
|
||||
cwd: "./test",
|
||||
env: {NODE_PATH: "../../nodejs/lib:../../../node_modules"}
|
||||
}
|
||||
},
|
||||
command: "node server_http.js --es6",
|
||||
},
|
||||
ThriftTestServer_TLS: {
|
||||
options: {
|
||||
startCheck: function(stdout, stderr) {
|
||||
return (/Thrift Server running on port/).test(stdout);
|
||||
},
|
||||
nodeSpawnOptions: {
|
||||
cwd: "test",
|
||||
env: {NODE_PATH: "../../nodejs/lib:../../../node_modules"}
|
||||
}
|
||||
async: true,
|
||||
execOptions: {
|
||||
cwd: "./test",
|
||||
env: {NODE_PATH: "../../nodejs/lib:../../../node_modules"}
|
||||
}
|
||||
},
|
||||
cmd: "node",
|
||||
args: ["server_https.js"]
|
||||
}
|
||||
command: "node server_https.js",
|
||||
},
|
||||
ThriftTestServerES6_TLS: {
|
||||
options: {
|
||||
async: true,
|
||||
execOptions: {
|
||||
cwd: "./test",
|
||||
env: {NODE_PATH: "../../nodejs/lib:../../../node_modules"}
|
||||
}
|
||||
},
|
||||
command: "node server_https.js --es6",
|
||||
},
|
||||
},
|
||||
qunit: {
|
||||
ThriftJS: {
|
||||
options: {
|
||||
urls: [
|
||||
'http://localhost:8088/test-nojq.html'
|
||||
]
|
||||
'http://localhost:8089/test-nojq.html'
|
||||
],
|
||||
puppeteer: {
|
||||
headless: true,
|
||||
args: ['--no-sandbox'],
|
||||
},
|
||||
}
|
||||
},
|
||||
ThriftJSJQ: {
|
||||
options: {
|
||||
urls: [
|
||||
'http://localhost:8088/test.html'
|
||||
]
|
||||
'http://localhost:8089/test.html'
|
||||
],
|
||||
puppeteer: {
|
||||
headless: true,
|
||||
args: ['--no-sandbox'],
|
||||
},
|
||||
}
|
||||
},
|
||||
ThriftJS_DoubleRendering: {
|
||||
options: {
|
||||
urls: [
|
||||
'http://localhost:8089/test-double-rendering.html'
|
||||
],
|
||||
puppeteer: {
|
||||
headless: true,
|
||||
args: ['--no-sandbox'],
|
||||
ignoreHTTPSErrors: true,
|
||||
},
|
||||
}
|
||||
},
|
||||
ThriftWS: {
|
||||
options: {
|
||||
urls: [
|
||||
'http://localhost:8088/testws.html'
|
||||
]
|
||||
'http://localhost:8089/testws.html'
|
||||
],
|
||||
puppeteer: {
|
||||
headless: true,
|
||||
args: ['--no-sandbox'],
|
||||
},
|
||||
}
|
||||
},
|
||||
ThriftJS_TLS: {
|
||||
options: {
|
||||
'--ignore-ssl-errors': true,
|
||||
urls: [
|
||||
'https://localhost:8089/test-nojq.html'
|
||||
]
|
||||
'https://localhost:8091/test-nojq.html'
|
||||
],
|
||||
puppeteer: {
|
||||
headless: true,
|
||||
args: ['--no-sandbox'],
|
||||
ignoreHTTPSErrors: true,
|
||||
},
|
||||
}
|
||||
},
|
||||
ThriftJSJQ_TLS: {
|
||||
options: {
|
||||
'--ignore-ssl-errors': true,
|
||||
urls: [
|
||||
'https://localhost:8089/test.html'
|
||||
]
|
||||
'https://localhost:8091/test.html'
|
||||
],
|
||||
puppeteer: {
|
||||
headless: true,
|
||||
args: ['--no-sandbox'],
|
||||
ignoreHTTPSErrors: true,
|
||||
},
|
||||
}
|
||||
},
|
||||
ThriftWS_TLS: {
|
||||
options: {
|
||||
'--ignore-ssl-errors': true,
|
||||
urls: [
|
||||
'https://localhost:8089/testws.html'
|
||||
]
|
||||
'https://localhost:8091/testws.html'
|
||||
],
|
||||
puppeteer: {
|
||||
headless: true,
|
||||
args: ['--no-sandbox'],
|
||||
ignoreHTTPSErrors: true,
|
||||
},
|
||||
}
|
||||
},
|
||||
ThriftDeepConstructor: {
|
||||
options: {
|
||||
urls: [
|
||||
'http://localhost:8088/test-deep-constructor.html'
|
||||
]
|
||||
'http://localhost:8089/test-deep-constructor.html'
|
||||
],
|
||||
puppeteer: {
|
||||
headless: true,
|
||||
args: ['--no-sandbox'],
|
||||
},
|
||||
}
|
||||
},
|
||||
ThriftWSES6: {
|
||||
options: {
|
||||
urls: [
|
||||
'http://localhost:8088/test-es6.html'
|
||||
],
|
||||
puppeteer: {
|
||||
headless: true,
|
||||
args: ['--no-sandbox'],
|
||||
},
|
||||
}
|
||||
}
|
||||
},
|
||||
jshint: {
|
||||
files: ['Gruntfile.js', 'src/**/*.js', 'test/*.js'],
|
||||
options: {
|
||||
// options here to override JSHint defaults
|
||||
globals: {
|
||||
jQuery: true,
|
||||
console: true,
|
||||
module: true,
|
||||
document: true
|
||||
// The main thrift library file. not es6 yet :(
|
||||
lib: {
|
||||
src: ['src/**/*.js'],
|
||||
options: {
|
||||
// options here to override JSHint defaults
|
||||
globals: {
|
||||
jQuery: true,
|
||||
console: true,
|
||||
module: true,
|
||||
document: true,
|
||||
},
|
||||
}
|
||||
}
|
||||
},
|
||||
},
|
||||
// The test files use es6
|
||||
test: {
|
||||
src: ['Gruntfile.js', 'test/*.js'],
|
||||
options: {
|
||||
// options here to override JSHint defaults
|
||||
globals: {
|
||||
jQuery: true,
|
||||
console: true,
|
||||
module: true,
|
||||
document: true,
|
||||
},
|
||||
esversion: 6,
|
||||
}
|
||||
},
|
||||
}
|
||||
});
|
||||
|
||||
grunt.loadNpmTasks('grunt-contrib-uglify');
|
||||
|
@ -154,19 +253,34 @@ module.exports = function(grunt) {
|
|||
grunt.loadNpmTasks('grunt-contrib-qunit');
|
||||
grunt.loadNpmTasks('grunt-contrib-concat');
|
||||
grunt.loadNpmTasks('grunt-jsdoc');
|
||||
grunt.loadNpmTasks('grunt-external-daemon');
|
||||
grunt.loadNpmTasks('grunt-shell');
|
||||
grunt.loadNpmTasks('grunt-shell-spawn');
|
||||
|
||||
grunt.registerTask('test', ['jshint', 'shell:InstallThriftJS', 'shell:InstallThriftNodeJSDep', 'shell:ThriftGen',
|
||||
'external_daemon:ThriftTestServer', 'external_daemon:ThriftTestServer_TLS',
|
||||
'shell:ThriftGenDeepConstructor', 'qunit:ThriftDeepConstructor',
|
||||
'qunit:ThriftJS', 'qunit:ThriftJS_TLS',
|
||||
'shell:ThriftGenJQ', 'qunit:ThriftJSJQ', 'qunit:ThriftJSJQ_TLS'
|
||||
]);
|
||||
grunt.registerTask('default', ['jshint', 'shell:InstallThriftJS', 'shell:InstallThriftNodeJSDep', 'shell:ThriftGen',
|
||||
'external_daemon:ThriftTestServer', 'external_daemon:ThriftTestServer_TLS',
|
||||
'qunit:ThriftJS', 'qunit:ThriftJS_TLS',
|
||||
'shell:ThriftGenJQ', 'qunit:ThriftJSJQ', 'qunit:ThriftJSJQ_TLS',
|
||||
'concat', 'uglify', 'jsdoc'
|
||||
]);
|
||||
grunt.registerTask('wait', 'Wait just one second for server to start', function () {
|
||||
var done = this.async();
|
||||
setTimeout(function() {
|
||||
done(true);
|
||||
}, 1000);
|
||||
});
|
||||
|
||||
grunt.registerTask('installAndGenerate', [
|
||||
'shell:InstallThriftJS', 'shell:InstallThriftNodeJSDep', 'shell:ThriftGen',
|
||||
'shell:ThriftGenDeepConstructor',
|
||||
'shell:InstallTestLibs',
|
||||
]);
|
||||
|
||||
grunt.registerTask('test', [
|
||||
'jshint',
|
||||
'installAndGenerate',
|
||||
'shell:ThriftTestServer', 'shell:ThriftTestServer_TLS',
|
||||
'shell:ThriftTestServerES6', 'shell:ThriftTestServerES6_TLS',
|
||||
'wait',
|
||||
'qunit:ThriftDeepConstructor',
|
||||
'qunit:ThriftJS', 'qunit:ThriftJS_TLS',
|
||||
'qunit:ThriftWS',
|
||||
'qunit:ThriftJSJQ', 'qunit:ThriftJSJQ_TLS',
|
||||
'qunit:ThriftWSES6',
|
||||
'shell:ThriftTestServer:kill', 'shell:ThriftTestServer_TLS:kill',
|
||||
'shell:ThriftTestServerES6:kill', 'shell:ThriftTestServerES6_TLS:kill',
|
||||
]);
|
||||
grunt.registerTask('default', ['test', 'concat', 'uglify', 'jsdoc']);
|
||||
};
|
||||
|
|
9
vendor/git.apache.org/thrift.git/lib/js/Makefile.am
generated
vendored
9
vendor/git.apache.org/thrift.git/lib/js/Makefile.am
generated
vendored
|
@ -18,10 +18,13 @@
|
|||
#
|
||||
|
||||
# Make sure this doesn't fail if ant is not configured.
|
||||
|
||||
# We call install twice to work around npm issues
|
||||
#
|
||||
if HAVE_NPM
|
||||
SUBDIRS = test
|
||||
|
||||
check-local: all
|
||||
npm install
|
||||
$(NPM) install || $(NPM) install
|
||||
$(NPM) list
|
||||
./node_modules/.bin/grunt
|
||||
|
||||
endif
|
||||
|
|
17
vendor/git.apache.org/thrift.git/lib/js/README.md
generated
vendored
17
vendor/git.apache.org/thrift.git/lib/js/README.md
generated
vendored
|
@ -38,19 +38,12 @@ This reads the package.json and pulls in the appropriate
|
|||
sources from the internet. To build the JavaScript branch
|
||||
of Apache Thrift execute the command:
|
||||
|
||||
grunt
|
||||
npx grunt
|
||||
|
||||
This runs the grunt build tool, linting all of the source
|
||||
files, setting up and running the tests, concatenating and
|
||||
minifying the main libraries and generating the html
|
||||
documentation.
|
||||
|
||||
If grunt is not installed you can install it with npm
|
||||
like this:
|
||||
|
||||
sudo npm install -g grunt-cli
|
||||
npm install grunt --save-dev
|
||||
|
||||
This runs the grunt build tool (from within `./node_modules/.bin/`),
|
||||
linting all of the source files, setting up and running the
|
||||
tests, concatenating and minifying the main libraries and
|
||||
generating the html documentation.
|
||||
|
||||
Tree
|
||||
----
|
||||
|
|
1869
vendor/git.apache.org/thrift.git/lib/js/package-lock.json
generated
vendored
Normal file
1869
vendor/git.apache.org/thrift.git/lib/js/package-lock.json
generated
vendored
Normal file
File diff suppressed because it is too large
Load diff
20
vendor/git.apache.org/thrift.git/lib/js/package.json
generated
vendored
20
vendor/git.apache.org/thrift.git/lib/js/package.json
generated
vendored
|
@ -1,15 +1,19 @@
|
|||
{
|
||||
"name": "thrift",
|
||||
"version": "0.10.0",
|
||||
"version": "1.0.0",
|
||||
"devDependencies": {
|
||||
"grunt": "^0.4.5",
|
||||
"grunt": "^1.0.2",
|
||||
"grunt-cli": "^1.2.0",
|
||||
"grunt-contrib-uglify": "^1.0.1",
|
||||
"grunt-contrib-jshint": "^1.0.0",
|
||||
"grunt-contrib-qunit": "^1.2.0",
|
||||
"grunt-contrib-concat": "^1.0.1",
|
||||
"grunt-jsdoc": "^2.0.0",
|
||||
"grunt-external-daemon": "^1.1.0",
|
||||
"grunt-shell": "^1.3.0"
|
||||
"grunt-contrib-jshint": "^1.0.0",
|
||||
"grunt-contrib-qunit": "^3.0.1",
|
||||
"grunt-contrib-uglify": "^1.0.1",
|
||||
"grunt-jsdoc": "^2.2.1",
|
||||
"grunt-shell-spawn": "^0.3.10",
|
||||
"jslint": "^0.12.0"
|
||||
},
|
||||
"dependencies": {
|
||||
"jsdoc": "^3.5.5",
|
||||
"nopt": "^4.0.1"
|
||||
}
|
||||
}
|
||||
|
|
118
vendor/git.apache.org/thrift.git/lib/js/src/thrift.js
generated
vendored
118
vendor/git.apache.org/thrift.git/lib/js/src/thrift.js
generated
vendored
|
@ -34,7 +34,7 @@
|
|||
* 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();
|
||||
|
@ -46,7 +46,7 @@ var Thrift = {
|
|||
* @const {string} Version
|
||||
* @memberof Thrift
|
||||
*/
|
||||
Version: '0.10.0',
|
||||
Version: '1.0.0-dev',
|
||||
|
||||
/**
|
||||
* Thrift IDL type string to Id mapping.
|
||||
|
@ -70,23 +70,23 @@ var Thrift = {
|
|||
* @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 @@ var Thrift = {
|
|||
* @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 @@ var Thrift = {
|
|||
function F() {}
|
||||
F.prototype = superConstructor.prototype;
|
||||
constructor.prototype = new F();
|
||||
constructor.prototype.name = name || "";
|
||||
constructor.prototype.name = name || '';
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -171,17 +171,17 @@ Thrift.TException.prototype.getMessage = function() {
|
|||
* @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.TApplicationExceptionType = {
|
|||
*/
|
||||
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');
|
||||
|
||||
|
@ -572,14 +572,16 @@ Thrift.TWebSocketTransport.prototype = {
|
|||
var clientCallback = callback;
|
||||
return function(msg) {
|
||||
self.setRecvBuffer(msg);
|
||||
clientCallback();
|
||||
if (clientCallback) {
|
||||
clientCallback();
|
||||
}
|
||||
};
|
||||
}()));
|
||||
} else {
|
||||
//Queue the send to go out __onOpen
|
||||
this.send_pending.push({
|
||||
buf: this.send_buf,
|
||||
cb: callback
|
||||
cb: callback
|
||||
});
|
||||
}
|
||||
},
|
||||
|
@ -590,8 +592,8 @@ Thrift.TWebSocketTransport.prototype = {
|
|||
//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() {
|
||||
self.socket.send(elem.buf);
|
||||
self.callbacks.push((function() {
|
||||
var clientCallback = elem.cb;
|
||||
return function(msg) {
|
||||
self.setRecvBuffer(msg);
|
||||
|
@ -614,7 +616,7 @@ Thrift.TWebSocketTransport.prototype = {
|
|||
},
|
||||
|
||||
__onError: function(evt) {
|
||||
console.log("Thrift WebSocket Error: " + evt.toString());
|
||||
console.log('Thrift WebSocket Error: ' + evt.toString());
|
||||
this.socket.close();
|
||||
},
|
||||
|
||||
|
@ -1256,7 +1258,12 @@ Thrift.Protocol.prototype = {
|
|||
|
||||
/** Deserializes the end of a list. */
|
||||
readListEnd: function() {
|
||||
this.readFieldEnd();
|
||||
var pos = this.rpos.pop() - 2;
|
||||
var st = this.rstack;
|
||||
st.pop();
|
||||
if (st instanceof Array && st.length > pos && st[pos].length > 0) {
|
||||
st.push(st[pos].shift());
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
|
@ -1312,7 +1319,11 @@ Thrift.Protocol.prototype = {
|
|||
if (f.length === 0) {
|
||||
r.value = undefined;
|
||||
} else {
|
||||
r.value = f.shift();
|
||||
if (!f.isReversed) {
|
||||
f.reverse();
|
||||
f.isReversed = true;
|
||||
}
|
||||
r.value = f.pop();
|
||||
}
|
||||
} else if (f instanceof Object) {
|
||||
for (var i in f) {
|
||||
|
@ -1431,6 +1442,9 @@ Thrift.Protocol.prototype = {
|
|||
}
|
||||
this.readListEnd();
|
||||
return null;
|
||||
|
||||
default:
|
||||
throw new Thrift.TProtocolException(Thrift.TProtocolExceptionType.INVALID_DATA);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
@ -1440,23 +1454,23 @@ Thrift.Protocol.prototype = {
|
|||
* 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 +1485,12 @@ Thrift.Multiplexer = function () {
|
|||
* 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 +1533,7 @@ copyList = function(lst, types) {
|
|||
return result;
|
||||
};
|
||||
|
||||
copyMap = function(obj, types){
|
||||
copyMap = function(obj, types) {
|
||||
|
||||
if (!obj) {return obj; }
|
||||
|
||||
|
@ -1534,8 +1548,8 @@ copyMap = function(obj, types){
|
|||
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;
|
||||
|
|
5
vendor/git.apache.org/thrift.git/lib/js/test/build.properties
generated
vendored
Normal file
5
vendor/git.apache.org/thrift.git/lib/js/test/build.properties
generated
vendored
Normal file
|
@ -0,0 +1,5 @@
|
|||
# Maven Ant tasks Jar details
|
||||
mvn.ant.task.version=2.1.3
|
||||
mvn.repo=http://repo1.maven.org/maven2
|
||||
mvn.ant.task.url=${mvn.repo}/org/apache/maven/maven-ant-tasks/${mvn.ant.task.version}
|
||||
mvn.ant.task.jar=maven-ant-tasks-${mvn.ant.task.version}.jar
|
46
vendor/git.apache.org/thrift.git/lib/js/test/build.xml
generated
vendored
46
vendor/git.apache.org/thrift.git/lib/js/test/build.xml
generated
vendored
|
@ -31,17 +31,21 @@
|
|||
<!-- the root directory, where you unpack thrift distibution (e.g. thrift-0.x.x.tar.gz) -->
|
||||
<property name="thrift.dir" location="../../../" />
|
||||
<property name="thrift.java.dir" location="${thrift.dir}/lib/java" />
|
||||
<property name="build.tools.dir" location="${thrift.java.dir}/build/tools/"/>
|
||||
<property file="${basedir}/build.properties"/>
|
||||
|
||||
<!-- Include the base java properties file -->
|
||||
<property file="${thrift.java.dir}/build.properties" />
|
||||
<property file="${thrift.java.dir}/gradle.properties" />
|
||||
|
||||
<property name="thrift.compiler" location="${thrift.dir}/compiler/cpp/thrift" />
|
||||
|
||||
<path id="libs.classpath">
|
||||
<fileset dir="${thrift.java.dir}/build/">
|
||||
<include name="*.jar" />
|
||||
<fileset dir="${thrift.java.dir}/build/libs">
|
||||
<include name="libthrift*.jar" />
|
||||
<exclude name="libthrift*javadoc.jar" />
|
||||
<exclude name="libthrift*sources.jar" />
|
||||
</fileset>
|
||||
<fileset dir="${thrift.java.dir}/build/lib">
|
||||
<fileset dir="${thrift.java.dir}/build/deps">
|
||||
<include name="*.jar" />
|
||||
</fileset>
|
||||
<fileset dir="${build}/lib">
|
||||
|
@ -59,15 +63,16 @@
|
|||
<condition>
|
||||
<not>
|
||||
<resourcecount count="2">
|
||||
<fileset id="fs" dir="${thrift.java.dir}/build">
|
||||
<fileset id="fs" dir="${thrift.java.dir}/build/libs">
|
||||
<include name="libthrift*.jar" />
|
||||
<exclude name="libthrift*javadoc.jar" />
|
||||
<exclude name="libthrift*sources.jar" />
|
||||
</fileset>
|
||||
</resourcecount>
|
||||
</not>
|
||||
</condition>
|
||||
You need libthrift*.jar and libthrift*test.jar located at
|
||||
${thrift.java.dir}/build
|
||||
${thrift.java.dir}/build/libs
|
||||
Did you compile Thrift Java library and its test suite by "ant compile-test"?
|
||||
</fail>
|
||||
<fail>
|
||||
|
@ -84,6 +89,7 @@
|
|||
|
||||
<target name="init" depends="dependencies">
|
||||
<tstamp />
|
||||
<mkdir dir="${build.tools.dir}"/>
|
||||
<mkdir dir="${build}"/>
|
||||
<mkdir dir="${build}/js/lib"/>
|
||||
<mkdir dir="${build}/lib"/>
|
||||
|
@ -92,16 +98,19 @@
|
|||
<mkdir dir="${build}/test/log"/>
|
||||
</target>
|
||||
|
||||
<target name="jslibs" depends="init, proxy">
|
||||
<target name="download_jslibs">
|
||||
<get src="http://code.jquery.com/jquery-1.11.3.min.js" dest="${build}/js/lib/jquery.js" usetimestamp="true"/>
|
||||
<get src="http://code.jquery.com/qunit/qunit-1.18.0.js" dest="${build}/js/lib/qunit.js" usetimestamp="true"/>
|
||||
<get src="http://code.jquery.com/qunit/qunit-1.18.0.css" dest="${build}/js/lib/qunit.css" usetimestamp="true"/>
|
||||
<get src="http://code.jquery.com/qunit/qunit-2.6.2.js" dest="${build}/js/lib/qunit.js" usetimestamp="true"/>
|
||||
<get src="http://code.jquery.com/qunit/qunit-2.6.2.css" dest="${build}/js/lib/qunit.css" usetimestamp="true"/>
|
||||
</target>
|
||||
|
||||
<target name="jslibs" depends="init, proxy, download_jslibs">
|
||||
</target>
|
||||
|
||||
<target name="compile" description="compile the test suite" depends="init, generate, resolve">
|
||||
<!-- //TODO enable <compilerarg value="-Xlint"/>-->
|
||||
<javac includeantruntime="false" srcdir="${genjava}" destdir="${build}/test" classpathref="libs.classpath"/>
|
||||
<javac includeantruntime="false" srcdir="${src}" destdir="${build}/test" classpathref="libs.classpath"/>
|
||||
<javac compiler="modern" includeantruntime="false" srcdir="${genjava}" destdir="${build}/test" classpathref="libs.classpath"/>
|
||||
<javac compiler="modern" includeantruntime="false" srcdir="${src}" destdir="${build}/test" classpathref="libs.classpath"/>
|
||||
</target>
|
||||
|
||||
<target name="jstest" description="create the test suite jar file" depends="compile">
|
||||
|
@ -161,6 +170,9 @@
|
|||
<exec executable="${thrift.compiler}" failonerror="true">
|
||||
<arg line="--gen js:jquery ${thrift.dir}/test/ThriftTest.thrift" />
|
||||
</exec>
|
||||
<exec executable="${thrift.compiler}" failonerror="true">
|
||||
<arg line="--gen js:jquery ${thrift.dir}/test/DoubleConstantsTest.thrift" />
|
||||
</exec>
|
||||
</target>
|
||||
|
||||
<target name="test" description="run test suite (lint, unittest)" depends="lint, unittest"/>
|
||||
|
@ -207,7 +219,17 @@
|
|||
<delete dir="${genjs}" />
|
||||
</target>
|
||||
|
||||
<target name="resolve" unless="mvn.finished">
|
||||
<target name="mvn.ant.tasks.download" depends="init,mvn.ant.tasks.check" unless="mvn.ant.tasks.found">
|
||||
<get src="${mvn.ant.task.url}/${mvn.ant.task.jar}" dest="${build.tools.dir}/${mvn.ant.task.jar}" usetimestamp="true"/>
|
||||
</target>
|
||||
|
||||
<target name="mvn.ant.tasks.check">
|
||||
<condition property="mvn.ant.tasks.found">
|
||||
<typefound uri="antlib:org.apache.maven.artifact.ant" name="artifact"/>
|
||||
</condition>
|
||||
</target>
|
||||
|
||||
<target name="resolve" depends="mvn.ant.tasks.download" unless="mvn.finished">
|
||||
<typedef uri="antlib:org.apache.maven.artifact.ant" classpath="${thrift.java.dir}/build/tools/${mvn.ant.task.jar}"/>
|
||||
|
||||
<artifact:dependencies filesetId="js.test.dependency.jars">
|
||||
|
|
76
vendor/git.apache.org/thrift.git/lib/js/test/deep-constructor.test.js
generated
vendored
76
vendor/git.apache.org/thrift.git/lib/js/test/deep-constructor.test.js
generated
vendored
|
@ -1,18 +1,18 @@
|
|||
function serialize(data) {
|
||||
var transport = new Thrift.Transport("/service");
|
||||
var protocol = new Thrift.Protocol(transport);
|
||||
protocol.writeMessageBegin("", 0, 0);
|
||||
const transport = new Thrift.Transport('/service');
|
||||
const 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");
|
||||
const transport = new Thrift.Transport('/service');
|
||||
transport.setRecvBuffer(serialized);
|
||||
var protocol = new Thrift.Protocol(transport);
|
||||
const protocol = new Thrift.Protocol(transport);
|
||||
protocol.readMessageBegin();
|
||||
var data = new type();
|
||||
const data = new type();
|
||||
data.read(protocol);
|
||||
protocol.readMessageEnd();
|
||||
return data;
|
||||
|
@ -27,12 +27,12 @@ function createThriftObj() {
|
|||
|
||||
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: {
|
||||
|
@ -61,7 +61,13 @@ function createThriftObj() {
|
|||
DB: new Simple({value: 'k'})
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
|
||||
list_of_list_field: [
|
||||
['one', 'two'],
|
||||
['three', 'four'],
|
||||
['five', 'six']
|
||||
]
|
||||
}
|
||||
);
|
||||
}
|
||||
|
@ -75,12 +81,12 @@ function createJsObj() {
|
|||
|
||||
struct_list_field: [
|
||||
{value: 'b'},
|
||||
{value: 'c'},
|
||||
{value: 'c'}
|
||||
],
|
||||
|
||||
struct_set_field: [
|
||||
{value: 'd'},
|
||||
{value: 'e'},
|
||||
{value: 'e'}
|
||||
],
|
||||
|
||||
struct_map_field: {
|
||||
|
@ -108,7 +114,13 @@ function createJsObj() {
|
|||
DB: {value: 'k'}
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
|
||||
list_of_list_field: [
|
||||
['one', 'two'],
|
||||
['three', 'four'],
|
||||
['five', 'six']
|
||||
]
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -125,38 +137,44 @@ function assertValues(obj, assert) {
|
|||
assert.equal(obj.struct_nested_containers_field[0][0].C[1].value, 'i');
|
||||
assert.equal(obj.struct_nested_containers_field2.D[0].DA.value, 'j');
|
||||
assert.equal(obj.struct_nested_containers_field2.D[1].DB.value, 'k');
|
||||
assert.equal(obj.list_of_list_field[0][0], 'one');
|
||||
assert.equal(obj.list_of_list_field[0][1], 'two');
|
||||
assert.equal(obj.list_of_list_field[1][0], 'three');
|
||||
assert.equal(obj.list_of_list_field[1][1], 'four');
|
||||
assert.equal(obj.list_of_list_field[2][0], 'five');
|
||||
assert.equal(obj.list_of_list_field[2][1], 'six');
|
||||
}
|
||||
|
||||
var cases = {
|
||||
const cases = {
|
||||
|
||||
"Serialize/deserialize simple struct should return equal object": function(assert){
|
||||
var tObj = new Simple({value: 'a'});
|
||||
var received = deserialize(serialize(tObj), Simple);
|
||||
'Serialize/deserialize simple struct should return equal object': function(assert) {
|
||||
const tObj = new Simple({value: 'a'});
|
||||
const received = deserialize(serialize(tObj), Simple);
|
||||
assert.ok(tObj !== received);
|
||||
assert.deepEqual(received, tObj);
|
||||
},
|
||||
|
||||
|
||||
"Serialize/deserialize should return equal object": function(assert){
|
||||
var tObj = createThriftObj();
|
||||
var received = deserialize(serialize(tObj), Complex);
|
||||
'Serialize/deserialize should return equal object': function(assert) {
|
||||
const tObj = createThriftObj();
|
||||
const 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) {
|
||||
var tObj1 = createThriftObj();
|
||||
var tObj2 = new Complex(createJsObj());
|
||||
'Nested structs and containers initialized from plain js objects should serialize same as if initialized from thrift objects': function(assert) {
|
||||
const tObj1 = createThriftObj();
|
||||
const 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();
|
||||
const args = createJsObj();
|
||||
assertValues(args, assert);
|
||||
|
||||
var tObj = new Complex(args);
|
||||
const tObj = new Complex(args);
|
||||
assertValues(tObj, assert);
|
||||
|
||||
args.struct_field.value = 'ZZZ';
|
||||
|
@ -174,8 +192,8 @@ var cases = {
|
|||
assertValues(tObj, assert);
|
||||
},
|
||||
|
||||
"nulls are ok": function(assert) {
|
||||
var tObj = new Complex({
|
||||
'nulls are ok': function(assert) {
|
||||
const tObj = new Complex({
|
||||
struct_field: null,
|
||||
struct_list_field: null,
|
||||
struct_set_field: null,
|
||||
|
@ -183,7 +201,7 @@ var cases = {
|
|||
struct_nested_containers_field: null,
|
||||
struct_nested_containers_field2: null
|
||||
});
|
||||
var received = deserialize(serialize(tObj), Complex);
|
||||
const received = deserialize(serialize(tObj), Complex);
|
||||
assert.ok(tObj !== received);
|
||||
assert.deepEqual(tObj, received);
|
||||
}
|
||||
|
@ -191,5 +209,5 @@ var cases = {
|
|||
};
|
||||
|
||||
Object.keys(cases).forEach(function(caseName) {
|
||||
test(caseName, cases[caseName]);
|
||||
QUnit.test(caseName, cases[caseName]);
|
||||
});
|
||||
|
|
1
vendor/git.apache.org/thrift.git/lib/js/test/jsTestDriver.conf
generated
vendored
1
vendor/git.apache.org/thrift.git/lib/js/test/jsTestDriver.conf
generated
vendored
|
@ -7,6 +7,7 @@ load:
|
|||
# dependencies
|
||||
- build/js/lib/jquery.js
|
||||
- build/js/thrift.js
|
||||
- gen-js/DoubleConstantsTest_constants.js
|
||||
- gen-js/ThriftTest_types.js
|
||||
- gen-js/ThriftTest.js
|
||||
# the test suite
|
||||
|
|
136
vendor/git.apache.org/thrift.git/lib/js/test/phantom-client.js
generated
vendored
136
vendor/git.apache.org/thrift.git/lib/js/test/phantom-client.js
generated
vendored
|
@ -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));
|
||||
|
|
24
vendor/git.apache.org/thrift.git/lib/js/test/phantomjs-qunit.js
generated
vendored
24
vendor/git.apache.org/thrift.git/lib/js/test/phantomjs-qunit.js
generated
vendored
|
@ -28,18 +28,18 @@ function waitFor(testFx, onReady, timeOutMillis) {
|
|||
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 @@ page.onConsoleMessage = function(msg) {
|
|||
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 {
|
||||
|
|
34
vendor/git.apache.org/thrift.git/lib/js/test/server_http.js
generated
vendored
34
vendor/git.apache.org/thrift.git/lib/js/test/server_http.js
generated
vendored
|
@ -17,33 +17,39 @@
|
|||
* under the License.
|
||||
*/
|
||||
|
||||
//This HTTP server is designed to serve the test.html browser
|
||||
// based JavaScript test page (which must be in the current directory).
|
||||
// This HTTP server is designed to serve the test.html browser
|
||||
// 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).
|
||||
//
|
||||
// Using the command flag --es6, this server can be run using nodejs code built
|
||||
// for the es6 environment or for pre-es6 environment.
|
||||
//
|
||||
|
||||
var thrift = require('../../nodejs/lib/thrift');
|
||||
var ThriftTestSvc = require('./gen-nodejs/ThriftTest.js');
|
||||
var ThriftTestHandler = require('./test_handler').ThriftTestHandler;
|
||||
const thrift = require('../../nodejs/lib/thrift');
|
||||
const es6Mode = process.argv.includes('--es6');
|
||||
const genFolder = es6Mode ? 'gen-nodejs-es6' : 'gen-nodejs';
|
||||
const ThriftTestSvc = require(`./${genFolder}/ThriftTest.js`);
|
||||
const ThriftTestHandler = require('./test_handler').ThriftTestHandler;
|
||||
|
||||
var ThriftTestSvcOpt = {
|
||||
const ThriftTestSvcOpt = {
|
||||
transport: thrift.TBufferedTransport,
|
||||
protocol: thrift.TJSONProtocol,
|
||||
processor: ThriftTestSvc,
|
||||
handler: ThriftTestHandler
|
||||
};
|
||||
|
||||
var ThriftWebServerOptions = {
|
||||
files: ".",
|
||||
const ThriftWebServerOptions = {
|
||||
files: __dirname,
|
||||
services: {
|
||||
"/service": ThriftTestSvcOpt
|
||||
'/service': ThriftTestSvcOpt
|
||||
}
|
||||
};
|
||||
|
||||
var server = thrift.createWebServer(ThriftWebServerOptions);
|
||||
var port = 8088;
|
||||
const server = thrift.createWebServer(ThriftWebServerOptions);
|
||||
const port = es6Mode ? 8088 : 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 (ES6 mode ${es6Mode}) running on port: ${port}`);
|
||||
|
|
34
vendor/git.apache.org/thrift.git/lib/js/test/server_https.js
generated
vendored
34
vendor/git.apache.org/thrift.git/lib/js/test/server_https.js
generated
vendored
|
@ -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,32 +26,34 @@
|
|||
// support libraries for test.html (jquery.js, qunit.js and qunit.css
|
||||
// in ./build/js/lib).
|
||||
|
||||
var fs = require("fs");
|
||||
var thrift = require('../../nodejs/lib/thrift');
|
||||
var ThriftTestSvc = require('./gen-nodejs/ThriftTest.js');
|
||||
var ThriftTestHandler = require('./test_handler').ThriftTestHandler;
|
||||
const fs = require('fs');
|
||||
const thrift = require('../../nodejs/lib/thrift');
|
||||
const es6Mode = process.argv.includes('--es6');
|
||||
const genFolder = es6Mode ? 'gen-nodejs-es6' : 'gen-nodejs';
|
||||
const ThriftTestSvc = require(`./${genFolder}/ThriftTest.js`);
|
||||
const ThriftTestHandler = require('./test_handler').ThriftTestHandler;
|
||||
|
||||
//Setup the I/O stack options for the ThriftTest service
|
||||
var ThriftTestSvcOpt = {
|
||||
const ThriftTestSvcOpt = {
|
||||
transport: thrift.TBufferedTransport,
|
||||
protocol: thrift.TJSONProtocol,
|
||||
processor: ThriftTestSvc,
|
||||
handler: ThriftTestHandler
|
||||
};
|
||||
|
||||
var ThriftWebServerOptions = {
|
||||
files: ".",
|
||||
const ThriftWebServerOptions = {
|
||||
files: __dirname,
|
||||
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;
|
||||
const server = thrift.createWebServer(ThriftWebServerOptions);
|
||||
const port = es6Mode ? 8090 : 8091;
|
||||
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 (ES6 mode ${es6Mode}) running on port: ${port}`);
|
||||
|
|
428
vendor/git.apache.org/thrift.git/lib/js/test/test-async.js
generated
vendored
428
vendor/git.apache.org/thrift.git/lib/js/test/test-async.js
generated
vendored
|
@ -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).
|
||||
*
|
||||
|
@ -30,319 +30,341 @@
|
|||
|
||||
|
||||
// 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) {
|
||||
const 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(assert, map1, map2) {
|
||||
if (typeof map1 !== 'function' && typeof map2 !== 'function') {
|
||||
if (!map1 || typeof map1 !== 'object') {
|
||||
equal(map1, map2);
|
||||
assert.equal(map1, map2);
|
||||
} else {
|
||||
for (var key in map1) {
|
||||
checkRecursively(map1[key], map2[key]);
|
||||
for (let key in map1) {
|
||||
checkRecursively(assert, map1[key], map2[key]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
module("Base Types");
|
||||
QUnit.module('Base Types');
|
||||
|
||||
asyncTest("Void", function() {
|
||||
expect( 1 );
|
||||
QUnit.test('Void', function(assert) {
|
||||
assert.expect(1);
|
||||
const done = assert.async();
|
||||
client.testVoid(function(result) {
|
||||
equal(result, undefined);
|
||||
QUnit.start();
|
||||
assert.equal(result, undefined);
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
asyncTest("String", function() {
|
||||
expect( 3 );
|
||||
QUnit.stop(2);
|
||||
client.testString('', function(result){
|
||||
equal(result, '');
|
||||
QUnit.start();
|
||||
|
||||
|
||||
QUnit.test('String', function(assert) {
|
||||
assert.expect(3);
|
||||
const done = assert.async(3);
|
||||
client.testString('', function(result) {
|
||||
assert.equal(result, '');
|
||||
done();
|
||||
});
|
||||
client.testString(stringTest, function(result){
|
||||
equal(result, stringTest);
|
||||
QUnit.start();
|
||||
client.testString(stringTest, function(result) {
|
||||
assert.equal(result, stringTest);
|
||||
done();
|
||||
});
|
||||
|
||||
var specialCharacters = 'quote: \" backslash:' +
|
||||
const specialCharacters = 'quote: \" backslash:' +
|
||||
' forwardslash-escaped: \/ ' +
|
||||
' 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){
|
||||
equal(result, specialCharacters);
|
||||
QUnit.start();
|
||||
client.testString(specialCharacters, function(result) {
|
||||
assert.equal(result, specialCharacters);
|
||||
done();
|
||||
});
|
||||
});
|
||||
asyncTest("Double", function() {
|
||||
expect( 4 );
|
||||
QUnit.stop(3);
|
||||
client.testDouble(0, function(result){
|
||||
equal(result, 0);
|
||||
QUnit.start();
|
||||
QUnit.test('Double', function(assert) {
|
||||
assert.expect(4);
|
||||
const done = assert.async(4);
|
||||
client.testDouble(0, function(result) {
|
||||
assert.equal(result, 0);
|
||||
done();
|
||||
});
|
||||
client.testDouble(-1, function(result){
|
||||
equal(result, -1);
|
||||
QUnit.start();
|
||||
client.testDouble(-1, function(result) {
|
||||
assert.equal(result, -1);
|
||||
done();
|
||||
});
|
||||
client.testDouble(3.14, function(result){
|
||||
equal(result, 3.14);
|
||||
QUnit.start();
|
||||
client.testDouble(3.14, function(result) {
|
||||
assert.equal(result, 3.14);
|
||||
done();
|
||||
});
|
||||
client.testDouble(Math.pow(2,60), function(result){
|
||||
equal(result, Math.pow(2,60));
|
||||
QUnit.start();
|
||||
client.testDouble(Math.pow(2, 60), function(result) {
|
||||
assert.equal(result, Math.pow(2, 60));
|
||||
done();
|
||||
});
|
||||
});
|
||||
// TODO: add testBinary()
|
||||
asyncTest("Byte", function() {
|
||||
expect( 2 );
|
||||
QUnit.stop();
|
||||
// TODO: add testBinary()
|
||||
QUnit.test('Byte', function(assert) {
|
||||
assert.expect(2);
|
||||
const done = assert.async(2);
|
||||
client.testByte(0, function(result) {
|
||||
equal(result, 0);
|
||||
QUnit.start();
|
||||
assert.equal(result, 0);
|
||||
done();
|
||||
});
|
||||
client.testByte(0x01, function(result) {
|
||||
equal(result, 0x01);
|
||||
QUnit.start();
|
||||
assert.equal(result, 0x01);
|
||||
done();
|
||||
});
|
||||
});
|
||||
asyncTest("I32", function() {
|
||||
expect( 3 );
|
||||
QUnit.stop(2);
|
||||
client.testI32(0, function(result){
|
||||
equal(result, 0);
|
||||
QUnit.start();
|
||||
QUnit.test('I32', function(assert) {
|
||||
assert.expect(3);
|
||||
const done = assert.async(3);
|
||||
client.testI32(0, function(result) {
|
||||
assert.equal(result, 0);
|
||||
done();
|
||||
});
|
||||
client.testI32(Math.pow(2,30), function(result){
|
||||
equal(result, Math.pow(2,30));
|
||||
QUnit.start();
|
||||
client.testI32(Math.pow(2, 30), function(result) {
|
||||
assert.equal(result, Math.pow(2, 30));
|
||||
done();
|
||||
});
|
||||
client.testI32(-Math.pow(2,30), function(result){
|
||||
equal(result, -Math.pow(2,30));
|
||||
QUnit.start();
|
||||
client.testI32(-Math.pow(2, 30), function(result) {
|
||||
assert.equal(result, -Math.pow(2, 30));
|
||||
done();
|
||||
});
|
||||
});
|
||||
asyncTest("I64", function() {
|
||||
expect( 3 );
|
||||
QUnit.stop(2);
|
||||
client.testI64(0, function(result){
|
||||
equal(result, 0);
|
||||
QUnit.start();
|
||||
QUnit.test('I64', function(assert) {
|
||||
assert.expect(3);
|
||||
const done = assert.async(3);
|
||||
client.testI64(0, function(result) {
|
||||
assert.equal(result, 0);
|
||||
done();
|
||||
});
|
||||
//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));
|
||||
QUnit.start();
|
||||
client.testI64(Math.pow(2, 52), function(result) {
|
||||
assert.equal(result, Math.pow(2, 52));
|
||||
done();
|
||||
});
|
||||
client.testI64(-Math.pow(2,52), function(result){
|
||||
equal(result, -Math.pow(2,52));
|
||||
QUnit.start();
|
||||
client.testI64(-Math.pow(2, 52), function(result) {
|
||||
assert.equal(result, -Math.pow(2, 52));
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
|
||||
|
||||
module("Structured Types");
|
||||
|
||||
asyncTest("Struct", function() {
|
||||
expect( 5 );
|
||||
var structTestInput = new ThriftTest.Xtruct();
|
||||
|
||||
QUnit.module('Structured Types');
|
||||
|
||||
QUnit.test('Struct', function(assert) {
|
||||
assert.expect(5);
|
||||
const done = assert.async();
|
||||
const 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){
|
||||
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();
|
||||
client.testStruct(structTestInput, function(result) {
|
||||
assert.equal(result.string_thing, structTestInput.string_thing);
|
||||
assert.equal(result.byte_thing, structTestInput.byte_thing);
|
||||
assert.equal(result.i32_thing, structTestInput.i32_thing);
|
||||
assert.equal(result.i64_thing, structTestInput.i64_thing);
|
||||
assert.equal(JSON.stringify(result), JSON.stringify(structTestInput));
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
asyncTest("Nest", function() {
|
||||
expect( 7 );
|
||||
var xtrTestInput = new ThriftTest.Xtruct();
|
||||
QUnit.test('Nest', function(assert) {
|
||||
assert.expect(7);
|
||||
const done = assert.async();
|
||||
const 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);
|
||||
|
||||
var nestTestInput = new ThriftTest.Xtruct2();
|
||||
xtrTestInput.i64_thing = Math.pow(2, 52);
|
||||
|
||||
const nestTestInput = new ThriftTest.Xtruct2();
|
||||
nestTestInput.byte_thing = 0x02;
|
||||
nestTestInput.struct_thing = xtrTestInput;
|
||||
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(JSON.stringify(result), JSON.stringify(nestTestInput));
|
||||
QUnit.start();
|
||||
nestTestInput.i32_thing = Math.pow(2, 15);
|
||||
|
||||
client.testNest(nestTestInput, function(result) {
|
||||
assert.equal(result.byte_thing, nestTestInput.byte_thing);
|
||||
assert.equal(result.struct_thing.string_thing, nestTestInput.struct_thing.string_thing);
|
||||
assert.equal(result.struct_thing.byte_thing, nestTestInput.struct_thing.byte_thing);
|
||||
assert.equal(result.struct_thing.i32_thing, nestTestInput.struct_thing.i32_thing);
|
||||
assert.equal(result.struct_thing.i64_thing, nestTestInput.struct_thing.i64_thing);
|
||||
assert.equal(result.i32_thing, nestTestInput.i32_thing);
|
||||
assert.equal(JSON.stringify(result), JSON.stringify(nestTestInput));
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
asyncTest("Map", function() {
|
||||
expect( 3 );
|
||||
var mapTestInput = {7:77, 8:88, 9:99};
|
||||
QUnit.test('Map', function(assert) {
|
||||
assert.expect(3);
|
||||
const done = assert.async();
|
||||
const mapTestInput = {7: 77, 8: 88, 9: 99};
|
||||
|
||||
client.testMap(mapTestInput, function(result){
|
||||
for (var key in result) {
|
||||
equal(result[key], mapTestInput[key]);
|
||||
client.testMap(mapTestInput, function(result) {
|
||||
for (let key in result) {
|
||||
assert.equal(result[key], mapTestInput[key]);
|
||||
}
|
||||
QUnit.start();
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
asyncTest("StringMap", function() {
|
||||
expect( 6 );
|
||||
var mapTestInput = {
|
||||
"a":"123", "a b":"with spaces ", "same":"same", "0":"numeric key",
|
||||
"longValue":stringTest, stringTest:"long key"
|
||||
QUnit.test('StringMap', function(assert) {
|
||||
assert.expect(6);
|
||||
const done = assert.async();
|
||||
const 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]);
|
||||
client.testStringMap(mapTestInput, function(result) {
|
||||
for (let key in result) {
|
||||
assert.equal(result[key], mapTestInput[key]);
|
||||
}
|
||||
QUnit.start();
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
asyncTest("Set", function() {
|
||||
expect( 1 );
|
||||
var setTestInput = [1,2,3];
|
||||
client.testSet(setTestInput, function(result){
|
||||
ok(result, setTestInput);
|
||||
QUnit.start();
|
||||
QUnit.test('Set', function(assert) {
|
||||
assert.expect(1);
|
||||
const done = assert.async();
|
||||
const setTestInput = [1, 2, 3];
|
||||
client.testSet(setTestInput, function(result) {
|
||||
assert.ok(result, setTestInput);
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
asyncTest("List", function() {
|
||||
expect( 1 );
|
||||
var listTestInput = [1,2,3];
|
||||
client.testList(listTestInput, function(result){
|
||||
ok(result, listTestInput);
|
||||
QUnit.start();
|
||||
QUnit.test('List', function(assert) {
|
||||
assert.expect(1);
|
||||
const done = assert.async();
|
||||
const listTestInput = [1, 2, 3];
|
||||
client.testList(listTestInput, function(result) {
|
||||
assert.ok(result, listTestInput);
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
asyncTest("Enum", function() {
|
||||
expect( 1 );
|
||||
client.testEnum(ThriftTest.Numberz.ONE, function(result){
|
||||
equal(result, ThriftTest.Numberz.ONE);
|
||||
QUnit.start();
|
||||
QUnit.test('Enum', function(assert) {
|
||||
assert.expect(1);
|
||||
const done = assert.async();
|
||||
client.testEnum(ThriftTest.Numberz.ONE, function(result) {
|
||||
assert.equal(result, ThriftTest.Numberz.ONE);
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
asyncTest("TypeDef", function() {
|
||||
expect( 1 );
|
||||
client.testTypedef(69, function(result){
|
||||
equal(result, 69);
|
||||
QUnit.start();
|
||||
QUnit.test('TypeDef', function(assert) {
|
||||
assert.expect(1);
|
||||
const done = assert.async();
|
||||
client.testTypedef(69, function(result) {
|
||||
assert.equal(result, 69);
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
module("deeper!");
|
||||
QUnit.module('deeper!');
|
||||
|
||||
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}
|
||||
QUnit.test('MapMap', function(assert) {
|
||||
assert.expect(16);
|
||||
const done = assert.async();
|
||||
const mapMapTestExpectedResult = {
|
||||
'4': {'1': 1, '2': 2, '3': 3, '4': 4},
|
||||
'-4': {'-4': -4, '-3': -3, '-2': -2, '-1': -1}
|
||||
};
|
||||
|
||||
client.testMapMap(1, function(result){
|
||||
for (var key in result) {
|
||||
for (var key2 in result[key]) {
|
||||
equal(result[key][key2], mapMapTestExpectedResult[key][key2]);
|
||||
client.testMapMap(1, function(result) {
|
||||
for (let key in result) {
|
||||
for (let key2 in result[key]) {
|
||||
assert.equal(result[key][key2], mapMapTestExpectedResult[key][key2]);
|
||||
}
|
||||
}
|
||||
checkRecursively(result, mapMapTestExpectedResult);
|
||||
QUnit.start();
|
||||
checkRecursively(assert, result, mapMapTestExpectedResult);
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
module("Exception");
|
||||
QUnit.module('Exception');
|
||||
|
||||
asyncTest("Xception", function() {
|
||||
expect(2);
|
||||
client.testException("Xception", function(e){
|
||||
equal(e.errorCode, 1001);
|
||||
equal(e.message, "Xception");
|
||||
QUnit.start();
|
||||
QUnit.test('Xception', function(assert) {
|
||||
assert.expect(2);
|
||||
const done = assert.async();
|
||||
client.testException('Xception', function(e) {
|
||||
assert.equal(e.errorCode, 1001);
|
||||
assert.equal(e.message, 'Xception');
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
asyncTest("no Exception", 0, function() {
|
||||
expect( 1 );
|
||||
client.testException("no Exception", function(e){
|
||||
ok(!e);
|
||||
QUnit.start();
|
||||
QUnit.test('no Exception', function(assert) {
|
||||
assert.expect(1);
|
||||
const done = assert.async();
|
||||
client.testException('no Exception', function(e) {
|
||||
assert.ok(!e);
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
module("Insanity");
|
||||
QUnit.module('Insanity');
|
||||
|
||||
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
|
||||
QUnit.test('testInsanity', function(assert) {
|
||||
assert.expect(24);
|
||||
const done = assert.async();
|
||||
const insanity = {
|
||||
'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){
|
||||
ok(res, JSON.stringify(res));
|
||||
ok(insanity, JSON.stringify(insanity));
|
||||
checkRecursively(res, insanity);
|
||||
QUnit.start();
|
||||
client.testInsanity(new ThriftTest.Insanity(), function(res) {
|
||||
assert.ok(res, JSON.stringify(res));
|
||||
assert.ok(insanity, JSON.stringify(insanity));
|
||||
checkRecursively(assert, res, insanity);
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
QUnit.module('Oneway');
|
||||
|
||||
QUnit.test('testOneway', function(assert) {
|
||||
assert.expect(1);
|
||||
const done = assert.async();
|
||||
client.testOneway(1, function(result) {
|
||||
assert.equal(result, undefined);
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
|
6
vendor/git.apache.org/thrift.git/lib/js/test/test-deep-constructor.html
generated
vendored
6
vendor/git.apache.org/thrift.git/lib/js/test/test-deep-constructor.html
generated
vendored
|
@ -25,11 +25,11 @@
|
|||
<script src="build/js/thrift.js" type="text/javascript" charset="utf-8"></script>
|
||||
<script src="gen-js/JsDeepConstructorTest_types.js" type="text/javascript" charset="utf-8"></script>
|
||||
<!-- jQuery -->
|
||||
<script type="text/javascript" src="http://code.jquery.com/jquery-1.7.2.js" charset="utf-8"></script>
|
||||
<script type="text/javascript" src="build/js/lib/jquery.js" charset="utf-8"></script>
|
||||
|
||||
<!-- QUnit Test framework-->
|
||||
<script type="text/javascript" src="http://code.jquery.com/qunit/qunit-1.14.0.js" charset="utf-8"></script>
|
||||
<link rel="stylesheet" href="http://code.jquery.com/qunit/qunit-1.14.0.css" type="text/css" media="screen" />
|
||||
<script type="text/javascript" src="build/js/lib/qunit.js" charset="utf-8"></script>
|
||||
<link rel="stylesheet" href="build/js/lib/qunit.css" type="text/css" media="screen" />
|
||||
|
||||
<!-- the Test Suite-->
|
||||
<script type="text/javascript" src="deep-constructor.test.js" charset="utf-8"></script>
|
||||
|
|
55
vendor/git.apache.org/thrift.git/lib/js/test/test-double-rendering.html
generated
vendored
Normal file
55
vendor/git.apache.org/thrift.git/lib/js/test/test-double-rendering.html
generated
vendored
Normal file
|
@ -0,0 +1,55 @@
|
|||
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
|
||||
<!--
|
||||
Licensed to the Apache Software Foundation (ASF) under one
|
||||
or more contributor license agreements. See the NOTICE file
|
||||
distributed with this work for additional information
|
||||
regarding copyright ownership. The ASF licenses this file
|
||||
to you under the Apache License, Version 2.0 (the
|
||||
"License"); you may not use this file except in compliance
|
||||
with the License. You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing,
|
||||
software distributed under the License is distributed on an
|
||||
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
KIND, either express or implied. See the License for the
|
||||
specific language governing permissions and limitations
|
||||
under the License.
|
||||
-->
|
||||
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
||||
<title>Rendering Double Constants in JS: Unit Test</title>
|
||||
|
||||
<script src="build/js/thrift.js" type="text/javascript" charset="utf-8"></script>
|
||||
<script src="gen-js/ThriftTest_types.js" type="text/javascript" charset="utf-8"></script>
|
||||
<script src="gen-js/ThriftTest.js" type="text/javascript" charset="utf-8"></script>
|
||||
<!-- double constants to check -->
|
||||
<script src="gen-js/DoubleConstantsTest_types.js" type="text/javascript" charset="utf-8"></script>
|
||||
|
||||
<!-- jQuery -->
|
||||
<script type="text/javascript" src="../node_modules/jquery/dist/jquery.js" charset="utf-8"></script>
|
||||
|
||||
<!-- QUnit Test framework-->
|
||||
<script type="text/javascript" src="../node_modules/qunit/qunit/qunit.js" charset="utf-8"></script>
|
||||
<link rel="stylesheet" href="../node_modules/qunit/qunit/qunit.css" type="text/css" media="screen" />
|
||||
|
||||
<!-- the Test Suite-->
|
||||
<script type="text/javascript" src="test-double-rendering.js" charset="utf-8"></script>
|
||||
</head>
|
||||
<body>
|
||||
<h1 id="qunit-header">Rendering Double Constants in JS: Unit Test</h1>
|
||||
<h2 id="qunit-banner"></h2>
|
||||
<div id="qunit-testrunner-toolbar"></div>
|
||||
<h2 id="qunit-userAgent"></h2>
|
||||
<ol id="qunit-tests"><li><!-- get valid xhtml strict--></li></ol>
|
||||
<!-- Uncomment this to check the validity. This significantly slows down the test.
|
||||
<p>
|
||||
<a href="http://validator.w3.org/check/referer"><img
|
||||
src="http://www.w3.org/Icons/valid-xhtml10"
|
||||
alt="Valid XHTML 1.0!" height="31" width="88" /></a>
|
||||
</p>
|
||||
-->
|
||||
</body>
|
||||
</html>
|
143
vendor/git.apache.org/thrift.git/lib/js/test/test-double-rendering.js
generated
vendored
Normal file
143
vendor/git.apache.org/thrift.git/lib/js/test/test-double-rendering.js
generated
vendored
Normal file
|
@ -0,0 +1,143 @@
|
|||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
/* jshint -W100 */
|
||||
|
||||
/*
|
||||
* JavaScript test suite for double constants inside
|
||||
* DebugProtoTest.thrift. These tests will run against Normal (-gen js)
|
||||
* Apache Thrift interfaces.
|
||||
*
|
||||
* Synchronous blocking calls should be identical in both
|
||||
* Normal and jQuery interfaces. All synchronous tests belong
|
||||
* here.
|
||||
*
|
||||
* Asynchronous success callbacks passed as the last parameter
|
||||
* of an RPC call should be identical in both Normal and jQuery
|
||||
* interfaces. Async success tests belong here.
|
||||
*
|
||||
* Asynchronous exception processing is different in Normal
|
||||
* and jQuery interfaces. Such tests belong in the test-nojq.js
|
||||
* or test-jq.js files respectively. jQuery specific XHR object
|
||||
* tests also belong in test-jq.js. Do not create any jQuery
|
||||
* dependencies in this file or in test-nojq.js
|
||||
*
|
||||
* To compile client code for this test use:
|
||||
* $ thrift -gen js ThriftTest.thrift
|
||||
* $ thrift -gen js DebugProtoTest.thrift
|
||||
*
|
||||
* See also:
|
||||
* ++ test-nojq.js for "-gen js" only tests
|
||||
*/
|
||||
|
||||
// double assertion threshold
|
||||
const EPSILON = 0.0000001;
|
||||
|
||||
// Work around for old API used by QUnitAdapter of jsTestDriver
|
||||
if (typeof QUnit.log == 'function') {
|
||||
// When using real QUnit (fron PhantomJS) log failures to console
|
||||
QUnit.log(function(details) {
|
||||
if (!details.result) {
|
||||
console.log('======== FAIL ========');
|
||||
console.log('TestName: ' + details.name);
|
||||
if (details.message) console.log(details.message);
|
||||
console.log('Expected: ' + details.expected);
|
||||
console.log('Actual : ' + details.actual);
|
||||
console.log('======================');
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
QUnit.module('Double rendering');
|
||||
|
||||
QUnit.test('Double (rendering)', function(assert) {
|
||||
console.log('Double rendering test -- starts');
|
||||
const EXPECTED_DOUBLE_ASSIGNED_TO_INT_CONSTANT = 1;
|
||||
const EXPECTED_DOUBLE_ASSIGNED_TO_NEGATIVE_INT_CONSTANT = -100;
|
||||
const EXPECTED_DOUBLE_ASSIGNED_TO_LARGEST_INT_CONSTANT = 9223372036854775807;
|
||||
const EXPECTED_DOUBLE_ASSIGNED_TO_SMALLEST_INT_CONSTANT = -9223372036854775807;
|
||||
const EXPECTED_DOUBLE_ASSIGNED_TO_DOUBLE_WITH_MANY_DECIMALS = 3.14159265359;
|
||||
const EXPECTED_DOUBLE_ASSIGNED_TO_FRACTIONAL_DOUBLE = 1000000.1;
|
||||
const EXPECTED_DOUBLE_ASSIGNED_TO_NEGATIVE_FRACTIONAL_DOUBLE = -1000000.1;
|
||||
const EXPECTED_DOUBLE_ASSIGNED_TO_LARGE_DOUBLE = 1.7e+308;
|
||||
const EXPECTED_DOUBLE_ASSIGNED_TO_LARGE_FRACTIONAL_DOUBLE = 9223372036854775816.43;
|
||||
const EXPECTED_DOUBLE_ASSIGNED_TO_SMALL_DOUBLE = -1.7e+308;
|
||||
const EXPECTED_DOUBLE_ASSIGNED_TO_NEGATIVE_BUT_LARGE_FRACTIONAL_DOUBLE = -9223372036854775816.43;
|
||||
assert.ok(
|
||||
Math.abs(EXPECTED_DOUBLE_ASSIGNED_TO_INT_CONSTANT - DOUBLE_ASSIGNED_TO_INT_CONSTANT_TEST) <= EPSILON);
|
||||
assert.ok(
|
||||
Math.abs(
|
||||
EXPECTED_DOUBLE_ASSIGNED_TO_NEGATIVE_INT_CONSTANT -
|
||||
DOUBLE_ASSIGNED_TO_NEGATIVE_INT_CONSTANT_TEST) <= EPSILON);
|
||||
assert.ok(
|
||||
Math.abs(
|
||||
EXPECTED_DOUBLE_ASSIGNED_TO_LARGEST_INT_CONSTANT -
|
||||
DOUBLE_ASSIGNED_TO_LARGEST_INT_CONSTANT_TEST) <= EPSILON);
|
||||
assert.ok(
|
||||
Math.abs(
|
||||
EXPECTED_DOUBLE_ASSIGNED_TO_SMALLEST_INT_CONSTANT -
|
||||
DOUBLE_ASSIGNED_TO_SMALLEST_INT_CONSTANT_TEST) <= EPSILON);
|
||||
assert.ok(
|
||||
Math.abs(
|
||||
EXPECTED_DOUBLE_ASSIGNED_TO_DOUBLE_WITH_MANY_DECIMALS -
|
||||
DOUBLE_ASSIGNED_TO_DOUBLE_WITH_MANY_DECIMALS_TEST) <= EPSILON);
|
||||
assert.ok(
|
||||
Math.abs(
|
||||
EXPECTED_DOUBLE_ASSIGNED_TO_FRACTIONAL_DOUBLE -
|
||||
DOUBLE_ASSIGNED_TO_FRACTIONAL_DOUBLE_TEST) <= EPSILON);
|
||||
assert.ok(
|
||||
Math.abs(
|
||||
EXPECTED_DOUBLE_ASSIGNED_TO_NEGATIVE_FRACTIONAL_DOUBLE -
|
||||
DOUBLE_ASSIGNED_TO_NEGATIVE_FRACTIONAL_DOUBLE_TEST) <= EPSILON);
|
||||
assert.ok(
|
||||
Math.abs(
|
||||
EXPECTED_DOUBLE_ASSIGNED_TO_LARGE_DOUBLE -
|
||||
DOUBLE_ASSIGNED_TO_LARGE_DOUBLE_TEST) <= EPSILON);
|
||||
assert.ok(
|
||||
Math.abs(
|
||||
EXPECTED_DOUBLE_ASSIGNED_TO_LARGE_FRACTIONAL_DOUBLE -
|
||||
DOUBLE_ASSIGNED_TO_LARGE_FRACTIONAL_DOUBLE_TEST) <= EPSILON);
|
||||
assert.ok(
|
||||
Math.abs(
|
||||
EXPECTED_DOUBLE_ASSIGNED_TO_SMALL_DOUBLE -
|
||||
DOUBLE_ASSIGNED_TO_SMALL_DOUBLE_TEST) <= EPSILON);
|
||||
assert.ok(
|
||||
Math.abs(
|
||||
EXPECTED_DOUBLE_ASSIGNED_TO_NEGATIVE_BUT_LARGE_FRACTIONAL_DOUBLE -
|
||||
DOUBLE_ASSIGNED_TO_NEGATIVE_BUT_LARGE_FRACTIONAL_DOUBLE_TEST) <= EPSILON);
|
||||
assert.equal(typeof DOUBLE_ASSIGNED_TO_INT_CONSTANT_TEST, 'number');
|
||||
assert.equal(typeof DOUBLE_ASSIGNED_TO_NEGATIVE_INT_CONSTANT_TEST, 'number');
|
||||
assert.equal(typeof DOUBLE_ASSIGNED_TO_LARGEST_INT_CONSTANT_TEST, 'number');
|
||||
assert.equal(typeof DOUBLE_ASSIGNED_TO_SMALLEST_INT_CONSTANT_TEST, 'number');
|
||||
assert.equal(typeof DOUBLE_ASSIGNED_TO_DOUBLE_WITH_MANY_DECIMALS_TEST, 'number');
|
||||
assert.equal(typeof DOUBLE_ASSIGNED_TO_FRACTIONAL_DOUBLE_TEST, 'number');
|
||||
assert.equal(typeof DOUBLE_ASSIGNED_TO_NEGATIVE_FRACTIONAL_DOUBLE_TEST, 'number');
|
||||
assert.equal(typeof DOUBLE_ASSIGNED_TO_LARGE_DOUBLE_TEST, 'number');
|
||||
assert.equal(typeof DOUBLE_ASSIGNED_TO_LARGE_FRACTIONAL_DOUBLE_TEST, 'number');
|
||||
assert.equal(typeof DOUBLE_ASSIGNED_TO_SMALL_DOUBLE_TEST, 'number');
|
||||
assert.equal(typeof DOUBLE_ASSIGNED_TO_NEGATIVE_BUT_LARGE_FRACTIONAL_DOUBLE_TEST, 'number');
|
||||
const EXPECTED_DOUBLE_LIST =
|
||||
[1,-100,100,9223372036854775807,-9223372036854775807,3.14159265359,1000000.1,-1000000.1,1.7e+308,-1.7e+308,
|
||||
9223372036854775816.43,-9223372036854775816.43];
|
||||
assert.equal(DOUBLE_LIST_TEST.length, EXPECTED_DOUBLE_LIST.length);
|
||||
for (let i = 0; i < EXPECTED_DOUBLE_LIST.length; ++i) {
|
||||
assert.ok(Math.abs(EXPECTED_DOUBLE_LIST[i] - DOUBLE_LIST_TEST[i]) <= EPSILON);
|
||||
}
|
||||
console.log('Double rendering test -- ends');
|
||||
});
|
||||
|
62
vendor/git.apache.org/thrift.git/lib/js/test/test-es6.html
generated
vendored
Normal file
62
vendor/git.apache.org/thrift.git/lib/js/test/test-es6.html
generated
vendored
Normal file
|
@ -0,0 +1,62 @@
|
|||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
|
||||
<!--
|
||||
Licensed to the Apache Software Foundation (ASF) under one
|
||||
or more contributor license agreements. See the NOTICE file
|
||||
distributed with this work for additional information
|
||||
regarding copyright ownership. The ASF licenses this file
|
||||
to you under the Apache License, Version 2.0 (the
|
||||
"License"); you may not use this file except in compliance
|
||||
with the License. You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing,
|
||||
software distributed under the License is distributed on an
|
||||
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
KIND, either express or implied. See the License for the
|
||||
specific language governing permissions and limitations
|
||||
under the License.
|
||||
-->
|
||||
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
||||
<title>Thrift Javascript Bindings: Unit Test</title>
|
||||
|
||||
<script src="build/js/thrift.js" type="text/javascript" charset="utf-8"></script>
|
||||
<script src="gen-js-es6/ThriftTest_types.js" type="text/javascript" charset="utf-8"></script>
|
||||
<script src="gen-js-es6/ThriftTest.js" type="text/javascript" charset="utf-8"></script>
|
||||
|
||||
<!-- jQuery -->
|
||||
<script type="text/javascript" src="build/js/lib/jquery.js" charset="utf-8"></script>
|
||||
|
||||
<!-- QUnit Test framework-->
|
||||
<script type="text/javascript" src="build/js/lib/qunit.js" charset="utf-8"></script>
|
||||
<link rel="stylesheet" href="build/js/lib/qunit.css" type="text/css" media="screen" />
|
||||
|
||||
<!-- the Test Suite-->
|
||||
<script>
|
||||
const loc = window.location;
|
||||
const ws_uri = ((loc.protocol === "https:") ? "wss://" : "ws://") +
|
||||
loc.hostname + ":" + loc.port + loc.pathname;
|
||||
const transport = new Thrift.TWebSocketTransport(ws_uri);
|
||||
const protocol = new Thrift.Protocol(transport);
|
||||
const client = new ThriftTest.ThriftTestClient(protocol);
|
||||
transport.open();
|
||||
</script>
|
||||
<script type="text/javascript" src="test-es6.js" charset="utf-8"></script>
|
||||
</head>
|
||||
<body>
|
||||
<h1 id="qunit-header">Thrift Javascript Bindings: Unit Test (<a href="https://git-wip-us.apache.org/repos/asf?p=thrift.git;a=blob;f=test/ThriftTest.thrift;hb=HEAD">ThriftTest.thrift</a>)</h1>
|
||||
<h2 id="qunit-banner"></h2>
|
||||
<div id="qunit-testrunner-toolbar"></div>
|
||||
<h2 id="qunit-userAgent"></h2>
|
||||
<ol id="qunit-tests"><li><!-- get valid xhtml strict--></li></ol>
|
||||
<!-- Uncomment this to check the validity. This significantly slows down the test.
|
||||
<p>
|
||||
<a href="http://validator.w3.org/check/referer"><img
|
||||
src="http://www.w3.org/Icons/valid-xhtml10"
|
||||
alt="Valid XHTML 1.0!" height="31" width="88" /></a>
|
||||
</p>
|
||||
-->
|
||||
</body>
|
||||
</html>
|
374
vendor/git.apache.org/thrift.git/lib/js/test/test-es6.js
generated
vendored
Normal file
374
vendor/git.apache.org/thrift.git/lib/js/test/test-es6.js
generated
vendored
Normal file
|
@ -0,0 +1,374 @@
|
|||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
/* jshint -W100 */
|
||||
|
||||
/*
|
||||
* Fully Async JavaScript test suite for ThriftTest.thrift.
|
||||
* These tests are designed to exercise the WebSocket transport
|
||||
* (which is exclusively async).
|
||||
*
|
||||
* To compile client code for this test use:
|
||||
* $ thrift -gen js:es6 ThriftTest.thrift
|
||||
*/
|
||||
|
||||
|
||||
|
||||
// all Languages in UTF-8
|
||||
|
||||
const 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(assert, map1, map2) {
|
||||
if (typeof map1 !== 'function' && typeof map2 !== 'function') {
|
||||
if (!map1 || typeof map1 !== 'object') {
|
||||
assert.equal(map1, map2);
|
||||
} else {
|
||||
for (var key in map1) {
|
||||
checkRecursively(assert, map1[key], map2[key]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
QUnit.module('Base Types');
|
||||
|
||||
QUnit.test('Void', function( assert ) {
|
||||
assert.expect(1);
|
||||
const done = assert.async();
|
||||
client.testVoid().then(function(result) {
|
||||
assert.equal(result, undefined);
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
QUnit.test('String', function( assert ) {
|
||||
assert.expect(3);
|
||||
const done = assert.async(3);
|
||||
client.testString('').then(function(result) {
|
||||
assert.equal(result, '');
|
||||
done();
|
||||
});
|
||||
client.testString(stringTest).then(function(result) {
|
||||
assert.equal(result, stringTest);
|
||||
done();
|
||||
});
|
||||
var specialCharacters = 'quote: \" backslash:' +
|
||||
' forwardslash-escaped: \/ ' +
|
||||
' 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).then(function(result) {
|
||||
assert.equal(result, specialCharacters);
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
QUnit.test('Double', function( assert ) {
|
||||
assert.expect(4);
|
||||
const done = assert.async(4);
|
||||
client.testDouble(0).then(function(result) {
|
||||
assert.equal(result, 0);
|
||||
done();
|
||||
});
|
||||
client.testDouble(-1).then(function(result) {
|
||||
assert.equal(result, -1);
|
||||
done();
|
||||
});
|
||||
client.testDouble(3.14).then(function(result) {
|
||||
assert.equal(result, 3.14);
|
||||
done();
|
||||
});
|
||||
client.testDouble(Math.pow(2, 60)).then(function(result) {
|
||||
assert.equal(result, Math.pow(2, 60));
|
||||
done();
|
||||
});
|
||||
});
|
||||
// TODO: add testBinary()
|
||||
QUnit.test('Byte', function( assert ) {
|
||||
assert.expect(2);
|
||||
const done = assert.async(2);
|
||||
client.testByte(0).then(function(result) {
|
||||
assert.equal(result, 0);
|
||||
done();
|
||||
});
|
||||
client.testByte(0x01).then(function(result) {
|
||||
assert.equal(result, 0x01);
|
||||
done();
|
||||
});
|
||||
});
|
||||
QUnit.test('I32', function( assert ) {
|
||||
assert.expect(3);
|
||||
const done = assert.async(3);
|
||||
client.testI32(0).then(function(result) {
|
||||
assert.equal(result, 0);
|
||||
done();
|
||||
});
|
||||
client.testI32(Math.pow(2, 30)).then(function(result) {
|
||||
assert.equal(result, Math.pow(2, 30));
|
||||
done();
|
||||
});
|
||||
client.testI32(-Math.pow(2, 30)).then(function(result) {
|
||||
assert.equal(result, -Math.pow(2, 30));
|
||||
done();
|
||||
});
|
||||
});
|
||||
QUnit.test('I64', function( assert ) {
|
||||
assert.expect(3);
|
||||
const done = assert.async(3);
|
||||
client.testI64(0).then(function(result) {
|
||||
assert.equal(result, 0);
|
||||
done();
|
||||
});
|
||||
//This is usually 2^60 but JS cannot represent anything over 2^52 accurately
|
||||
client.testI64(Math.pow(2, 52)).then(function(result) {
|
||||
assert.equal(result, Math.pow(2, 52));
|
||||
done();
|
||||
});
|
||||
client.testI64(-Math.pow(2, 52)).then(function(result) {
|
||||
assert.equal(result, -Math.pow(2, 52));
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
QUnit.module('Structured Types');
|
||||
|
||||
QUnit.test('Struct', function( assert ) {
|
||||
assert.expect(5);
|
||||
const done = assert.async();
|
||||
var structTestInput = new ThriftTest.Xtruct();
|
||||
structTestInput.string_thing = 'worked';
|
||||
structTestInput.byte_thing = 0x01;
|
||||
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);
|
||||
|
||||
client.testStruct(structTestInput).then(function(result) {
|
||||
assert.equal(result.string_thing, structTestInput.string_thing);
|
||||
assert.equal(result.byte_thing, structTestInput.byte_thing);
|
||||
assert.equal(result.i32_thing, structTestInput.i32_thing);
|
||||
assert.equal(result.i64_thing, structTestInput.i64_thing);
|
||||
assert.equal(JSON.stringify(result), JSON.stringify(structTestInput));
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
QUnit.test('Nest', function( assert ) {
|
||||
assert.expect(7);
|
||||
const done = assert.async();
|
||||
var xtrTestInput = new ThriftTest.Xtruct();
|
||||
xtrTestInput.string_thing = 'worked';
|
||||
xtrTestInput.byte_thing = 0x01;
|
||||
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);
|
||||
|
||||
var nestTestInput = new ThriftTest.Xtruct2();
|
||||
nestTestInput.byte_thing = 0x02;
|
||||
nestTestInput.struct_thing = xtrTestInput;
|
||||
nestTestInput.i32_thing = Math.pow(2, 15);
|
||||
|
||||
client.testNest(nestTestInput).then(function(result) {
|
||||
assert.equal(result.byte_thing, nestTestInput.byte_thing);
|
||||
assert.equal(result.struct_thing.string_thing, nestTestInput.struct_thing.string_thing);
|
||||
assert.equal(result.struct_thing.byte_thing, nestTestInput.struct_thing.byte_thing);
|
||||
assert.equal(result.struct_thing.i32_thing, nestTestInput.struct_thing.i32_thing);
|
||||
assert.equal(result.struct_thing.i64_thing, nestTestInput.struct_thing.i64_thing);
|
||||
assert.equal(result.i32_thing, nestTestInput.i32_thing);
|
||||
assert.equal(JSON.stringify(result), JSON.stringify(nestTestInput));
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
QUnit.test('Map', function( assert ) {
|
||||
assert.expect(3);
|
||||
const done = assert.async();
|
||||
var mapTestInput = {7: 77, 8: 88, 9: 99};
|
||||
|
||||
client.testMap(mapTestInput).then(function(result) {
|
||||
for (var key in result) {
|
||||
assert.equal(result[key], mapTestInput[key]);
|
||||
}
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
QUnit.test('StringMap', function( assert ) {
|
||||
assert.expect(6);
|
||||
const done = assert.async();
|
||||
var mapTestInput = {
|
||||
'a': '123', 'a b': 'with spaces ', 'same': 'same', '0': 'numeric key',
|
||||
'longValue': stringTest, stringTest: 'long key'
|
||||
};
|
||||
|
||||
client.testStringMap(mapTestInput).then(function(result) {
|
||||
for (var key in result) {
|
||||
assert.equal(result[key], mapTestInput[key]);
|
||||
}
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
QUnit.test('Set', function( assert ) {
|
||||
assert.expect(1);
|
||||
const done = assert.async();
|
||||
var setTestInput = [1, 2, 3];
|
||||
client.testSet(setTestInput).then(function(result) {
|
||||
assert.ok(result, setTestInput);
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
QUnit.test('List', function( assert ) {
|
||||
assert.expect(1);
|
||||
const done = assert.async();
|
||||
var listTestInput = [1, 2, 3];
|
||||
client.testList(listTestInput).then(function(result) {
|
||||
assert.ok(result, listTestInput);
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
QUnit.test('Enum', function( assert ) {
|
||||
assert.expect(1);
|
||||
const done = assert.async();
|
||||
client.testEnum(ThriftTest.Numberz.ONE).then(function(result) {
|
||||
assert.equal(result, ThriftTest.Numberz.ONE);
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
QUnit.test('TypeDef', function( assert ) {
|
||||
assert.expect(1);
|
||||
const done = assert.async();
|
||||
client.testTypedef(69).then(function(result) {
|
||||
assert.equal(result, 69);
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
QUnit.module('deeper!');
|
||||
|
||||
QUnit.test('MapMap', function( assert ) {
|
||||
assert.expect(16);
|
||||
const done = assert.async();
|
||||
var mapMapTestExpectedResult = {
|
||||
'4': {'1': 1, '2': 2, '3': 3, '4': 4},
|
||||
'-4': {'-4': -4, '-3': -3, '-2': -2, '-1': -1}
|
||||
};
|
||||
|
||||
client.testMapMap(1).then(function(result) {
|
||||
for (var key in result) {
|
||||
for (var key2 in result[key]) {
|
||||
assert.equal(result[key][key2], mapMapTestExpectedResult[key][key2]);
|
||||
}
|
||||
}
|
||||
checkRecursively(assert, result, mapMapTestExpectedResult);
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
QUnit.module('Exception');
|
||||
|
||||
QUnit.test('Xception', function( assert ) {
|
||||
assert.expect(2);
|
||||
const done = assert.async();
|
||||
client.testException('Xception').then(function(res) {
|
||||
assert.ok(false);
|
||||
}).catch(function(e) {
|
||||
|
||||
console.log(`Exception exception e`);
|
||||
console.log(e);
|
||||
console.log(JSON.stringify(e, null, 2));
|
||||
|
||||
assert.equal(e.errorCode, 1001);
|
||||
assert.equal(e.message, 'Xception');
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
QUnit.test('no Exception', function( assert ) {
|
||||
assert.expect(1);
|
||||
const done = assert.async();
|
||||
client.testException('no Exception').then(function(e) {
|
||||
assert.ok(!e);
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
QUnit.module('Insanity');
|
||||
|
||||
QUnit.test('testInsanity', function( assert ) {
|
||||
assert.expect(24);
|
||||
const done = assert.async();
|
||||
var insanity = {
|
||||
'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
|
||||
}
|
||||
]
|
||||
},
|
||||
'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
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
'2': { '6': { 'userMap': null, 'xtructs': null } }
|
||||
};
|
||||
client.testInsanity(new ThriftTest.Insanity()).then(function(res) {
|
||||
assert.ok(res, JSON.stringify(res));
|
||||
assert.ok(insanity, JSON.stringify(insanity));
|
||||
checkRecursively(assert, res, insanity);
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
QUnit.module('Oneway');
|
||||
QUnit.test('testOneway', function( assert ) {
|
||||
assert.expect(1);
|
||||
const done = assert.async();
|
||||
client.testOneway(1).then(function(result) {
|
||||
assert.equal(result, undefined);
|
||||
done();
|
||||
});
|
||||
});
|
145
vendor/git.apache.org/thrift.git/lib/js/test/test-jq.js
generated
vendored
145
vendor/git.apache.org/thrift.git/lib/js/test/test-jq.js
generated
vendored
|
@ -33,126 +33,127 @@
|
|||
//////////////////////////////////
|
||||
//jQuery asynchronous tests
|
||||
jQuery.ajaxSetup({ timeout: 0 });
|
||||
$(document).ajaxError( function() { QUnit.start(); } );
|
||||
|
||||
module("jQ Async Manual");
|
||||
QUnit.module('jQ Async Manual');
|
||||
|
||||
test("testI32", function() {
|
||||
expect( 2 );
|
||||
QUnit.stop();
|
||||
QUnit.test('testI32', function(assert) {
|
||||
assert.expect(2);
|
||||
const done = assert.async(2);
|
||||
|
||||
var transport = new Thrift.Transport();
|
||||
var protocol = new Thrift.Protocol(transport);
|
||||
var client = new ThriftTest.ThriftTestClient(protocol);
|
||||
const transport = new Thrift.Transport();
|
||||
const protocol = new Thrift.Protocol(transport);
|
||||
const client = new ThriftTest.ThriftTestClient(protocol);
|
||||
|
||||
var jqxhr = jQuery.ajax({
|
||||
url: "/service",
|
||||
data: client.send_testI32(Math.pow(-2,31)),
|
||||
type: "POST",
|
||||
const jqxhr = jQuery.ajax({
|
||||
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);
|
||||
assert.equal(client.recv_testI32(), Math.pow(-2, 31));
|
||||
done();
|
||||
},
|
||||
error: function() { ok(false); },
|
||||
error: function() { assert.ok(false); },
|
||||
complete: function() {
|
||||
ok(true);
|
||||
QUnit.start();
|
||||
assert.ok(true);
|
||||
done();
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
test("testI64", function() {
|
||||
expect( 2 );
|
||||
QUnit.stop();
|
||||
QUnit.test('testI64', function(assert) {
|
||||
assert.expect(2);
|
||||
const done = assert.async(2);
|
||||
|
||||
var transport = new Thrift.Transport();
|
||||
var protocol = new Thrift.Protocol(transport);
|
||||
var client = new ThriftTest.ThriftTestClient(protocol);
|
||||
const transport = new Thrift.Transport();
|
||||
const protocol = new Thrift.Protocol(transport);
|
||||
const 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));
|
||||
assert.equal(client.recv_testI64(), Math.pow(-2, 52));
|
||||
done();
|
||||
},
|
||||
error: function() { ok(false); },
|
||||
error: function() { assert.ok(false); },
|
||||
complete: function() {
|
||||
ok(true);
|
||||
QUnit.start();
|
||||
assert.ok(true);
|
||||
done();
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
module("jQ Async");
|
||||
test("I32", function() {
|
||||
expect( 3 );
|
||||
QUnit.module('jQ Async');
|
||||
QUnit.test('I32', function(assert) {
|
||||
assert.expect(3);
|
||||
|
||||
QUnit.stop();
|
||||
client.testI32(Math.pow(2,30), function(result) {
|
||||
equal(result, Math.pow(2,30));
|
||||
QUnit.start();
|
||||
const done = assert.async(3);
|
||||
client.testI32(Math.pow(2, 30), function(result) {
|
||||
assert.equal(result, Math.pow(2, 30));
|
||||
done();
|
||||
});
|
||||
|
||||
QUnit.stop();
|
||||
var jqxhr = client.testI32(Math.pow(-2,31), function(result) {
|
||||
equal(result, Math.pow(-2,31));
|
||||
const jqxhr = client.testI32(Math.pow(-2, 31), function(result) {
|
||||
assert.equal(result, Math.pow(-2, 31));
|
||||
done();
|
||||
});
|
||||
|
||||
jqxhr.success(function(result) {
|
||||
equal(result, Math.pow(-2,31));
|
||||
QUnit.start();
|
||||
assert.equal(result, Math.pow(-2, 31));
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
test("I64", function() {
|
||||
expect( 4 );
|
||||
QUnit.test('I64', function(assert) {
|
||||
assert.expect(4);
|
||||
|
||||
QUnit.stop();
|
||||
const done = assert.async(4);
|
||||
//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));
|
||||
QUnit.start();
|
||||
client.testI64(Math.pow(2, 52), function(result) {
|
||||
assert.equal(result, Math.pow(2, 52));
|
||||
done();
|
||||
});
|
||||
|
||||
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) {
|
||||
assert.equal(result, Math.pow(-2, 52));
|
||||
done();
|
||||
})
|
||||
.error( function(xhr, status, e) { ok(false, e.message); } )
|
||||
.error(function(xhr, status, e) { assert.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));
|
||||
assert.equal(result, Math.pow(-2, 52));
|
||||
done();
|
||||
})
|
||||
.complete(function() {
|
||||
ok(true);
|
||||
QUnit.start();
|
||||
assert.ok(true);
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
test("Xception", function() {
|
||||
expect( 2 );
|
||||
QUnit.test('Xception', function(assert) {
|
||||
assert.expect(2);
|
||||
|
||||
QUnit.stop();
|
||||
const done = assert.async(2);
|
||||
|
||||
var dfd = client.testException("Xception", function(result) {
|
||||
ok(false);
|
||||
QUnit.start();
|
||||
const dfd = client.testException('Xception', function(result) {
|
||||
assert.ok(false);
|
||||
done();
|
||||
})
|
||||
.error(function(xhr, status, e){
|
||||
equal(e.errorCode, 1001);
|
||||
equal(e.message, "Xception");
|
||||
//QUnit.start();
|
||||
//Note start is not required here because:
|
||||
//$(document).ajaxError( function() { QUnit.start(); } );
|
||||
.error(function(xhr, status, e) {
|
||||
assert.equal(e.errorCode, 1001);
|
||||
assert.equal(e.message, 'Xception');
|
||||
done();
|
||||
$(document).ajaxError( function() { done(); } );
|
||||
});
|
||||
});
|
||||
|
|
4
vendor/git.apache.org/thrift.git/lib/js/test/test-nojq.html
generated
vendored
4
vendor/git.apache.org/thrift.git/lib/js/test/test-nojq.html
generated
vendored
|
@ -29,7 +29,7 @@
|
|||
<!-- QUnit Test framework-->
|
||||
<script type="text/javascript" src="build/js/lib/qunit.js" charset="utf-8"></script>
|
||||
<link rel="stylesheet" href="build/js/lib/qunit.css" type="text/css" media="screen" />
|
||||
|
||||
|
||||
<!-- the Test Suite-->
|
||||
<script type="text/javascript" src="test.js" charset="utf-8"></script>
|
||||
<script type="text/javascript" src="test-nojq.js" charset="utf-8"></script>
|
||||
|
@ -37,7 +37,7 @@
|
|||
<body>
|
||||
<h1 id="qunit-header">Thrift Javascript Bindings: Unit Test (<a href="https://git-wip-us.apache.org/repos/asf?p=thrift.git;a=blob;f=test/ThriftTest.thrift;hb=HEAD">ThriftTest.thrift</a>)</h1>
|
||||
<h2 id="qunit-banner"></h2>
|
||||
<div id="qunit-testrunner-toolbar"></div>
|
||||
<div id="qunit-testrunner-toolbar"></div>
|
||||
<h2 id="qunit-userAgent"></h2>
|
||||
<ol id="qunit-tests"><li><!-- get valid xhtml strict--></li></ol>
|
||||
<!-- Uncomment this to check the validity. This significantly slows down the test.
|
||||
|
|
21
vendor/git.apache.org/thrift.git/lib/js/test/test-nojq.js
generated
vendored
21
vendor/git.apache.org/thrift.git/lib/js/test/test-nojq.js
generated
vendored
|
@ -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,17 +33,16 @@
|
|||
//////////////////////////////////
|
||||
//Async exception tests
|
||||
|
||||
module("NojQ Async");
|
||||
QUnit.module('NojQ Async');
|
||||
|
||||
test("Xception", function() {
|
||||
expect( 2 );
|
||||
QUnit.test('Xception', function(assert) {
|
||||
assert.expect(2);
|
||||
const done = assert.async();
|
||||
|
||||
QUnit.stop();
|
||||
|
||||
client.testException("Xception", function(result) {
|
||||
equal(result.errorCode, 1001);
|
||||
equal(result.message, "Xception");
|
||||
QUnit.start();
|
||||
client.testException('Xception', function(result) {
|
||||
assert.equal(result.errorCode, 1001);
|
||||
assert.equal(result.message, 'Xception');
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
|
|
9
vendor/git.apache.org/thrift.git/lib/js/test/test.html
generated
vendored
9
vendor/git.apache.org/thrift.git/lib/js/test/test.html
generated
vendored
|
@ -23,8 +23,8 @@
|
|||
<title>Thrift Javascript Bindings: Unit Test</title>
|
||||
|
||||
<script src="build/js/thrift.js" type="text/javascript" charset="utf-8"></script>
|
||||
<script src="gen-js/ThriftTest_types.js" type="text/javascript" charset="utf-8"></script>
|
||||
<script src="gen-js/ThriftTest.js" type="text/javascript" charset="utf-8"></script>
|
||||
<script src="gen-js-jquery/ThriftTest_types.js" type="text/javascript" charset="utf-8"></script>
|
||||
<script src="gen-js-jquery/ThriftTest.js" type="text/javascript" charset="utf-8"></script>
|
||||
|
||||
<!-- jQuery -->
|
||||
<script type="text/javascript" src="build/js/lib/jquery.js" charset="utf-8"></script>
|
||||
|
@ -34,11 +34,6 @@
|
|||
<link rel="stylesheet" href="build/js/lib/qunit.css" type="text/css" media="screen" />
|
||||
|
||||
<!-- the Test Suite-->
|
||||
<script>
|
||||
var transport = new Thrift.Transport("/service");
|
||||
var protocol = new Thrift.Protocol(transport);
|
||||
var client = new ThriftTest.ThriftTestClient(protocol);
|
||||
</script>
|
||||
<script type="text/javascript" src="test.js" charset="utf-8"></script>
|
||||
<script type="text/javascript" src="test-jq.js" charset="utf-8"></script>
|
||||
</head>
|
||||
|
|
377
vendor/git.apache.org/thrift.git/lib/js/test/test.js
generated
vendored
377
vendor/git.apache.org/thrift.git/lib/js/test/test.js
generated
vendored
|
@ -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);
|
||||
const transport = new Thrift.Transport('/service');
|
||||
const protocol = new Thrift.Protocol(transport);
|
||||
const client = new ThriftTest.ThriftTestClient(protocol);
|
||||
|
||||
// Work around for old API used by QUnitAdapter of jsTestDriver
|
||||
if (typeof QUnit.log == 'function') {
|
||||
|
@ -67,170 +67,170 @@ if (typeof QUnit.log == 'function') {
|
|||
}
|
||||
|
||||
// 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ú, 粵語";
|
||||
const 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) {
|
||||
function checkRecursively(assert, map1, map2) {
|
||||
if (typeof map1 !== 'function' && typeof map2 !== 'function') {
|
||||
if (!map1 || typeof map1 !== 'object') {
|
||||
equal(map1, map2);
|
||||
assert.equal(map1, map2);
|
||||
} else {
|
||||
for (var key in map1) {
|
||||
checkRecursively(map1[key], map2[key]);
|
||||
for (let key in map1) {
|
||||
checkRecursively(assert, map1[key], map2[key]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
module("Base Types");
|
||||
QUnit.module('Base Types');
|
||||
|
||||
test("Void", function() {
|
||||
equal(client.testVoid(), undefined);
|
||||
QUnit.test('Void', function(assert) {
|
||||
assert.equal(client.testVoid(), undefined);
|
||||
});
|
||||
test("Binary (String)", function() {
|
||||
var binary = '';
|
||||
for (var v = 255; v >= 0; --v) {
|
||||
QUnit.test('Binary (String)', function(assert) {
|
||||
let binary = '';
|
||||
for (let v = 255; v >= 0; --v) {
|
||||
binary += String.fromCharCode(v);
|
||||
}
|
||||
equal(client.testBinary(binary), binary);
|
||||
assert.equal(client.testBinary(binary), binary);
|
||||
});
|
||||
test("Binary (Uint8Array)", function() {
|
||||
var binary = '';
|
||||
for (var v = 255; v >= 0; --v) {
|
||||
QUnit.test('Binary (Uint8Array)', function(assert) {
|
||||
let binary = '';
|
||||
for (let v = 255; v >= 0; --v) {
|
||||
binary += String.fromCharCode(v);
|
||||
}
|
||||
var arr = new Uint8Array(binary.length);
|
||||
for (var i = 0; i < binary.length; ++i) {
|
||||
const arr = new Uint8Array(binary.length);
|
||||
for (let i = 0; i < binary.length; ++i) {
|
||||
arr[i] = binary[i].charCodeAt();
|
||||
}
|
||||
equal(client.testBinary(arr), binary);
|
||||
assert.equal(client.testBinary(arr), binary);
|
||||
});
|
||||
test("String", function() {
|
||||
equal(client.testString(''), '');
|
||||
equal(client.testString(stringTest), stringTest);
|
||||
QUnit.test('String', function(assert) {
|
||||
assert.equal(client.testString(''), '');
|
||||
assert.equal(client.testString(stringTest), stringTest);
|
||||
|
||||
var specialCharacters = 'quote: \" backslash:' +
|
||||
const specialCharacters = 'quote: \" backslash:' +
|
||||
' forwardslash-escaped: \/ ' +
|
||||
' 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);
|
||||
assert.equal(client.testString(specialCharacters), specialCharacters);
|
||||
});
|
||||
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));
|
||||
QUnit.test('Double', function(assert) {
|
||||
assert.equal(client.testDouble(0), 0);
|
||||
assert.equal(client.testDouble(-1), -1);
|
||||
assert.equal(client.testDouble(3.14), 3.14);
|
||||
assert.equal(client.testDouble(Math.pow(2, 60)), Math.pow(2, 60));
|
||||
});
|
||||
test("Byte", function() {
|
||||
equal(client.testByte(0), 0);
|
||||
equal(client.testByte(0x01), 0x01);
|
||||
QUnit.test('Byte', function(assert) {
|
||||
assert.equal(client.testByte(0), 0);
|
||||
assert.equal(client.testByte(0x01), 0x01);
|
||||
});
|
||||
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));
|
||||
QUnit.test('I32', function(assert) {
|
||||
assert.equal(client.testI32(0), 0);
|
||||
assert.equal(client.testI32(Math.pow(2, 30)), Math.pow(2, 30));
|
||||
assert.equal(client.testI32(-Math.pow(2, 30)), -Math.pow(2, 30));
|
||||
});
|
||||
test("I64", function() {
|
||||
equal(client.testI64(0), 0);
|
||||
QUnit.test('I64', function(assert) {
|
||||
assert.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));
|
||||
assert.equal(client.testI64(Math.pow(2, 52)), Math.pow(2, 52));
|
||||
assert.equal(client.testI64(-Math.pow(2, 52)), -Math.pow(2, 52));
|
||||
});
|
||||
|
||||
|
||||
module("Structured Types");
|
||||
QUnit.module('Structured Types');
|
||||
|
||||
test("Struct", function() {
|
||||
var structTestInput = new ThriftTest.Xtruct();
|
||||
QUnit.test('Struct', function(assert) {
|
||||
const 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);
|
||||
const structTestOutput = client.testStruct(structTestInput);
|
||||
|
||||
equal(structTestOutput.string_thing, structTestInput.string_thing);
|
||||
equal(structTestOutput.byte_thing, structTestInput.byte_thing);
|
||||
equal(structTestOutput.i32_thing, structTestInput.i32_thing);
|
||||
equal(structTestOutput.i64_thing, structTestInput.i64_thing);
|
||||
assert.equal(structTestOutput.string_thing, structTestInput.string_thing);
|
||||
assert.equal(structTestOutput.byte_thing, structTestInput.byte_thing);
|
||||
assert.equal(structTestOutput.i32_thing, structTestInput.i32_thing);
|
||||
assert.equal(structTestOutput.i64_thing, structTestInput.i64_thing);
|
||||
|
||||
equal(JSON.stringify(structTestOutput), JSON.stringify(structTestInput));
|
||||
assert.equal(JSON.stringify(structTestOutput), JSON.stringify(structTestInput));
|
||||
});
|
||||
|
||||
test("Nest", function() {
|
||||
var xtrTestInput = new ThriftTest.Xtruct();
|
||||
QUnit.test('Nest', function(assert) {
|
||||
const 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();
|
||||
const 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);
|
||||
const nestTestOutput = client.testNest(nestTestInput);
|
||||
|
||||
equal(nestTestOutput.byte_thing, nestTestInput.byte_thing);
|
||||
equal(nestTestOutput.struct_thing.string_thing, nestTestInput.struct_thing.string_thing);
|
||||
equal(nestTestOutput.struct_thing.byte_thing, nestTestInput.struct_thing.byte_thing);
|
||||
equal(nestTestOutput.struct_thing.i32_thing, nestTestInput.struct_thing.i32_thing);
|
||||
equal(nestTestOutput.struct_thing.i64_thing, nestTestInput.struct_thing.i64_thing);
|
||||
equal(nestTestOutput.i32_thing, nestTestInput.i32_thing);
|
||||
assert.equal(nestTestOutput.byte_thing, nestTestInput.byte_thing);
|
||||
assert.equal(nestTestOutput.struct_thing.string_thing, nestTestInput.struct_thing.string_thing);
|
||||
assert.equal(nestTestOutput.struct_thing.byte_thing, nestTestInput.struct_thing.byte_thing);
|
||||
assert.equal(nestTestOutput.struct_thing.i32_thing, nestTestInput.struct_thing.i32_thing);
|
||||
assert.equal(nestTestOutput.struct_thing.i64_thing, nestTestInput.struct_thing.i64_thing);
|
||||
assert.equal(nestTestOutput.i32_thing, nestTestInput.i32_thing);
|
||||
|
||||
equal(JSON.stringify(nestTestOutput), JSON.stringify(nestTestInput));
|
||||
assert.equal(JSON.stringify(nestTestOutput), JSON.stringify(nestTestInput));
|
||||
});
|
||||
|
||||
test("Map", function() {
|
||||
var mapTestInput = {7:77, 8:88, 9:99};
|
||||
QUnit.test('Map', function(assert) {
|
||||
const mapTestInput = {7: 77, 8: 88, 9: 99};
|
||||
|
||||
var mapTestOutput = client.testMap(mapTestInput);
|
||||
const mapTestOutput = client.testMap(mapTestInput);
|
||||
|
||||
for (var key in mapTestOutput) {
|
||||
equal(mapTestOutput[key], mapTestInput[key]);
|
||||
for (let key in mapTestOutput) {
|
||||
assert.equal(mapTestOutput[key], mapTestInput[key]);
|
||||
}
|
||||
});
|
||||
|
||||
test("StringMap", function() {
|
||||
var mapTestInput = {
|
||||
"a":"123", "a b":"with spaces ", "same":"same", "0":"numeric key",
|
||||
"longValue":stringTest, stringTest:"long key"
|
||||
QUnit.test('StringMap', function(assert) {
|
||||
const mapTestInput = {
|
||||
'a': '123', 'a b': 'with spaces ', 'same': 'same', '0': 'numeric key',
|
||||
'longValue': stringTest, stringTest: 'long key'
|
||||
};
|
||||
|
||||
var mapTestOutput = client.testStringMap(mapTestInput);
|
||||
const mapTestOutput = client.testStringMap(mapTestInput);
|
||||
|
||||
for (var key in mapTestOutput) {
|
||||
equal(mapTestOutput[key], mapTestInput[key]);
|
||||
for (let key in mapTestOutput) {
|
||||
assert.equal(mapTestOutput[key], mapTestInput[key]);
|
||||
}
|
||||
});
|
||||
|
||||
test("Set", function() {
|
||||
var setTestInput = [1,2,3];
|
||||
ok(client.testSet(setTestInput), setTestInput);
|
||||
QUnit.test('Set', function(assert) {
|
||||
const setTestInput = [1, 2, 3];
|
||||
assert.ok(client.testSet(setTestInput), setTestInput);
|
||||
});
|
||||
|
||||
test("List", function() {
|
||||
var listTestInput = [1,2,3];
|
||||
ok(client.testList(listTestInput), listTestInput);
|
||||
QUnit.test('List', function(assert) {
|
||||
const listTestInput = [1, 2, 3];
|
||||
assert.ok(client.testList(listTestInput), listTestInput);
|
||||
});
|
||||
|
||||
test("Enum", function() {
|
||||
equal(client.testEnum(ThriftTest.Numberz.ONE), ThriftTest.Numberz.ONE);
|
||||
QUnit.test('Enum', function(assert) {
|
||||
assert.equal(client.testEnum(ThriftTest.Numberz.ONE), ThriftTest.Numberz.ONE);
|
||||
});
|
||||
|
||||
test("TypeDef", function() {
|
||||
equal(client.testTypedef(69), 69);
|
||||
QUnit.test('TypeDef', function(assert) {
|
||||
assert.equal(client.testTypedef(69), 69);
|
||||
});
|
||||
|
||||
test("Skip", function() {
|
||||
var structTestInput = new ThriftTest.Xtruct();
|
||||
var modifiedClient = new ThriftTest.ThriftTestClient(protocol);
|
||||
QUnit.test('Skip', function(assert) {
|
||||
const structTestInput = new ThriftTest.Xtruct();
|
||||
const modifiedClient = new ThriftTest.ThriftTestClient(protocol);
|
||||
|
||||
modifiedClient.recv_testStruct = function() {
|
||||
var input = modifiedClient.input;
|
||||
var xtruct3 = new ThriftTest.Xtruct3();
|
||||
const input = modifiedClient.input;
|
||||
const xtruct3 = new ThriftTest.Xtruct3();
|
||||
|
||||
input.readMessageBegin();
|
||||
input.readStructBegin();
|
||||
|
@ -250,163 +250,166 @@ module("Structured Types");
|
|||
};
|
||||
|
||||
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);
|
||||
const structTestOutput = modifiedClient.testStruct(structTestInput);
|
||||
|
||||
equal(structTestOutput instanceof ThriftTest.Xtruct3, true);
|
||||
equal(structTestOutput.string_thing, structTestInput.string_thing);
|
||||
equal(structTestOutput.changed, null);
|
||||
equal(structTestOutput.i32_thing, structTestInput.i32_thing);
|
||||
equal(structTestOutput.i64_thing, structTestInput.i64_thing);
|
||||
assert.equal(structTestOutput instanceof ThriftTest.Xtruct3, true);
|
||||
assert.equal(structTestOutput.string_thing, structTestInput.string_thing);
|
||||
assert.equal(structTestOutput.changed, null);
|
||||
assert.equal(structTestOutput.i32_thing, structTestInput.i32_thing);
|
||||
assert.equal(structTestOutput.i64_thing, structTestInput.i64_thing);
|
||||
});
|
||||
|
||||
|
||||
module("deeper!");
|
||||
QUnit.module('deeper!');
|
||||
|
||||
test("MapMap", function() {
|
||||
var mapMapTestExpectedResult = {
|
||||
"4":{"1":1,"2":2,"3":3,"4":4},
|
||||
"-4":{"-4":-4, "-3":-3, "-2":-2, "-1":-1}
|
||||
QUnit.test('MapMap', function(assert) {
|
||||
const mapMapTestExpectedResult = {
|
||||
'4': {'1': 1, '2': 2, '3': 3, '4': 4},
|
||||
'-4': {'-4': -4, '-3': -3, '-2': -2, '-1': -1}
|
||||
};
|
||||
|
||||
var mapMapTestOutput = client.testMapMap(1);
|
||||
const mapMapTestOutput = client.testMapMap(1);
|
||||
|
||||
|
||||
for (var key in mapMapTestOutput) {
|
||||
for (var key2 in mapMapTestOutput[key]) {
|
||||
equal(mapMapTestOutput[key][key2], mapMapTestExpectedResult[key][key2]);
|
||||
for (let key in mapMapTestOutput) {
|
||||
for (let key2 in mapMapTestOutput[key]) {
|
||||
assert.equal(mapMapTestOutput[key][key2], mapMapTestExpectedResult[key][key2]);
|
||||
}
|
||||
}
|
||||
|
||||
checkRecursively(mapMapTestOutput, mapMapTestExpectedResult);
|
||||
checkRecursively(assert, mapMapTestOutput, mapMapTestExpectedResult);
|
||||
});
|
||||
|
||||
|
||||
module("Exception");
|
||||
QUnit.module('Exception');
|
||||
|
||||
test("Xception", function() {
|
||||
expect(2);
|
||||
try{
|
||||
client.testException("Xception");
|
||||
}catch(e){
|
||||
equal(e.errorCode, 1001);
|
||||
equal(e.message, "Xception");
|
||||
QUnit.test('Xception', function(assert) {
|
||||
assert.expect(2);
|
||||
const done = assert.async();
|
||||
try {
|
||||
client.testException('Xception');
|
||||
assert.ok(false);
|
||||
}catch (e) {
|
||||
assert.equal(e.errorCode, 1001);
|
||||
assert.equal(e.message, 'Xception');
|
||||
done();
|
||||
}
|
||||
});
|
||||
|
||||
test("no Exception", 0, function() {
|
||||
try{
|
||||
client.testException("no Exception");
|
||||
}catch(e){
|
||||
ok(false);
|
||||
QUnit.test('no Exception', function(assert) {
|
||||
assert.expect(1);
|
||||
try {
|
||||
client.testException('no Exception');
|
||||
assert.ok(true);
|
||||
}catch (e) {
|
||||
assert.ok(false);
|
||||
}
|
||||
});
|
||||
|
||||
test("TException", function() {
|
||||
QUnit.test('TException', function(assert) {
|
||||
//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) {
|
||||
//ok(false);
|
||||
assert.expect(1);
|
||||
try {
|
||||
client.testException('TException');
|
||||
} catch (e) {
|
||||
//assert.ok(false);
|
||||
}
|
||||
ok(true);
|
||||
assert.ok(true);
|
||||
});
|
||||
|
||||
|
||||
module("Insanity");
|
||||
QUnit.module('Insanity');
|
||||
|
||||
var crazy = {
|
||||
"userMap":{ "5":5, "8":8 },
|
||||
"xtructs":[{
|
||||
"string_thing":"Goodbye4",
|
||||
"byte_thing":4,
|
||||
"i32_thing":4,
|
||||
"i64_thing":4
|
||||
const crazy = {
|
||||
'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() {
|
||||
var insanity = {
|
||||
"1":{
|
||||
"2":crazy,
|
||||
"3":crazy
|
||||
QUnit.test('testInsanity', function(assert) {
|
||||
const insanity = {
|
||||
'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));
|
||||
ok(insanity, JSON.stringify(insanity));
|
||||
const res = client.testInsanity(new ThriftTest.Insanity(crazy));
|
||||
assert.ok(res, JSON.stringify(res));
|
||||
assert.ok(insanity, JSON.stringify(insanity));
|
||||
|
||||
checkRecursively(res, insanity);
|
||||
checkRecursively(assert, res, insanity);
|
||||
});
|
||||
|
||||
|
||||
//////////////////////////////////
|
||||
//Run same tests asynchronously
|
||||
|
||||
module("Async");
|
||||
QUnit.module('Async');
|
||||
|
||||
test("Double", function() {
|
||||
expect( 1 );
|
||||
QUnit.test('Double', function(assert) {
|
||||
assert.expect(1);
|
||||
|
||||
QUnit.stop();
|
||||
const done = assert.async();
|
||||
client.testDouble(3.14159265, function(result) {
|
||||
equal(result, 3.14159265);
|
||||
QUnit.start();
|
||||
assert.equal(result, 3.14159265);
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
test("Byte", function() {
|
||||
expect( 1 );
|
||||
QUnit.test('Byte', function(assert) {
|
||||
assert.expect(1);
|
||||
|
||||
QUnit.stop();
|
||||
const done = assert.async();
|
||||
client.testByte(0x01, function(result) {
|
||||
equal(result, 0x01);
|
||||
QUnit.start();
|
||||
assert.equal(result, 0x01);
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
test("I32", function() {
|
||||
expect( 2 );
|
||||
QUnit.test('I32', function(assert) {
|
||||
assert.expect(2);
|
||||
|
||||
QUnit.stop();
|
||||
client.testI32(Math.pow(2,30), function(result) {
|
||||
equal(result, Math.pow(2,30));
|
||||
QUnit.start();
|
||||
const done = assert.async(2);
|
||||
client.testI32(Math.pow(2, 30), function(result) {
|
||||
assert.equal(result, Math.pow(2, 30));
|
||||
done();
|
||||
});
|
||||
|
||||
QUnit.stop();
|
||||
client.testI32(Math.pow(-2,31), function(result) {
|
||||
equal(result, Math.pow(-2,31));
|
||||
QUnit.start();
|
||||
client.testI32(Math.pow(-2, 31), function(result) {
|
||||
assert.equal(result, Math.pow(-2, 31));
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
test("I64", function() {
|
||||
expect( 2 );
|
||||
QUnit.test('I64', function(assert) {
|
||||
assert.expect(2);
|
||||
|
||||
QUnit.stop();
|
||||
const done = assert.async(2);
|
||||
//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));
|
||||
QUnit.start();
|
||||
client.testI64(Math.pow(2, 52), function(result) {
|
||||
assert.equal(result, Math.pow(2, 52));
|
||||
done();
|
||||
});
|
||||
|
||||
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));
|
||||
QUnit.start();
|
||||
client.testI64(Math.pow(-2, 52), function(result) {
|
||||
assert.equal(result, Math.pow(-2, 52));
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
|
44
vendor/git.apache.org/thrift.git/lib/js/test/test_handler.js
generated
vendored
44
vendor/git.apache.org/thrift.git/lib/js/test/test_handler.js
generated
vendored
|
@ -17,13 +17,15 @@
|
|||
* 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');
|
||||
var TException = require('../../nodejs/lib/thrift').TException;
|
||||
const es6Mode = process.argv.includes('--es6');
|
||||
const genFolder = es6Mode ? 'gen-nodejs-es6' : 'gen-nodejs';
|
||||
const ttypes = require(`./${genFolder}/ThriftTest_types`);
|
||||
const TException = require('../../nodejs/lib/thrift').TException;
|
||||
|
||||
var ThriftTestHandler = exports.ThriftTestHandler = {
|
||||
exports.ThriftTestHandler = {
|
||||
testVoid: function(result) {
|
||||
console.log('testVoid()');
|
||||
result(null);
|
||||
|
@ -99,10 +101,10 @@ var ThriftTestHandler = exports.ThriftTestHandler = {
|
|||
testMapMap: function(hello, result) {
|
||||
console.log('testMapMap(' + hello + ')');
|
||||
|
||||
var mapmap = [];
|
||||
var pos = [];
|
||||
var neg = [];
|
||||
for (var i = 1; i < 5; i++) {
|
||||
const mapmap = [];
|
||||
const pos = [];
|
||||
const neg = [];
|
||||
for (let i = 1; i < 5; i++) {
|
||||
pos[i] = i;
|
||||
neg[-i] = -i;
|
||||
}
|
||||
|
@ -116,34 +118,34 @@ var ThriftTestHandler = exports.ThriftTestHandler = {
|
|||
console.log(argument);
|
||||
console.log(')');
|
||||
|
||||
var hello = new ttypes.Xtruct();
|
||||
const hello = new ttypes.Xtruct();
|
||||
hello.string_thing = 'Hello2';
|
||||
hello.byte_thing = 2;
|
||||
hello.i32_thing = 2;
|
||||
hello.i64_thing = 2;
|
||||
|
||||
var goodbye = new ttypes.Xtruct();
|
||||
const goodbye = new ttypes.Xtruct();
|
||||
goodbye.string_thing = 'Goodbye4';
|
||||
goodbye.byte_thing = 4;
|
||||
goodbye.i32_thing = 4;
|
||||
goodbye.i64_thing = 4;
|
||||
|
||||
var crazy = new ttypes.Insanity();
|
||||
const crazy = new ttypes.Insanity();
|
||||
crazy.userMap = [];
|
||||
crazy.userMap[ttypes.Numberz.EIGHT] = 8;
|
||||
crazy.userMap[ttypes.Numberz.FIVE] = 5;
|
||||
crazy.xtructs = [goodbye, hello];
|
||||
|
||||
var first_map = [];
|
||||
var second_map = [];
|
||||
const first_map = [];
|
||||
const second_map = [];
|
||||
|
||||
first_map[ttypes.Numberz.TWO] = crazy;
|
||||
first_map[ttypes.Numberz.THREE] = crazy;
|
||||
|
||||
var looney = new ttypes.Insanity();
|
||||
const looney = new ttypes.Insanity();
|
||||
second_map[ttypes.Numberz.SIX] = looney;
|
||||
|
||||
var insane = [];
|
||||
const insane = [];
|
||||
insane[1] = first_map;
|
||||
insane[2] = second_map;
|
||||
|
||||
|
@ -154,7 +156,7 @@ var ThriftTestHandler = exports.ThriftTestHandler = {
|
|||
testMulti: function(arg0, arg1, arg2, arg3, arg4, arg5, result) {
|
||||
console.log('testMulti()');
|
||||
|
||||
var hello = new ttypes.Xtruct();
|
||||
const hello = new ttypes.Xtruct();
|
||||
hello.string_thing = 'Hello2';
|
||||
hello.byte_thing = arg0;
|
||||
hello.i32_thing = arg1;
|
||||
|
@ -162,9 +164,9 @@ var ThriftTestHandler = exports.ThriftTestHandler = {
|
|||
result(null, hello);
|
||||
},
|
||||
testException: function(arg, result) {
|
||||
console.log('testException('+arg+')');
|
||||
console.log('testException(' + arg + ')');
|
||||
if (arg === 'Xception') {
|
||||
var x = new ttypes.Xception();
|
||||
const x = new ttypes.Xception();
|
||||
x.errorCode = 1001;
|
||||
x.message = arg;
|
||||
result(x);
|
||||
|
@ -177,19 +179,19 @@ var ThriftTestHandler = exports.ThriftTestHandler = {
|
|||
testMultiException: function(arg0, arg1, result) {
|
||||
console.log('testMultiException(' + arg0 + ', ' + arg1 + ')');
|
||||
if (arg0 === ('Xception')) {
|
||||
var x = new ttypes.Xception();
|
||||
const x = new ttypes.Xception();
|
||||
x.errorCode = 1001;
|
||||
x.message = 'This is an Xception';
|
||||
result(x);
|
||||
} else if (arg0 === ('Xception2')) {
|
||||
var x2 = new ttypes.Xception2();
|
||||
const x2 = new ttypes.Xception2();
|
||||
x2.errorCode = 2002;
|
||||
x2.struct_thing = new ttypes.Xtruct();
|
||||
x2.struct_thing.string_thing = 'This is an Xception2';
|
||||
result(x2);
|
||||
}
|
||||
|
||||
var res = new ttypes.Xtruct();
|
||||
const res = new ttypes.Xtruct();
|
||||
res.string_thing = arg1;
|
||||
result(null, res);
|
||||
},
|
||||
|
|
10
vendor/git.apache.org/thrift.git/lib/js/test/testws.html
generated
vendored
10
vendor/git.apache.org/thrift.git/lib/js/test/testws.html
generated
vendored
|
@ -35,12 +35,12 @@
|
|||
|
||||
<!-- the Test Suite-->
|
||||
<script>
|
||||
var loc = window.location;
|
||||
var ws_uri = ((loc.protocol === "https:") ? "wss://" : "ws://") +
|
||||
const loc = window.location;
|
||||
const ws_uri = ((loc.protocol === "https:") ? "wss://" : "ws://") +
|
||||
loc.hostname + ":" + loc.port + loc.pathname;
|
||||
var transport = new Thrift.TWebSocketTransport(ws_uri);
|
||||
var protocol = new Thrift.Protocol(transport);
|
||||
var client = new ThriftTest.ThriftTestClient(protocol);
|
||||
const transport = new Thrift.TWebSocketTransport(ws_uri);
|
||||
const protocol = new Thrift.Protocol(transport);
|
||||
const client = new ThriftTest.ThriftTestClient(protocol);
|
||||
transport.open();
|
||||
</script>
|
||||
<script type="text/javascript" src="test-async.js" charset="utf-8"></script>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue