diff options
author | Mark Spruiell <mes@zeroc.com> | 2015-12-02 11:28:31 -0800 |
---|---|---|
committer | Mark Spruiell <mes@zeroc.com> | 2015-12-02 11:28:31 -0800 |
commit | 7ea494f049785c1adf0ec7693cae7744276e42d2 (patch) | |
tree | 889a2cdbf371c155a26b6225e2b0c03d58b840ab /js | |
parent | Fix for ICE-6896 - sporadic binding test failure with the Python language map... (diff) | |
download | ice-7ea494f049785c1adf0ec7693cae7744276e42d2.tar.bz2 ice-7ea494f049785c1adf0ec7693cae7744276e42d2.tar.xz ice-7ea494f049785c1adf0ec7693cae7744276e42d2.zip |
Fixes for ICE-6905 - support NaN/Infinity in scripting languages
Diffstat (limited to 'js')
-rw-r--r-- | js/src/Ice/BasicStream.js | 10 | ||||
-rw-r--r-- | js/test/Ice/operations/Twoways.js | 23 |
2 files changed, 21 insertions, 12 deletions
diff --git a/js/src/Ice/BasicStream.js b/js/src/Ice/BasicStream.js index 97e803c3ab3..548956fc158 100644 --- a/js/src/Ice/BasicStream.js +++ b/js/src/Ice/BasicStream.js @@ -2943,9 +2943,19 @@ Ice.IntHelper = defineBuiltinHelper(stream.writeInt, stream.readInt, 4, Ice.Opti Ice.FloatHelper = defineBuiltinHelper(stream.writeFloat, stream.readFloat, 4, Ice.OptionalFormat.F4, MIN_FLOAT32_VALUE, MAX_FLOAT32_VALUE); +Ice.FloatHelper.validate = function(v) +{ + return Number.isNaN(v) || v == Number.POSITIVE_INFINITY || v == Number.NEGATIVE_INFINITY || + (v >= MIN_FLOAT32_VALUE && v <= MAX_FLOAT32_VALUE); +}; Ice.DoubleHelper = defineBuiltinHelper(stream.writeDouble, stream.readDouble, 8, Ice.OptionalFormat.F8, -Number.MAX_VALUE, Number.MAX_VALUE); +Ice.DoubleHelper.validate = function(v) +{ + return Number.isNaN(v) || v == Number.POSITIVE_INFINITY || v == Number.NEGATIVE_INFINITY || + (v >= -Number.MAX_VALUE && v <= Number.MAX_VALUE); +}; Ice.BoolHelper = defineBuiltinHelper(stream.writeBool, stream.readBool, 1, Ice.OptionalFormat.F1); Ice.LongHelper = defineBuiltinHelper(stream.writeLong, stream.readLong, 8, Ice.OptionalFormat.F8); diff --git a/js/test/Ice/operations/Twoways.js b/js/test/Ice/operations/Twoways.js index a5c78738fe9..e7bbd6bedc0 100644 --- a/js/test/Ice/operations/Twoways.js +++ b/js/test/Ice/operations/Twoways.js @@ -180,27 +180,26 @@ function(ex) { test(ex instanceof Ice.MarshalException); - return prx.opFloatDouble(0, Number.MAX_VALUE * 2); + return prx.opFloatDouble(Number.NaN, Number.NaN); } ).then( - failCB, - function(ex) + function(retval, f, d) { - test(ex instanceof Ice.MarshalException); - return prx.opFloatDouble(0, -Number.MAX_VALUE * 2); + return prx.opFloatDouble(-Number.NaN, -Number.NaN); } ).then( - failCB, - function(ex) + function(retval, f, d) { - test(ex instanceof Ice.MarshalException); - return prx.opFloatDouble(0, Number.NaN); + return prx.opFloatDouble(Number.POSITIVE_INFINITY, Number.POSITIVE_INFINITY); } ).then( - failCB, - function(ex) + function(retval, f, d) + { + return prx.opFloatDouble(Number.NEGATIVE_INFINITY, Number.NEGATIVE_INFINITY); + } + ).then( + function(retval, f, d) { - test(ex instanceof Ice.MarshalException); return prx.opString("hello", "world"); } ).then( |