|
@@ -149,58 +149,60 @@ describe('Message test suite', function() {
|
|
});
|
|
});
|
|
|
|
|
|
it('testComplexConversion', function() {
|
|
it('testComplexConversion', function() {
|
|
- var data1 = ['a',,, [, 11], [[, 22], [, 33]],, ['s1', 's2'],, 1];
|
|
|
|
- var data2 = ['a',,, [, 11], [[, 22], [, 33]],, ['s1', 's2'],, 1];
|
|
|
|
|
|
+ var data1 = ['a', , , [, 11], [[, 22], [, 33]], , ['s1', 's2'], , 1];
|
|
|
|
+ var data2 = ['a', , , [, 11], [[, 22], [, 33]], , ['s1', 's2'], , 1];
|
|
var foo = new proto.jspb.test.Complex(data1);
|
|
var foo = new proto.jspb.test.Complex(data1);
|
|
var bar = new proto.jspb.test.Complex(data2);
|
|
var bar = new proto.jspb.test.Complex(data2);
|
|
var result = foo.toObject();
|
|
var result = foo.toObject();
|
|
- assertObjectEquals({
|
|
|
|
- aString: 'a',
|
|
|
|
- anOutOfOrderBool: 1,
|
|
|
|
- aNestedMessage: {
|
|
|
|
- anInt: 11
|
|
|
|
- },
|
|
|
|
- aRepeatedMessageList: [{anInt: 22}, {anInt: 33}],
|
|
|
|
- aRepeatedStringList: ['s1', 's2']
|
|
|
|
- }, result);
|
|
|
|
|
|
+ assertObjectEquals(
|
|
|
|
+ {
|
|
|
|
+ aString: 'a',
|
|
|
|
+ anOutOfOrderBool: 1,
|
|
|
|
+ aNestedMessage: {anInt: 11},
|
|
|
|
+ aRepeatedMessageList: [{anInt: 22}, {anInt: 33}],
|
|
|
|
+ aRepeatedStringList: ['s1', 's2']
|
|
|
|
+ },
|
|
|
|
+ result);
|
|
|
|
|
|
// Now test with the jspb instances included.
|
|
// Now test with the jspb instances included.
|
|
result = foo.toObject(true /* opt_includeInstance */);
|
|
result = foo.toObject(true /* opt_includeInstance */);
|
|
- assertObjectEquals({
|
|
|
|
- aString: 'a',
|
|
|
|
- anOutOfOrderBool: 1,
|
|
|
|
- aNestedMessage: {
|
|
|
|
- anInt: 11,
|
|
|
|
- $jspbMessageInstance: foo.getANestedMessage()
|
|
|
|
- },
|
|
|
|
- aRepeatedMessageList: [
|
|
|
|
- {anInt: 22, $jspbMessageInstance: foo.getARepeatedMessageList()[0]},
|
|
|
|
- {anInt: 33, $jspbMessageInstance: foo.getARepeatedMessageList()[1]}
|
|
|
|
- ],
|
|
|
|
- aRepeatedStringList: ['s1', 's2'],
|
|
|
|
- $jspbMessageInstance: foo
|
|
|
|
- }, result);
|
|
|
|
|
|
+ assertObjectEquals(
|
|
|
|
+ {
|
|
|
|
+ aString: 'a',
|
|
|
|
+ anOutOfOrderBool: 1,
|
|
|
|
+ aNestedMessage:
|
|
|
|
+ {anInt: 11, $jspbMessageInstance: foo.getANestedMessage()},
|
|
|
|
+ aRepeatedMessageList: [
|
|
|
|
+ {anInt: 22, $jspbMessageInstance: foo.getARepeatedMessageList()[0]},
|
|
|
|
+ {anInt: 33, $jspbMessageInstance: foo.getARepeatedMessageList()[1]}
|
|
|
|
+ ],
|
|
|
|
+ aRepeatedStringList: ['s1', 's2'],
|
|
|
|
+ $jspbMessageInstance: foo
|
|
|
|
+ },
|
|
|
|
+ result);
|
|
|
|
|
|
});
|
|
});
|
|
|
|
|
|
it('testMissingFields', function() {
|
|
it('testMissingFields', function() {
|
|
var foo = new proto.jspb.test.Complex([
|
|
var foo = new proto.jspb.test.Complex([
|
|
- undefined, undefined, undefined, [],
|
|
|
|
- undefined, undefined, undefined, undefined]);
|
|
|
|
|
|
+ undefined, undefined, undefined, [], undefined, undefined, undefined,
|
|
|
|
+ undefined
|
|
|
|
+ ]);
|
|
var bar = new proto.jspb.test.Complex([
|
|
var bar = new proto.jspb.test.Complex([
|
|
- undefined, undefined, undefined, [],
|
|
|
|
- undefined, undefined, undefined, undefined]);
|
|
|
|
|
|
+ undefined, undefined, undefined, [], undefined, undefined, undefined,
|
|
|
|
+ undefined
|
|
|
|
+ ]);
|
|
var result = foo.toObject();
|
|
var result = foo.toObject();
|
|
- assertObjectEquals({
|
|
|
|
- aString: undefined,
|
|
|
|
- anOutOfOrderBool: undefined,
|
|
|
|
- aNestedMessage: {
|
|
|
|
- anInt: undefined
|
|
|
|
- },
|
|
|
|
- // Note: JsPb converts undefined repeated fields to empty arrays.
|
|
|
|
- aRepeatedMessageList: [],
|
|
|
|
- aRepeatedStringList: []
|
|
|
|
- }, result);
|
|
|
|
|
|
+ assertObjectEquals(
|
|
|
|
+ {
|
|
|
|
+ aString: undefined,
|
|
|
|
+ anOutOfOrderBool: undefined,
|
|
|
|
+ aNestedMessage: {anInt: undefined},
|
|
|
|
+ // Note: JsPb converts undefined repeated fields to empty arrays.
|
|
|
|
+ aRepeatedMessageList: [],
|
|
|
|
+ aRepeatedStringList: []
|
|
|
|
+ },
|
|
|
|
+ result);
|
|
|
|
|
|
});
|
|
});
|
|
|
|
|
|
@@ -214,20 +216,21 @@ describe('Message test suite', function() {
|
|
it('testSpecialCases', function() {
|
|
it('testSpecialCases', function() {
|
|
// Note: Some property names are reserved in JavaScript.
|
|
// Note: Some property names are reserved in JavaScript.
|
|
// These names are converted to the Js property named pb_<reserved_name>.
|
|
// These names are converted to the Js property named pb_<reserved_name>.
|
|
- var special =
|
|
|
|
- new proto.jspb.test.SpecialCases(['normal', 'default', 'function',
|
|
|
|
- 'var']);
|
|
|
|
|
|
+ var special = new proto.jspb.test.SpecialCases(
|
|
|
|
+ ['normal', 'default', 'function', 'var']);
|
|
var result = special.toObject();
|
|
var result = special.toObject();
|
|
- assertObjectEquals({
|
|
|
|
- normal: 'normal',
|
|
|
|
- pb_default: 'default',
|
|
|
|
- pb_function: 'function',
|
|
|
|
- pb_var: 'var'
|
|
|
|
- }, result);
|
|
|
|
|
|
+ assertObjectEquals(
|
|
|
|
+ {
|
|
|
|
+ normal: 'normal',
|
|
|
|
+ pb_default: 'default',
|
|
|
|
+ pb_function: 'function',
|
|
|
|
+ pb_var: 'var'
|
|
|
|
+ },
|
|
|
|
+ result);
|
|
});
|
|
});
|
|
|
|
|
|
it('testDefaultValues', function() {
|
|
it('testDefaultValues', function() {
|
|
- var defaultString = "default<>\'\"abc";
|
|
|
|
|
|
+ var defaultString = 'default<>\'"abc';
|
|
var response = new proto.jspb.test.DefaultValues();
|
|
var response = new proto.jspb.test.DefaultValues();
|
|
|
|
|
|
// Test toObject
|
|
// Test toObject
|
|
@@ -291,8 +294,10 @@ describe('Message test suite', function() {
|
|
|
|
|
|
// Test that clearing the values reverts them to the default state.
|
|
// Test that clearing the values reverts them to the default state.
|
|
response = makeDefault(['blah', false, 111, 77]);
|
|
response = makeDefault(['blah', false, 111, 77]);
|
|
- response.clearStringField(); response.clearBoolField();
|
|
|
|
- response.clearIntField(); response.clearEnumField();
|
|
|
|
|
|
+ response.clearStringField();
|
|
|
|
+ response.clearBoolField();
|
|
|
|
+ response.clearIntField();
|
|
|
|
+ response.clearEnumField();
|
|
assertEquals(defaultString, response.getStringField());
|
|
assertEquals(defaultString, response.getStringField());
|
|
assertEquals(true, response.getBoolField());
|
|
assertEquals(true, response.getBoolField());
|
|
assertEquals(11, response.getIntField());
|
|
assertEquals(11, response.getIntField());
|
|
@@ -304,8 +309,10 @@ describe('Message test suite', function() {
|
|
|
|
|
|
// Test that setFoo(null) clears the values.
|
|
// Test that setFoo(null) clears the values.
|
|
response = makeDefault(['blah', false, 111, 77]);
|
|
response = makeDefault(['blah', false, 111, 77]);
|
|
- response.setStringField(null); response.setBoolField(null);
|
|
|
|
- response.setIntField(undefined); response.setEnumField(undefined);
|
|
|
|
|
|
+ response.setStringField(null);
|
|
|
|
+ response.setBoolField(null);
|
|
|
|
+ response.setIntField(undefined);
|
|
|
|
+ response.setEnumField(undefined);
|
|
assertEquals(defaultString, response.getStringField());
|
|
assertEquals(defaultString, response.getStringField());
|
|
assertEquals(true, response.getBoolField());
|
|
assertEquals(true, response.getBoolField());
|
|
assertEquals(11, response.getIntField());
|
|
assertEquals(11, response.getIntField());
|
|
@@ -321,13 +328,13 @@ describe('Message test suite', function() {
|
|
assertTrue(jspb.Message.equals(s1, new proto.jspb.test.Simple1(['hi'])));
|
|
assertTrue(jspb.Message.equals(s1, new proto.jspb.test.Simple1(['hi'])));
|
|
assertFalse(jspb.Message.equals(s1, new proto.jspb.test.Simple1(['bye'])));
|
|
assertFalse(jspb.Message.equals(s1, new proto.jspb.test.Simple1(['bye'])));
|
|
var s1b = new proto.jspb.test.Simple1(['hi', ['hello']]);
|
|
var s1b = new proto.jspb.test.Simple1(['hi', ['hello']]);
|
|
- assertTrue(jspb.Message.equals(s1b,
|
|
|
|
- new proto.jspb.test.Simple1(['hi', ['hello']])));
|
|
|
|
- assertTrue(jspb.Message.equals(s1b,
|
|
|
|
- new proto.jspb.test.Simple1(['hi', ['hello', undefined,
|
|
|
|
- undefined, undefined]])));
|
|
|
|
- assertFalse(jspb.Message.equals(s1b,
|
|
|
|
- new proto.jspb.test.Simple1(['no', ['hello']])));
|
|
|
|
|
|
+ assertTrue(jspb.Message.equals(
|
|
|
|
+ s1b, new proto.jspb.test.Simple1(['hi', ['hello']])));
|
|
|
|
+ assertTrue(jspb.Message.equals(s1b, new proto.jspb.test.Simple1([
|
|
|
|
+ 'hi', ['hello', undefined, undefined, undefined]
|
|
|
|
+ ])));
|
|
|
|
+ assertFalse(jspb.Message.equals(
|
|
|
|
+ s1b, new proto.jspb.test.Simple1(['no', ['hello']])));
|
|
// Test with messages of different types
|
|
// Test with messages of different types
|
|
var s2 = new proto.jspb.test.Simple2(['hi']);
|
|
var s2 = new proto.jspb.test.Simple2(['hi']);
|
|
assertFalse(jspb.Message.equals(s1, s2));
|
|
assertFalse(jspb.Message.equals(s1, s2));
|
|
@@ -335,18 +342,18 @@ describe('Message test suite', function() {
|
|
|
|
|
|
it('testEquals_softComparison', function() {
|
|
it('testEquals_softComparison', function() {
|
|
var s1 = new proto.jspb.test.Simple1(['hi', [], null]);
|
|
var s1 = new proto.jspb.test.Simple1(['hi', [], null]);
|
|
- assertTrue(jspb.Message.equals(s1,
|
|
|
|
- new proto.jspb.test.Simple1(['hi', []])));
|
|
|
|
|
|
+ assertTrue(
|
|
|
|
+ jspb.Message.equals(s1, new proto.jspb.test.Simple1(['hi', []])));
|
|
|
|
|
|
var s1b = new proto.jspb.test.Simple1(['hi', [], true]);
|
|
var s1b = new proto.jspb.test.Simple1(['hi', [], true]);
|
|
- assertTrue(jspb.Message.equals(s1b,
|
|
|
|
- new proto.jspb.test.Simple1(['hi', [], 1])));
|
|
|
|
|
|
+ assertTrue(
|
|
|
|
+ jspb.Message.equals(s1b, new proto.jspb.test.Simple1(['hi', [], 1])));
|
|
});
|
|
});
|
|
|
|
|
|
it('testEqualsComplex', function() {
|
|
it('testEqualsComplex', function() {
|
|
- var data1 = ['a',,, [, 11], [[, 22], [, 33]],, ['s1', 's2'],, 1];
|
|
|
|
- var data2 = ['a',,, [, 11], [[, 22], [, 34]],, ['s1', 's2'],, 1];
|
|
|
|
- var data3 = ['a',,, [, 11], [[, 22]],, ['s1', 's2'],, 1];
|
|
|
|
|
|
+ var data1 = ['a', , , [, 11], [[, 22], [, 33]], , ['s1', 's2'], , 1];
|
|
|
|
+ var data2 = ['a', , , [, 11], [[, 22], [, 34]], , ['s1', 's2'], , 1];
|
|
|
|
+ var data3 = ['a', , , [, 11], [[, 22]], , ['s1', 's2'], , 1];
|
|
var data4 = ['hi'];
|
|
var data4 = ['hi'];
|
|
var c1a = new proto.jspb.test.Complex(data1);
|
|
var c1a = new proto.jspb.test.Complex(data1);
|
|
var c1b = new proto.jspb.test.Complex(data1);
|
|
var c1b = new proto.jspb.test.Complex(data1);
|
|
@@ -363,42 +370,34 @@ describe('Message test suite', function() {
|
|
it('testEqualsExtensionsConstructed', function() {
|
|
it('testEqualsExtensionsConstructed', function() {
|
|
assertTrue(jspb.Message.equals(
|
|
assertTrue(jspb.Message.equals(
|
|
new proto.jspb.test.HasExtensions([]),
|
|
new proto.jspb.test.HasExtensions([]),
|
|
- new proto.jspb.test.HasExtensions([{}])
|
|
|
|
- ));
|
|
|
|
|
|
+ new proto.jspb.test.HasExtensions([{}])));
|
|
assertTrue(jspb.Message.equals(
|
|
assertTrue(jspb.Message.equals(
|
|
new proto.jspb.test.HasExtensions(['hi', {100: [{200: 'a'}]}]),
|
|
new proto.jspb.test.HasExtensions(['hi', {100: [{200: 'a'}]}]),
|
|
- new proto.jspb.test.HasExtensions(['hi', {100: [{200: 'a'}]}])
|
|
|
|
- ));
|
|
|
|
|
|
+ new proto.jspb.test.HasExtensions(['hi', {100: [{200: 'a'}]}])));
|
|
assertFalse(jspb.Message.equals(
|
|
assertFalse(jspb.Message.equals(
|
|
new proto.jspb.test.HasExtensions(['hi', {100: [{200: 'a'}]}]),
|
|
new proto.jspb.test.HasExtensions(['hi', {100: [{200: 'a'}]}]),
|
|
- new proto.jspb.test.HasExtensions(['hi', {100: [{200: 'b'}]}])
|
|
|
|
- ));
|
|
|
|
|
|
+ new proto.jspb.test.HasExtensions(['hi', {100: [{200: 'b'}]}])));
|
|
assertTrue(jspb.Message.equals(
|
|
assertTrue(jspb.Message.equals(
|
|
new proto.jspb.test.HasExtensions([{100: [{200: 'a'}]}]),
|
|
new proto.jspb.test.HasExtensions([{100: [{200: 'a'}]}]),
|
|
- new proto.jspb.test.HasExtensions([{100: [{200: 'a'}]}])
|
|
|
|
- ));
|
|
|
|
|
|
+ new proto.jspb.test.HasExtensions([{100: [{200: 'a'}]}])));
|
|
assertTrue(jspb.Message.equals(
|
|
assertTrue(jspb.Message.equals(
|
|
new proto.jspb.test.HasExtensions([{100: [{200: 'a'}]}]),
|
|
new proto.jspb.test.HasExtensions([{100: [{200: 'a'}]}]),
|
|
- new proto.jspb.test.HasExtensions([,,, {100: [{200: 'a'}]}])
|
|
|
|
- ));
|
|
|
|
|
|
+ new proto.jspb.test.HasExtensions([, , , {100: [{200: 'a'}]}])));
|
|
assertTrue(jspb.Message.equals(
|
|
assertTrue(jspb.Message.equals(
|
|
- new proto.jspb.test.HasExtensions([,,, {100: [{200: 'a'}]}]),
|
|
|
|
- new proto.jspb.test.HasExtensions([{100: [{200: 'a'}]}])
|
|
|
|
- ));
|
|
|
|
|
|
+ new proto.jspb.test.HasExtensions([, , , {100: [{200: 'a'}]}]),
|
|
|
|
+ new proto.jspb.test.HasExtensions([{100: [{200: 'a'}]}])));
|
|
assertTrue(jspb.Message.equals(
|
|
assertTrue(jspb.Message.equals(
|
|
new proto.jspb.test.HasExtensions(['hi', {100: [{200: 'a'}]}]),
|
|
new proto.jspb.test.HasExtensions(['hi', {100: [{200: 'a'}]}]),
|
|
- new proto.jspb.test.HasExtensions(['hi',,, {100: [{200: 'a'}]}])
|
|
|
|
- ));
|
|
|
|
|
|
+ new proto.jspb.test.HasExtensions(['hi', , , {100: [{200: 'a'}]}])));
|
|
assertTrue(jspb.Message.equals(
|
|
assertTrue(jspb.Message.equals(
|
|
- new proto.jspb.test.HasExtensions(['hi',,, {100: [{200: 'a'}]}]),
|
|
|
|
- new proto.jspb.test.HasExtensions(['hi', {100: [{200: 'a'}]}])
|
|
|
|
- ));
|
|
|
|
|
|
+ new proto.jspb.test.HasExtensions(['hi', , , {100: [{200: 'a'}]}]),
|
|
|
|
+ new proto.jspb.test.HasExtensions(['hi', {100: [{200: 'a'}]}])));
|
|
});
|
|
});
|
|
|
|
|
|
it('testEqualsExtensionsUnconstructed', function() {
|
|
it('testEqualsExtensionsUnconstructed', function() {
|
|
assertTrue(jspb.Message.compareFields([], [{}]));
|
|
assertTrue(jspb.Message.compareFields([], [{}]));
|
|
- assertTrue(jspb.Message.compareFields([,,, {}], []));
|
|
|
|
- assertTrue(jspb.Message.compareFields([,,, {}], [,, {}]));
|
|
|
|
|
|
+ assertTrue(jspb.Message.compareFields([, , , {}], []));
|
|
|
|
+ assertTrue(jspb.Message.compareFields([, , , {}], [, , {}]));
|
|
assertTrue(jspb.Message.compareFields(
|
|
assertTrue(jspb.Message.compareFields(
|
|
['hi', {100: [{200: 'a'}]}], ['hi', {100: [{200: 'a'}]}]));
|
|
['hi', {100: [{200: 'a'}]}], ['hi', {100: [{200: 'a'}]}]));
|
|
assertFalse(jspb.Message.compareFields(
|
|
assertFalse(jspb.Message.compareFields(
|
|
@@ -406,13 +405,13 @@ describe('Message test suite', function() {
|
|
assertTrue(jspb.Message.compareFields(
|
|
assertTrue(jspb.Message.compareFields(
|
|
[{100: [{200: 'a'}]}], [{100: [{200: 'a'}]}]));
|
|
[{100: [{200: 'a'}]}], [{100: [{200: 'a'}]}]));
|
|
assertTrue(jspb.Message.compareFields(
|
|
assertTrue(jspb.Message.compareFields(
|
|
- [{100: [{200: 'a'}]}], [,,, {100: [{200: 'a'}]}]));
|
|
|
|
|
|
+ [{100: [{200: 'a'}]}], [, , , {100: [{200: 'a'}]}]));
|
|
assertTrue(jspb.Message.compareFields(
|
|
assertTrue(jspb.Message.compareFields(
|
|
- [,,, {100: [{200: 'a'}]}], [{100: [{200: 'a'}]}]));
|
|
|
|
|
|
+ [, , , {100: [{200: 'a'}]}], [{100: [{200: 'a'}]}]));
|
|
assertTrue(jspb.Message.compareFields(
|
|
assertTrue(jspb.Message.compareFields(
|
|
- ['hi', {100: [{200: 'a'}]}], ['hi',,, {100: [{200: 'a'}]}]));
|
|
|
|
|
|
+ ['hi', {100: [{200: 'a'}]}], ['hi', , , {100: [{200: 'a'}]}]));
|
|
assertTrue(jspb.Message.compareFields(
|
|
assertTrue(jspb.Message.compareFields(
|
|
- ['hi',,, {100: [{200: 'a'}]}], ['hi', {100: [{200: 'a'}]}]));
|
|
|
|
|
|
+ ['hi', , , {100: [{200: 'a'}]}], ['hi', {100: [{200: 'a'}]}]));
|
|
});
|
|
});
|
|
|
|
|
|
it('testInitializeMessageWithLastFieldNull', function() {
|
|
it('testInitializeMessageWithLastFieldNull', function() {
|
|
@@ -436,13 +435,13 @@ describe('Message test suite', function() {
|
|
it('testToMap', function() {
|
|
it('testToMap', function() {
|
|
var p1 = new proto.jspb.test.Simple1(['k', ['v']]);
|
|
var p1 = new proto.jspb.test.Simple1(['k', ['v']]);
|
|
var p2 = new proto.jspb.test.Simple1(['k1', ['v1', 'v2']]);
|
|
var p2 = new proto.jspb.test.Simple1(['k1', ['v1', 'v2']]);
|
|
- var soymap = jspb.Message.toMap([p1, p2],
|
|
|
|
- proto.jspb.test.Simple1.prototype.getAString,
|
|
|
|
|
|
+ var soymap = jspb.Message.toMap(
|
|
|
|
+ [p1, p2], proto.jspb.test.Simple1.prototype.getAString,
|
|
proto.jspb.test.Simple1.prototype.toObject);
|
|
proto.jspb.test.Simple1.prototype.toObject);
|
|
assertEquals('k', soymap['k'].aString);
|
|
assertEquals('k', soymap['k'].aString);
|
|
assertArrayEquals(['v'], soymap['k'].aRepeatedStringList);
|
|
assertArrayEquals(['v'], soymap['k'].aRepeatedStringList);
|
|
- var protomap = jspb.Message.toMap([p1, p2],
|
|
|
|
- proto.jspb.test.Simple1.prototype.getAString);
|
|
|
|
|
|
+ var protomap = jspb.Message.toMap(
|
|
|
|
+ [p1, p2], proto.jspb.test.Simple1.prototype.getAString);
|
|
assertEquals('k', protomap['k'].getAString());
|
|
assertEquals('k', protomap['k'].getAString());
|
|
assertArrayEquals(['v'], protomap['k'].getARepeatedStringList());
|
|
assertArrayEquals(['v'], protomap['k'].getARepeatedStringList());
|
|
});
|
|
});
|
|
@@ -463,8 +462,12 @@ describe('Message test suite', function() {
|
|
extension.setExt('e1');
|
|
extension.setExt('e1');
|
|
original.setExtension(proto.jspb.test.IsExtension.extField, extension);
|
|
original.setExtension(proto.jspb.test.IsExtension.extField, extension);
|
|
var clone = original.clone();
|
|
var clone = original.clone();
|
|
- assertArrayEquals(['v1',, ['x1', ['y1', 'z1']],,
|
|
|
|
- [['x2', ['y2', 'z2']], ['x3', ['y3', 'z3']]], bytes1,, { 100: [, 'e1'] }],
|
|
|
|
|
|
+ assertArrayEquals(
|
|
|
|
+ [
|
|
|
|
+ 'v1', , ['x1', ['y1', 'z1']], ,
|
|
|
|
+ [['x2', ['y2', 'z2']], ['x3', ['y3', 'z3']]], bytes1, ,
|
|
|
|
+ {100: [, 'e1']}
|
|
|
|
+ ],
|
|
clone.toArray());
|
|
clone.toArray());
|
|
clone.setStr('v2');
|
|
clone.setStr('v2');
|
|
var simple4 = new proto.jspb.test.Simple1(['a1', ['b1', 'c1']]);
|
|
var simple4 = new proto.jspb.test.Simple1(['a1', ['b1', 'c1']]);
|
|
@@ -481,11 +484,19 @@ describe('Message test suite', function() {
|
|
var newExtension = new proto.jspb.test.CloneExtension();
|
|
var newExtension = new proto.jspb.test.CloneExtension();
|
|
newExtension.setExt('e2');
|
|
newExtension.setExt('e2');
|
|
clone.setExtension(proto.jspb.test.CloneExtension.extField, newExtension);
|
|
clone.setExtension(proto.jspb.test.CloneExtension.extField, newExtension);
|
|
- assertArrayEquals(['v2',, ['a1', ['b1', 'c1']],,
|
|
|
|
- [['a2', ['b2', 'c2']], ['a3', ['b3', 'c3']]], bytes2,, { 100: [, 'e2'] }],
|
|
|
|
|
|
+ assertArrayEquals(
|
|
|
|
+ [
|
|
|
|
+ 'v2', , ['a1', ['b1', 'c1']], ,
|
|
|
|
+ [['a2', ['b2', 'c2']], ['a3', ['b3', 'c3']]], bytes2, ,
|
|
|
|
+ {100: [, 'e2']}
|
|
|
|
+ ],
|
|
clone.toArray());
|
|
clone.toArray());
|
|
- assertArrayEquals(['v1',, ['x1', ['y1', 'z1']],,
|
|
|
|
- [['x2', ['y2', 'z2']], ['x3', ['y3', 'z3']]], bytes1,, { 100: [, 'e1'] }],
|
|
|
|
|
|
+ assertArrayEquals(
|
|
|
|
+ [
|
|
|
|
+ 'v1', , ['x1', ['y1', 'z1']], ,
|
|
|
|
+ [['x2', ['y2', 'z2']], ['x3', ['y3', 'z3']]], bytes1, ,
|
|
|
|
+ {100: [, 'e1']}
|
|
|
|
+ ],
|
|
original.toArray());
|
|
original.toArray());
|
|
});
|
|
});
|
|
|
|
|
|
@@ -517,11 +528,12 @@ describe('Message test suite', function() {
|
|
jspb.Message.copyInto(original, dest);
|
|
jspb.Message.copyInto(original, dest);
|
|
assertArrayEquals(original.toArray(), dest.toArray());
|
|
assertArrayEquals(original.toArray(), dest.toArray());
|
|
assertEquals('x1', dest.getSimple1().getAString());
|
|
assertEquals('x1', dest.getSimple1().getAString());
|
|
- assertEquals('e1',
|
|
|
|
|
|
+ assertEquals(
|
|
|
|
+ 'e1',
|
|
dest.getExtension(proto.jspb.test.CloneExtension.extField).getExt());
|
|
dest.getExtension(proto.jspb.test.CloneExtension.extField).getExt());
|
|
dest.getSimple1().setAString('new value');
|
|
dest.getSimple1().setAString('new value');
|
|
- assertNotEquals(dest.getSimple1().getAString(),
|
|
|
|
- original.getSimple1().getAString());
|
|
|
|
|
|
+ assertNotEquals(
|
|
|
|
+ dest.getSimple1().getAString(), original.getSimple1().getAString());
|
|
if (supportsUint8Array) {
|
|
if (supportsUint8Array) {
|
|
dest.getBytesField()[0] = 7;
|
|
dest.getBytesField()[0] = 7;
|
|
assertObjectEquals(bytes1, original.getBytesField());
|
|
assertObjectEquals(bytes1, original.getBytesField());
|
|
@@ -531,12 +543,12 @@ describe('Message test suite', function() {
|
|
assertObjectEquals(bytes1, original.getBytesField());
|
|
assertObjectEquals(bytes1, original.getBytesField());
|
|
assertObjectEquals('789', dest.getBytesField());
|
|
assertObjectEquals('789', dest.getBytesField());
|
|
}
|
|
}
|
|
- dest.getExtension(proto.jspb.test.CloneExtension.extField).
|
|
|
|
- setExt('new value');
|
|
|
|
|
|
+ dest.getExtension(proto.jspb.test.CloneExtension.extField)
|
|
|
|
+ .setExt('new value');
|
|
assertNotEquals(
|
|
assertNotEquals(
|
|
dest.getExtension(proto.jspb.test.CloneExtension.extField).getExt(),
|
|
dest.getExtension(proto.jspb.test.CloneExtension.extField).getExt(),
|
|
- original.getExtension(
|
|
|
|
- proto.jspb.test.CloneExtension.extField).getExt());
|
|
|
|
|
|
+ original.getExtension(proto.jspb.test.CloneExtension.extField)
|
|
|
|
+ .getExt());
|
|
});
|
|
});
|
|
|
|
|
|
it('testCopyInto_notSameType', function() {
|
|
it('testCopyInto_notSameType', function() {
|
|
@@ -554,26 +566,32 @@ describe('Message test suite', function() {
|
|
var extension2 = new proto.jspb.test.Simple1(['str', ['s1', 's2']]);
|
|
var extension2 = new proto.jspb.test.Simple1(['str', ['s1', 's2']]);
|
|
var extendable = new proto.jspb.test.HasExtensions(['v1', 'v2', 'v3']);
|
|
var extendable = new proto.jspb.test.HasExtensions(['v1', 'v2', 'v3']);
|
|
extendable.setExtension(proto.jspb.test.IsExtension.extField, extension1);
|
|
extendable.setExtension(proto.jspb.test.IsExtension.extField, extension1);
|
|
- extendable.setExtension(proto.jspb.test.IndirectExtension.simple,
|
|
|
|
- extension2);
|
|
|
|
|
|
+ extendable.setExtension(
|
|
|
|
+ proto.jspb.test.IndirectExtension.simple, extension2);
|
|
extendable.setExtension(proto.jspb.test.IndirectExtension.str, 'xyzzy');
|
|
extendable.setExtension(proto.jspb.test.IndirectExtension.str, 'xyzzy');
|
|
- extendable.setExtension(proto.jspb.test.IndirectExtension.repeatedStrList,
|
|
|
|
- ['a', 'b']);
|
|
|
|
|
|
+ extendable.setExtension(
|
|
|
|
+ proto.jspb.test.IndirectExtension.repeatedStrList, ['a', 'b']);
|
|
var s1 = new proto.jspb.test.Simple1(['foo', ['s1', 's2']]);
|
|
var s1 = new proto.jspb.test.Simple1(['foo', ['s1', 's2']]);
|
|
var s2 = new proto.jspb.test.Simple1(['bar', ['t1', 't2']]);
|
|
var s2 = new proto.jspb.test.Simple1(['bar', ['t1', 't2']]);
|
|
extendable.setExtension(
|
|
extendable.setExtension(
|
|
- proto.jspb.test.IndirectExtension.repeatedSimpleList,
|
|
|
|
- [s1, s2]);
|
|
|
|
- assertObjectEquals(extension1,
|
|
|
|
|
|
+ proto.jspb.test.IndirectExtension.repeatedSimpleList, [s1, s2]);
|
|
|
|
+ assertObjectEquals(
|
|
|
|
+ extension1,
|
|
extendable.getExtension(proto.jspb.test.IsExtension.extField));
|
|
extendable.getExtension(proto.jspb.test.IsExtension.extField));
|
|
- assertObjectEquals(extension2,
|
|
|
|
|
|
+ assertObjectEquals(
|
|
|
|
+ extension2,
|
|
extendable.getExtension(proto.jspb.test.IndirectExtension.simple));
|
|
extendable.getExtension(proto.jspb.test.IndirectExtension.simple));
|
|
- assertObjectEquals('xyzzy',
|
|
|
|
|
|
+ assertObjectEquals(
|
|
|
|
+ 'xyzzy',
|
|
extendable.getExtension(proto.jspb.test.IndirectExtension.str));
|
|
extendable.getExtension(proto.jspb.test.IndirectExtension.str));
|
|
- assertObjectEquals(['a', 'b'], extendable.getExtension(
|
|
|
|
- proto.jspb.test.IndirectExtension.repeatedStrList));
|
|
|
|
- assertObjectEquals([s1, s2], extendable.getExtension(
|
|
|
|
- proto.jspb.test.IndirectExtension.repeatedSimpleList));
|
|
|
|
|
|
+ assertObjectEquals(
|
|
|
|
+ ['a', 'b'],
|
|
|
|
+ extendable.getExtension(
|
|
|
|
+ proto.jspb.test.IndirectExtension.repeatedStrList));
|
|
|
|
+ assertObjectEquals(
|
|
|
|
+ [s1, s2],
|
|
|
|
+ extendable.getExtension(
|
|
|
|
+ proto.jspb.test.IndirectExtension.repeatedSimpleList));
|
|
// Not supported yet, but it should work...
|
|
// Not supported yet, but it should work...
|
|
extendable.setExtension(proto.jspb.test.IndirectExtension.simple, null);
|
|
extendable.setExtension(proto.jspb.test.IndirectExtension.simple, null);
|
|
assertNull(
|
|
assertNull(
|
|
@@ -592,29 +610,35 @@ describe('Message test suite', function() {
|
|
var extendable = new proto.jspb.test.HasExtensions(['v1', 'v2', 'v3']);
|
|
var extendable = new proto.jspb.test.HasExtensions(['v1', 'v2', 'v3']);
|
|
var extension = new proto.jspb.test.Simple1(['foo', ['s1', 's2']]);
|
|
var extension = new proto.jspb.test.Simple1(['foo', ['s1', 's2']]);
|
|
extendable.setExtension(proto.jspb.test.simple1, extension);
|
|
extendable.setExtension(proto.jspb.test.simple1, extension);
|
|
- assertObjectEquals(extension,
|
|
|
|
- extendable.getExtension(proto.jspb.test.simple1));
|
|
|
|
|
|
+ assertObjectEquals(
|
|
|
|
+ extension, extendable.getExtension(proto.jspb.test.simple1));
|
|
|
|
|
|
// From _lib mode.
|
|
// From _lib mode.
|
|
extension = new proto.jspb.test.ExtensionMessage(['s1']);
|
|
extension = new proto.jspb.test.ExtensionMessage(['s1']);
|
|
extendable = new proto.jspb.test.TestExtensionsMessage([16]);
|
|
extendable = new proto.jspb.test.TestExtensionsMessage([16]);
|
|
extendable.setExtension(proto.jspb.test.floatingMsgField, extension);
|
|
extendable.setExtension(proto.jspb.test.floatingMsgField, extension);
|
|
extendable.setExtension(proto.jspb.test.floatingStrField, 's2');
|
|
extendable.setExtension(proto.jspb.test.floatingStrField, 's2');
|
|
- assertObjectEquals(extension,
|
|
|
|
- extendable.getExtension(proto.jspb.test.floatingMsgField));
|
|
|
|
- assertObjectEquals('s2',
|
|
|
|
- extendable.getExtension(proto.jspb.test.floatingStrField));
|
|
|
|
|
|
+ assertObjectEquals(
|
|
|
|
+ extension, extendable.getExtension(proto.jspb.test.floatingMsgField));
|
|
|
|
+ assertObjectEquals(
|
|
|
|
+ 's2', extendable.getExtension(proto.jspb.test.floatingStrField));
|
|
assertNotUndefined(proto.jspb.exttest.floatingMsgField);
|
|
assertNotUndefined(proto.jspb.exttest.floatingMsgField);
|
|
assertNotUndefined(proto.jspb.exttest.floatingMsgFieldTwo);
|
|
assertNotUndefined(proto.jspb.exttest.floatingMsgFieldTwo);
|
|
assertNotUndefined(proto.jspb.exttest.beta.floatingStrField);
|
|
assertNotUndefined(proto.jspb.exttest.beta.floatingStrField);
|
|
});
|
|
});
|
|
|
|
|
|
it('testNestedExtensions', function() {
|
|
it('testNestedExtensions', function() {
|
|
- var extendable = new proto.jspb.exttest.nested.TestNestedExtensionsMessage();
|
|
|
|
- var extension = new proto.jspb.exttest.nested.TestOuterMessage.NestedExtensionMessage(['s1']);
|
|
|
|
- extendable.setExtension(proto.jspb.exttest.nested.TestOuterMessage.innerExtension, extension);
|
|
|
|
- assertObjectEquals(extension,
|
|
|
|
- extendable.getExtension(proto.jspb.exttest.nested.TestOuterMessage.innerExtension));
|
|
|
|
|
|
+ var extendable =
|
|
|
|
+ new proto.jspb.exttest.nested.TestNestedExtensionsMessage();
|
|
|
|
+ var extension =
|
|
|
|
+ new proto.jspb.exttest.nested.TestOuterMessage.NestedExtensionMessage(
|
|
|
|
+ ['s1']);
|
|
|
|
+ extendable.setExtension(
|
|
|
|
+ proto.jspb.exttest.nested.TestOuterMessage.innerExtension, extension);
|
|
|
|
+ assertObjectEquals(
|
|
|
|
+ extension,
|
|
|
|
+ extendable.getExtension(
|
|
|
|
+ proto.jspb.exttest.nested.TestOuterMessage.innerExtension));
|
|
});
|
|
});
|
|
|
|
|
|
it('testToObject_extendedObject', function() {
|
|
it('testToObject_extendedObject', function() {
|
|
@@ -622,60 +646,72 @@ describe('Message test suite', function() {
|
|
var extension2 = new proto.jspb.test.Simple1(['str', ['s1', 's2'], true]);
|
|
var extension2 = new proto.jspb.test.Simple1(['str', ['s1', 's2'], true]);
|
|
var extendable = new proto.jspb.test.HasExtensions(['v1', 'v2', 'v3']);
|
|
var extendable = new proto.jspb.test.HasExtensions(['v1', 'v2', 'v3']);
|
|
extendable.setExtension(proto.jspb.test.IsExtension.extField, extension1);
|
|
extendable.setExtension(proto.jspb.test.IsExtension.extField, extension1);
|
|
- extendable.setExtension(proto.jspb.test.IndirectExtension.simple,
|
|
|
|
- extension2);
|
|
|
|
|
|
+ extendable.setExtension(
|
|
|
|
+ proto.jspb.test.IndirectExtension.simple, extension2);
|
|
extendable.setExtension(proto.jspb.test.IndirectExtension.str, 'xyzzy');
|
|
extendable.setExtension(proto.jspb.test.IndirectExtension.str, 'xyzzy');
|
|
- extendable.setExtension(proto.jspb.test.IndirectExtension.repeatedStrList,
|
|
|
|
- ['a', 'b']);
|
|
|
|
|
|
+ extendable.setExtension(
|
|
|
|
+ proto.jspb.test.IndirectExtension.repeatedStrList, ['a', 'b']);
|
|
var s1 = new proto.jspb.test.Simple1(['foo', ['s1', 's2'], true]);
|
|
var s1 = new proto.jspb.test.Simple1(['foo', ['s1', 's2'], true]);
|
|
var s2 = new proto.jspb.test.Simple1(['bar', ['t1', 't2'], false]);
|
|
var s2 = new proto.jspb.test.Simple1(['bar', ['t1', 't2'], false]);
|
|
extendable.setExtension(
|
|
extendable.setExtension(
|
|
- proto.jspb.test.IndirectExtension.repeatedSimpleList,
|
|
|
|
- [s1, s2]);
|
|
|
|
- assertObjectEquals({
|
|
|
|
- str1: 'v1', str2: 'v2', str3: 'v3',
|
|
|
|
- extField: { ext1: 'ext1field' },
|
|
|
|
- simple: {
|
|
|
|
- aString: 'str', aRepeatedStringList: ['s1', 's2'], aBoolean: true
|
|
|
|
- },
|
|
|
|
- str: 'xyzzy',
|
|
|
|
- repeatedStrList: ['a', 'b'],
|
|
|
|
- repeatedSimpleList: [
|
|
|
|
- { aString: 'foo', aRepeatedStringList: ['s1', 's2'], aBoolean: true},
|
|
|
|
- { aString: 'bar', aRepeatedStringList: ['t1', 't2'], aBoolean: false}
|
|
|
|
- ]
|
|
|
|
- }, extendable.toObject());
|
|
|
|
|
|
+ proto.jspb.test.IndirectExtension.repeatedSimpleList, [s1, s2]);
|
|
|
|
+ assertObjectEquals(
|
|
|
|
+ {
|
|
|
|
+ str1: 'v1',
|
|
|
|
+ str2: 'v2',
|
|
|
|
+ str3: 'v3',
|
|
|
|
+ extField: {ext1: 'ext1field'},
|
|
|
|
+ simple: {
|
|
|
|
+ aString: 'str',
|
|
|
|
+ aRepeatedStringList: ['s1', 's2'],
|
|
|
|
+ aBoolean: true
|
|
|
|
+ },
|
|
|
|
+ str: 'xyzzy',
|
|
|
|
+ repeatedStrList: ['a', 'b'],
|
|
|
|
+ repeatedSimpleList: [
|
|
|
|
+ {aString: 'foo', aRepeatedStringList: ['s1', 's2'], aBoolean: true},
|
|
|
|
+ {aString: 'bar', aRepeatedStringList: ['t1', 't2'], aBoolean: false}
|
|
|
|
+ ]
|
|
|
|
+ },
|
|
|
|
+ extendable.toObject());
|
|
|
|
|
|
// Now, with instances included.
|
|
// Now, with instances included.
|
|
- assertObjectEquals({
|
|
|
|
- str1: 'v1', str2: 'v2', str3: 'v3',
|
|
|
|
- extField: {
|
|
|
|
- ext1: 'ext1field',
|
|
|
|
- $jspbMessageInstance:
|
|
|
|
- extendable.getExtension(proto.jspb.test.IsExtension.extField)
|
|
|
|
- },
|
|
|
|
- simple: {
|
|
|
|
- aString: 'str',
|
|
|
|
- aRepeatedStringList: ['s1', 's2'],
|
|
|
|
- aBoolean: true,
|
|
|
|
- $jspbMessageInstance:
|
|
|
|
- extendable.getExtension(proto.jspb.test.IndirectExtension.simple)
|
|
|
|
- },
|
|
|
|
- str: 'xyzzy',
|
|
|
|
- repeatedStrList: ['a', 'b'],
|
|
|
|
- repeatedSimpleList: [{
|
|
|
|
- aString: 'foo',
|
|
|
|
- aRepeatedStringList: ['s1', 's2'],
|
|
|
|
- aBoolean: true,
|
|
|
|
- $jspbMessageInstance: s1
|
|
|
|
- }, {
|
|
|
|
- aString: 'bar',
|
|
|
|
- aRepeatedStringList: ['t1', 't2'],
|
|
|
|
- aBoolean: false,
|
|
|
|
- $jspbMessageInstance: s2
|
|
|
|
- }],
|
|
|
|
- $jspbMessageInstance: extendable
|
|
|
|
- }, extendable.toObject(true /* opt_includeInstance */));
|
|
|
|
|
|
+ assertObjectEquals(
|
|
|
|
+ {
|
|
|
|
+ str1: 'v1',
|
|
|
|
+ str2: 'v2',
|
|
|
|
+ str3: 'v3',
|
|
|
|
+ extField: {
|
|
|
|
+ ext1: 'ext1field',
|
|
|
|
+ $jspbMessageInstance:
|
|
|
|
+ extendable.getExtension(proto.jspb.test.IsExtension.extField)
|
|
|
|
+ },
|
|
|
|
+ simple: {
|
|
|
|
+ aString: 'str',
|
|
|
|
+ aRepeatedStringList: ['s1', 's2'],
|
|
|
|
+ aBoolean: true,
|
|
|
|
+ $jspbMessageInstance: extendable.getExtension(
|
|
|
|
+ proto.jspb.test.IndirectExtension.simple)
|
|
|
|
+ },
|
|
|
|
+ str: 'xyzzy',
|
|
|
|
+ repeatedStrList: ['a', 'b'],
|
|
|
|
+ repeatedSimpleList: [
|
|
|
|
+ {
|
|
|
|
+ aString: 'foo',
|
|
|
|
+ aRepeatedStringList: ['s1', 's2'],
|
|
|
|
+ aBoolean: true,
|
|
|
|
+ $jspbMessageInstance: s1
|
|
|
|
+ },
|
|
|
|
+ {
|
|
|
|
+ aString: 'bar',
|
|
|
|
+ aRepeatedStringList: ['t1', 't2'],
|
|
|
|
+ aBoolean: false,
|
|
|
|
+ $jspbMessageInstance: s2
|
|
|
|
+ }
|
|
|
|
+ ],
|
|
|
|
+ $jspbMessageInstance: extendable
|
|
|
|
+ },
|
|
|
|
+ extendable.toObject(true /* opt_includeInstance */));
|
|
});
|
|
});
|
|
|
|
|
|
it('testInitialization_emptyArray', function() {
|
|
it('testInitialization_emptyArray', function() {
|
|
@@ -708,7 +744,8 @@ describe('Message test suite', function() {
|
|
});
|
|
});
|
|
|
|
|
|
it('testToObject_hasExtensionField', function() {
|
|
it('testToObject_hasExtensionField', function() {
|
|
- var data = new proto.jspb.test.HasExtensions(['str1', {100: ['ext1'], 102: ''}]);
|
|
|
|
|
|
+ var data =
|
|
|
|
+ new proto.jspb.test.HasExtensions(['str1', {100: ['ext1'], 102: ''}]);
|
|
var obj = data.toObject();
|
|
var obj = data.toObject();
|
|
assertEquals('str1', obj.str1);
|
|
assertEquals('str1', obj.str1);
|
|
assertEquals('ext1', obj.extField.ext1);
|
|
assertEquals('ext1', obj.extField.ext1);
|
|
@@ -728,8 +765,7 @@ describe('Message test suite', function() {
|
|
var extensionMessage = new proto.jspb.test.IsExtension(['is_extension']);
|
|
var extensionMessage = new proto.jspb.test.IsExtension(['is_extension']);
|
|
data.setExtension(proto.jspb.test.IsExtension.extField, extensionMessage);
|
|
data.setExtension(proto.jspb.test.IsExtension.extField, extensionMessage);
|
|
var obj = data.toObject();
|
|
var obj = data.toObject();
|
|
- assertNotNull(
|
|
|
|
- data.getExtension(proto.jspb.test.IsExtension.extField));
|
|
|
|
|
|
+ assertNotNull(data.getExtension(proto.jspb.test.IsExtension.extField));
|
|
assertEquals('is_extension', obj.extField.ext1);
|
|
assertEquals('is_extension', obj.extField.ext1);
|
|
});
|
|
});
|
|
|
|
|
|
@@ -746,16 +782,18 @@ describe('Message test suite', function() {
|
|
var groups = group.getRepeatedGroupList();
|
|
var groups = group.getRepeatedGroupList();
|
|
assertEquals('g1', groups[0].getId());
|
|
assertEquals('g1', groups[0].getId());
|
|
assertObjectEquals([true, false], groups[0].getSomeBoolList());
|
|
assertObjectEquals([true, false], groups[0].getSomeBoolList());
|
|
- assertObjectEquals({id: 'g1', someBoolList: [true, false]},
|
|
|
|
- groups[0].toObject());
|
|
|
|
- assertObjectEquals({
|
|
|
|
- repeatedGroupList: [{id: 'g1', someBoolList: [true, false]}],
|
|
|
|
- requiredGroup: {id: undefined},
|
|
|
|
- optionalGroup: undefined,
|
|
|
|
- requiredSimple: {aRepeatedStringList: [], aString: undefined},
|
|
|
|
- optionalSimple: undefined,
|
|
|
|
- id: undefined
|
|
|
|
- }, group.toObject());
|
|
|
|
|
|
+ assertObjectEquals(
|
|
|
|
+ {id: 'g1', someBoolList: [true, false]}, groups[0].toObject());
|
|
|
|
+ assertObjectEquals(
|
|
|
|
+ {
|
|
|
|
+ repeatedGroupList: [{id: 'g1', someBoolList: [true, false]}],
|
|
|
|
+ requiredGroup: {id: undefined},
|
|
|
|
+ optionalGroup: undefined,
|
|
|
|
+ requiredSimple: {aRepeatedStringList: [], aString: undefined},
|
|
|
|
+ optionalSimple: undefined,
|
|
|
|
+ id: undefined
|
|
|
|
+ },
|
|
|
|
+ group.toObject());
|
|
var group1 = new proto.jspb.test.TestGroup1();
|
|
var group1 = new proto.jspb.test.TestGroup1();
|
|
group1.setGroup(someGroup);
|
|
group1.setGroup(someGroup);
|
|
assertEquals(someGroup, group1.getGroup());
|
|
assertEquals(someGroup, group1.getGroup());
|
|
@@ -772,28 +810,29 @@ describe('Message test suite', function() {
|
|
message.setExtension$(11);
|
|
message.setExtension$(11);
|
|
message.setExtension(proto.jspb.test.TestReservedNamesExtension.foo, 12);
|
|
message.setExtension(proto.jspb.test.TestReservedNamesExtension.foo, 12);
|
|
assertEquals(11, message.getExtension$());
|
|
assertEquals(11, message.getExtension$());
|
|
- assertEquals(12, message.getExtension(
|
|
|
|
- proto.jspb.test.TestReservedNamesExtension.foo));
|
|
|
|
|
|
+ assertEquals(
|
|
|
|
+ 12,
|
|
|
|
+ message.getExtension(proto.jspb.test.TestReservedNamesExtension.foo));
|
|
assertObjectEquals({extension: 11, foo: 12}, message.toObject());
|
|
assertObjectEquals({extension: 11, foo: 12}, message.toObject());
|
|
});
|
|
});
|
|
|
|
|
|
it('testInitializeMessageWithUnsetOneof', function() {
|
|
it('testInitializeMessageWithUnsetOneof', function() {
|
|
var message = new proto.jspb.test.TestMessageWithOneof([]);
|
|
var message = new proto.jspb.test.TestMessageWithOneof([]);
|
|
assertEquals(
|
|
assertEquals(
|
|
- proto.jspb.test.TestMessageWithOneof.PartialOneofCase.
|
|
|
|
- PARTIAL_ONEOF_NOT_SET,
|
|
|
|
|
|
+ proto.jspb.test.TestMessageWithOneof.PartialOneofCase
|
|
|
|
+ .PARTIAL_ONEOF_NOT_SET,
|
|
message.getPartialOneofCase());
|
|
message.getPartialOneofCase());
|
|
assertEquals(
|
|
assertEquals(
|
|
- proto.jspb.test.TestMessageWithOneof.RecursiveOneofCase.
|
|
|
|
- RECURSIVE_ONEOF_NOT_SET,
|
|
|
|
|
|
+ proto.jspb.test.TestMessageWithOneof.RecursiveOneofCase
|
|
|
|
+ .RECURSIVE_ONEOF_NOT_SET,
|
|
message.getRecursiveOneofCase());
|
|
message.getRecursiveOneofCase());
|
|
});
|
|
});
|
|
|
|
|
|
it('testUnsetsOneofCaseWhenFieldIsCleared', function() {
|
|
it('testUnsetsOneofCaseWhenFieldIsCleared', function() {
|
|
var message = new proto.jspb.test.TestMessageWithOneof;
|
|
var message = new proto.jspb.test.TestMessageWithOneof;
|
|
assertEquals(
|
|
assertEquals(
|
|
- proto.jspb.test.TestMessageWithOneof.PartialOneofCase.
|
|
|
|
- PARTIAL_ONEOF_NOT_SET,
|
|
|
|
|
|
+ proto.jspb.test.TestMessageWithOneof.PartialOneofCase
|
|
|
|
+ .PARTIAL_ONEOF_NOT_SET,
|
|
message.getPartialOneofCase());
|
|
message.getPartialOneofCase());
|
|
|
|
|
|
message.setPone('hi');
|
|
message.setPone('hi');
|
|
@@ -803,20 +842,20 @@ describe('Message test suite', function() {
|
|
|
|
|
|
message.clearPone();
|
|
message.clearPone();
|
|
assertEquals(
|
|
assertEquals(
|
|
- proto.jspb.test.TestMessageWithOneof.PartialOneofCase.
|
|
|
|
- PARTIAL_ONEOF_NOT_SET,
|
|
|
|
|
|
+ proto.jspb.test.TestMessageWithOneof.PartialOneofCase
|
|
|
|
+ .PARTIAL_ONEOF_NOT_SET,
|
|
message.getPartialOneofCase());
|
|
message.getPartialOneofCase());
|
|
});
|
|
});
|
|
|
|
|
|
it('testFloatingPointFieldsSupportNan', function() {
|
|
it('testFloatingPointFieldsSupportNan', function() {
|
|
var assertNan = function(x) {
|
|
var assertNan = function(x) {
|
|
- assertTrue('Expected ' + x + ' (' + goog.typeOf(x) + ') to be NaN.',
|
|
|
|
|
|
+ assertTrue(
|
|
|
|
+ 'Expected ' + x + ' (' + goog.typeOf(x) + ') to be NaN.',
|
|
goog.isNumber(x) && isNaN(x));
|
|
goog.isNumber(x) && isNaN(x));
|
|
};
|
|
};
|
|
|
|
|
|
var message = new proto.jspb.test.FloatingPointFields([
|
|
var message = new proto.jspb.test.FloatingPointFields([
|
|
- 'NaN', 'NaN', ['NaN', 'NaN'], 'NaN',
|
|
|
|
- 'NaN', 'NaN', ['NaN', 'NaN'], 'NaN'
|
|
|
|
|
|
+ 'NaN', 'NaN', ['NaN', 'NaN'], 'NaN', 'NaN', 'NaN', ['NaN', 'NaN'], 'NaN'
|
|
]);
|
|
]);
|
|
assertNan(message.getOptionalFloatField());
|
|
assertNan(message.getOptionalFloatField());
|
|
assertNan(message.getRequiredFloatField());
|
|
assertNan(message.getRequiredFloatField());
|
|
@@ -837,12 +876,9 @@ describe('Message test suite', function() {
|
|
message2.setExtension(
|
|
message2.setExtension(
|
|
proto.jspb.exttest.reverse.TestExtensionReverseOrderMessage1.a, 233);
|
|
proto.jspb.exttest.reverse.TestExtensionReverseOrderMessage1.a, 233);
|
|
message2.setExtension(
|
|
message2.setExtension(
|
|
- proto
|
|
|
|
- .jspb
|
|
|
|
- .exttest
|
|
|
|
- .reverse
|
|
|
|
- .TestExtensionReverseOrderMessage1
|
|
|
|
- .TestExtensionReverseOrderNestedMessage1.b, 2333);
|
|
|
|
|
|
+ proto.jspb.exttest.reverse.TestExtensionReverseOrderMessage1
|
|
|
|
+ .TestExtensionReverseOrderNestedMessage1.b,
|
|
|
|
+ 2333);
|
|
message2.setExtension(proto.jspb.exttest.reverse.c, 23333);
|
|
message2.setExtension(proto.jspb.exttest.reverse.c, 23333);
|
|
|
|
|
|
assertEquals(
|
|
assertEquals(
|
|
@@ -852,15 +888,9 @@ describe('Message test suite', function() {
|
|
assertEquals(
|
|
assertEquals(
|
|
2333,
|
|
2333,
|
|
message2.getExtension(
|
|
message2.getExtension(
|
|
- proto
|
|
|
|
- .jspb
|
|
|
|
- .exttest
|
|
|
|
- .reverse
|
|
|
|
- .TestExtensionReverseOrderMessage1
|
|
|
|
|
|
+ proto.jspb.exttest.reverse.TestExtensionReverseOrderMessage1
|
|
.TestExtensionReverseOrderNestedMessage1.b));
|
|
.TestExtensionReverseOrderNestedMessage1.b));
|
|
- assertEquals(
|
|
|
|
- 23333,
|
|
|
|
- message2.getExtension(proto.jspb.exttest.reverse.c));
|
|
|
|
|
|
+ assertEquals(23333, message2.getExtension(proto.jspb.exttest.reverse.c));
|
|
});
|
|
});
|
|
|
|
|
|
it('testCircularDepsBaseOnMessageField', function() {
|
|
it('testCircularDepsBaseOnMessageField', function() {
|
|
@@ -983,16 +1013,14 @@ describe('Message test suite', function() {
|
|
var package1Message = new proto.jspb.filenametest.package1.TestMessage;
|
|
var package1Message = new proto.jspb.filenametest.package1.TestMessage;
|
|
var package2Message = new proto.jspb.filenametest.package2.TestMessage;
|
|
var package2Message = new proto.jspb.filenametest.package2.TestMessage;
|
|
|
|
|
|
- package1Message.setExtension(
|
|
|
|
- proto.jspb.filenametest.package1.a, 10);
|
|
|
|
- package1Message.setExtension(
|
|
|
|
- proto.jspb.filenametest.package1.b, 11);
|
|
|
|
|
|
+ package1Message.setExtension(proto.jspb.filenametest.package1.a, 10);
|
|
|
|
+ package1Message.setExtension(proto.jspb.filenametest.package1.b, 11);
|
|
package2Message.setA(12);
|
|
package2Message.setA(12);
|
|
|
|
|
|
- assertEquals(10,
|
|
|
|
- package1Message.getExtension(proto.jspb.filenametest.package1.a));
|
|
|
|
- assertEquals(11,
|
|
|
|
- package1Message.getExtension(proto.jspb.filenametest.package1.b));
|
|
|
|
|
|
+ assertEquals(
|
|
|
|
+ 10, package1Message.getExtension(proto.jspb.filenametest.package1.a));
|
|
|
|
+ assertEquals(
|
|
|
|
+ 11, package1Message.getExtension(proto.jspb.filenametest.package1.b));
|
|
assertEquals(12, package2Message.getA());
|
|
assertEquals(12, package2Message.getA());
|
|
});
|
|
});
|
|
|
|
|