diff options
author | Jisi Liu <jisi.liu@gmail.com> | 2016-03-30 11:39:59 -0700 |
---|---|---|
committer | Jisi Liu <jisi.liu@gmail.com> | 2016-03-30 11:39:59 -0700 |
commit | 3b3c8abb9635eb3ea078a821a99c9ef29d66dff7 (patch) | |
tree | 7d2ec154f15c9f9153d890e76b6cf30e471ea488 /js/message_test.js | |
parent | 78105897a8f01c7be9cf8502b6c58d47eb1ccdd7 (diff) | |
download | protobuf-3b3c8abb9635eb3ea078a821a99c9ef29d66dff7.tar.gz protobuf-3b3c8abb9635eb3ea078a821a99c9ef29d66dff7.tar.bz2 protobuf-3b3c8abb9635eb3ea078a821a99c9ef29d66dff7.zip |
Integrate google internal changes.
Diffstat (limited to 'js/message_test.js')
-rw-r--r-- | js/message_test.js | 50 |
1 files changed, 34 insertions, 16 deletions
diff --git a/js/message_test.js b/js/message_test.js index f572188e..01add5f1 100644 --- a/js/message_test.js +++ b/js/message_test.js @@ -53,6 +53,8 @@ goog.require('proto.jspb.test.Complex'); goog.require('proto.jspb.test.DefaultValues'); goog.require('proto.jspb.test.Empty'); goog.require('proto.jspb.test.EnumContainer'); +goog.require('proto.jspb.test.floatingMsgField'); +goog.require('proto.jspb.test.FloatingPointFields'); goog.require('proto.jspb.test.floatingStrField'); goog.require('proto.jspb.test.HasExtensions'); goog.require('proto.jspb.test.IndirectExtension'); @@ -60,7 +62,6 @@ goog.require('proto.jspb.test.IsExtension'); goog.require('proto.jspb.test.OptionalFields'); goog.require('proto.jspb.test.OuterEnum'); goog.require('proto.jspb.test.OuterMessage.Complex'); -goog.require('proto.jspb.test.simple1'); goog.require('proto.jspb.test.Simple1'); goog.require('proto.jspb.test.Simple2'); goog.require('proto.jspb.test.SpecialCases'); @@ -74,7 +75,7 @@ goog.require('proto.jspb.test.TestReservedNamesExtension'); // CommonJS-LoadFromFile: test2_pb proto.jspb.test goog.require('proto.jspb.test.ExtensionMessage'); goog.require('proto.jspb.test.TestExtensionsMessage'); -goog.require('proto.jspb.test.floatingMsgField'); + @@ -98,12 +99,6 @@ describe('Message test suite', function() { assertEquals('some_bytes', data.getBytesField()); }); - it('testNestedMessage', function() { - var msg = new proto.jspb.test.OuterMessage.Complex(); - msg.setInnerComplexField(5); - assertObjectEquals({innerComplexField: 5}, msg.toObject()); - }); - it('testComplexConversion', function() { var data1 = ['a',,, [, 11], [[, 22], [, 33]],, ['s1', 's2'],, 1]; var data2 = ['a',,, [, 11], [[, 22], [, 33]],, ['s1', 's2'],, 1]; @@ -160,6 +155,13 @@ describe('Message test suite', function() { }); + it('testNestedComplexMessage', function() { + // Instantiate the message and set a unique field, just to ensure that we + // are not getting jspb.test.Complex instead. + var msg = new proto.jspb.test.OuterMessage.Complex(); + msg.setInnerComplexField(5); + }); + it('testSpecialCases', function() { // Note: Some property names are reserved in JavaScript. // These names are converted to the Js property named pb_<reserved_name>. @@ -544,12 +546,6 @@ describe('Message test suite', function() { extendable.setExtension(proto.jspb.test.IndirectExtension.str, null); assertNull(extendable.getExtension(proto.jspb.test.IndirectExtension.str)); - // These assertions will only work properly in uncompiled mode. - // Extension fields defined on proto2 Descriptor messages are filtered out. - - // TODO(haberman): codegen changes to properly ignore descriptor.proto - // extensions need to be merged from google3. - // assertUndefined(proto.jspb.test.IsExtension['simpleOption']); // Extension fields with jspb.ignore = true are ignored. assertUndefined(proto.jspb.test.IndirectExtension['ignored']); @@ -907,7 +903,7 @@ describe('Message test suite', function() { message.getDefaultOneofACase()); message = - new proto.jspb.test.TestMessageWithOneof(new Array(9).concat(567,890)); + new proto.jspb.test.TestMessageWithOneof(new Array(9).concat(567, 890)); assertEquals(1234, message.getAone()); assertEquals(890, message.getAtwo()); assertEquals( @@ -936,7 +932,7 @@ describe('Message test suite', function() { message.getDefaultOneofBCase()); message = new proto.jspb.test.TestMessageWithOneof( - new Array(11).concat(567,890)); + new Array(11).concat(567, 890)); assertUndefined(message.getBone()); assertEquals(890, message.getBtwo()); assertEquals( @@ -989,4 +985,26 @@ describe('Message test suite', function() { assertEquals('y', array[4]); }); + it('testFloatingPointFieldsSupportNan', function() { + var assertNan = function(x) { + assertTrue('Expected ' + x + ' (' + goog.typeOf(x) + ') to be NaN.', + goog.isNumber(x) && isNaN(x)); + }; + + var message = new proto.jspb.test.FloatingPointFields([ + 'NaN', 'NaN', ['NaN', 'NaN'], 'NaN', + 'NaN', 'NaN', ['NaN', 'NaN'], 'NaN' + ]); + assertNan(message.getOptionalFloatField()); + assertNan(message.getRequiredFloatField()); + assertNan(message.getRepeatedFloatFieldList()[0]); + assertNan(message.getRepeatedFloatFieldList()[1]); + assertNan(message.getDefaultFloatField()); + assertNan(message.getOptionalDoubleField()); + assertNan(message.getRequiredDoubleField()); + assertNan(message.getRepeatedDoubleFieldList()[0]); + assertNan(message.getRepeatedDoubleFieldList()[1]); + assertNan(message.getDefaultDoubleField()); + }); + }); |