diff options
-rwxr-xr-x | js/allTests.py | 1 | ||||
-rw-r--r-- | js/gulp/testAndDemoTasks.js | 2 | ||||
-rw-r--r-- | js/src/Ice/Long.js | 36 | ||||
-rw-r--r-- | js/test/Common/index.html | 6 |
4 files changed, 31 insertions, 14 deletions
diff --git a/js/allTests.py b/js/allTests.py index 04857170e60..79d3941f631 100755 --- a/js/allTests.py +++ b/js/allTests.py @@ -50,6 +50,7 @@ tests = [ ("Ice/slicing/exceptions", ["core"]), ("Ice/slicing/objects", ["core"]), ("Ice/timeout", ["core"]), + ("Ice/number", ["once"]), ("Glacier2/router", ["service"]), ] diff --git a/js/gulp/testAndDemoTasks.js b/js/gulp/testAndDemoTasks.js index 73bc01594e9..99e37c81413 100644 --- a/js/gulp/testAndDemoTasks.js +++ b/js/gulp/testAndDemoTasks.js @@ -28,7 +28,7 @@ module.exports = function(gulp) { "Ice/exceptionsBidir", "Ice/facets", "Ice/facetsBidir", "Ice/hold", "Ice/inheritance", "Ice/inheritanceBidir", "Ice/location", "Ice/objects", "Ice/operations", "Ice/operationsBidir", "Ice/optional", "Ice/optionalBidir", "Ice/promise", "Ice/properties", "Ice/proxy", "Ice/retry", - "Ice/slicing/exceptions", "Ice/slicing/objects", "Ice/timeout", "Glacier2/router"], + "Ice/slicing/exceptions", "Ice/slicing/objects", "Ice/timeout", "Ice/number", "Glacier2/router"], demo: ["Ice/hello", "Ice/throughput", "Ice/minimal", "Ice/latency", "Ice/bidir", "Glacier2/chat", "ChatDemo"] }; diff --git a/js/src/Ice/Long.js b/js/src/Ice/Long.js index 8d80641760f..14b6eba7e07 100644 --- a/js/src/Ice/Long.js +++ b/js/src/Ice/Long.js @@ -17,6 +17,15 @@ var Ice = require("../Ice/Class").Ice; var Long = Ice.Class({ __init__: function(high, low) { + if(low < 0 || low > Long.MAX_UINT32) + { + throw new RangeError("Low word must be between 0 and 0xFFFFFFFF"); + } + if(high < 0 || high > Long.MAX_UINT32) + { + throw new RangeError("High word must be between 0 and 0xFFFFFFFF"); + } + this.high = high; this.low = low; }, @@ -42,24 +51,22 @@ var Long = Ice.Class({ }, toNumber: function() { + if((this.high & Long.SIGN_MASK) !== 0) { - var low = ~this.low; - var high = ~this.high; - if(low < 0xFFFFFFFF) + if(this.high === Long.MAX_UINT32 && this.low !== 0) { - low += 1; + return -(~this.low + 1); } - else + + var high = ~this.high + 1; + + if(high > Long.HIGH_MAX) { - low = 0; - high += 1; - if(high > Long.HIGH_MAX) - { - return Number.NEGATIVE_INFINITY; - } + return Number.NEGATIVE_INFINITY; } - return -1 * (high * Long.HIGH_MASK) + low; + + return -1 * (high * Long.HIGH_MASK) + this.low; } else { @@ -73,6 +80,11 @@ var Long = Ice.Class({ }); // +// 2^32 +// +Long.MAX_UINT32 = 0xFFFFFFFF; + +// // (high & SIGN_MASK) != 0 denotes a negative number; // that is, the most significant bit is set. // diff --git a/js/test/Common/index.html b/js/test/Common/index.html index cad0af89f46..c46509ef8ae 100644 --- a/js/test/Common/index.html +++ b/js/test/Common/index.html @@ -319,7 +319,11 @@ "Ice/timeout": { files: ["Test.js", "Client.js"] - } + }, + "Ice/number": + { + files: ["Client.js"] + }, }; var current, next; |