proto3_test.js 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477
  1. // Protocol Buffers - Google's data interchange format
  2. // Copyright 2008 Google Inc. All rights reserved.
  3. // https://developers.google.com/protocol-buffers/
  4. //
  5. // Redistribution and use in source and binary forms, with or without
  6. // modification, are permitted provided that the following conditions are
  7. // met:
  8. //
  9. // * Redistributions of source code must retain the above copyright
  10. // notice, this list of conditions and the following disclaimer.
  11. // * Redistributions in binary form must reproduce the above
  12. // copyright notice, this list of conditions and the following disclaimer
  13. // in the documentation and/or other materials provided with the
  14. // distribution.
  15. // * Neither the name of Google Inc. nor the names of its
  16. // contributors may be used to endorse or promote products derived from
  17. // this software without specific prior written permission.
  18. //
  19. // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  20. // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  21. // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
  22. // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
  23. // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  24. // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  25. // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
  26. // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  27. // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  28. // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  29. // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  30. goog.require('goog.crypt.base64');
  31. goog.require('goog.testing.asserts');
  32. // CommonJS-LoadFromFile: testbinary_pb proto.jspb.test
  33. goog.require('proto.jspb.test.ForeignMessage');
  34. // CommonJS-LoadFromFile: proto3_test_pb proto.jspb.test
  35. goog.require('proto.jspb.test.Proto3Enum');
  36. goog.require('proto.jspb.test.TestProto3');
  37. // CommonJS-LoadFromFile: google/protobuf/any_pb proto.google.protobuf
  38. goog.require('proto.google.protobuf.Any');
  39. // CommonJS-LoadFromFile: google/protobuf/timestamp_pb proto.google.protobuf
  40. goog.require('proto.google.protobuf.Timestamp');
  41. // CommonJS-LoadFromFile: google/protobuf/struct_pb proto.google.protobuf
  42. goog.require('proto.google.protobuf.Struct');
  43. var BYTES = new Uint8Array([1, 2, 8, 9]);
  44. var BYTES_B64 = goog.crypt.base64.encodeByteArray(BYTES);
  45. /**
  46. * Helper: compare a bytes field to an expected value
  47. * @param {Uint8Array|string} arr
  48. * @param {Uint8Array} expected
  49. * @return {boolean}
  50. */
  51. function bytesCompare(arr, expected) {
  52. if (typeof arr === 'string') {
  53. arr = goog.crypt.base64.decodeStringToUint8Array(arr);
  54. }
  55. if (arr.length != expected.length) {
  56. return false;
  57. }
  58. for (var i = 0; i < arr.length; i++) {
  59. if (arr[i] != expected[i]) {
  60. return false;
  61. }
  62. }
  63. return true;
  64. }
  65. describe('proto3Test', function() {
  66. /**
  67. * Test default values don't affect equality test.
  68. */
  69. it('testEqualsProto3', function() {
  70. var msg1 = new proto.jspb.test.TestProto3();
  71. var msg2 = new proto.jspb.test.TestProto3();
  72. msg2.setSingularString('');
  73. assertTrue(jspb.Message.equals(msg1, msg2));
  74. });
  75. /**
  76. * Test setting when a field has default semantics.
  77. */
  78. it('testSetProto3ToValueAndBackToDefault', function() {
  79. var msg = new proto.jspb.test.TestProto3();
  80. // Setting should work normally.
  81. msg.setSingularString('optionalString');
  82. assertEquals(msg.getSingularString(), 'optionalString');
  83. // Clearing should work too ...
  84. msg.setSingularString('');
  85. assertEquals(msg.getSingularString(), '');
  86. // ... and shouldn't affect the equality with a brand new message.
  87. assertTrue(jspb.Message.equals(msg, new proto.jspb.test.TestProto3()));
  88. });
  89. /**
  90. * Test defaults for proto3 message fields.
  91. */
  92. it('testProto3FieldDefaults', function() {
  93. var msg = new proto.jspb.test.TestProto3();
  94. assertEquals(msg.getSingularInt32(), 0);
  95. assertEquals(msg.getSingularInt64(), 0);
  96. assertEquals(msg.getSingularUint32(), 0);
  97. assertEquals(msg.getSingularUint64(), 0);
  98. assertEquals(msg.getSingularSint32(), 0);
  99. assertEquals(msg.getSingularSint64(), 0);
  100. assertEquals(msg.getSingularFixed32(), 0);
  101. assertEquals(msg.getSingularFixed64(), 0);
  102. assertEquals(msg.getSingularSfixed32(), 0);
  103. assertEquals(msg.getSingularSfixed64(), 0);
  104. assertEquals(msg.getSingularFloat(), 0);
  105. assertEquals(msg.getSingularDouble(), 0);
  106. assertEquals(msg.getSingularString(), '');
  107. // TODO(b/26173701): when we change bytes fields default getter to return
  108. // Uint8Array, we'll want to switch this assertion to match the u8 case.
  109. assertEquals(typeof msg.getSingularBytes(), 'string');
  110. assertEquals(msg.getSingularBytes_asU8() instanceof Uint8Array, true);
  111. assertEquals(typeof msg.getSingularBytes_asB64(), 'string');
  112. assertEquals(msg.getSingularBytes().length, 0);
  113. assertEquals(msg.getSingularBytes_asU8().length, 0);
  114. assertEquals(msg.getSingularBytes_asB64(), '');
  115. assertEquals(msg.getSingularForeignEnum(),
  116. proto.jspb.test.Proto3Enum.PROTO3_FOO);
  117. assertEquals(msg.getSingularForeignMessage(), undefined);
  118. assertEquals(msg.getSingularForeignMessage(), undefined);
  119. assertEquals(msg.getRepeatedInt32List().length, 0);
  120. assertEquals(msg.getRepeatedInt64List().length, 0);
  121. assertEquals(msg.getRepeatedUint32List().length, 0);
  122. assertEquals(msg.getRepeatedUint64List().length, 0);
  123. assertEquals(msg.getRepeatedSint32List().length, 0);
  124. assertEquals(msg.getRepeatedSint64List().length, 0);
  125. assertEquals(msg.getRepeatedFixed32List().length, 0);
  126. assertEquals(msg.getRepeatedFixed64List().length, 0);
  127. assertEquals(msg.getRepeatedSfixed32List().length, 0);
  128. assertEquals(msg.getRepeatedSfixed64List().length, 0);
  129. assertEquals(msg.getRepeatedFloatList().length, 0);
  130. assertEquals(msg.getRepeatedDoubleList().length, 0);
  131. assertEquals(msg.getRepeatedStringList().length, 0);
  132. assertEquals(msg.getRepeatedBytesList().length, 0);
  133. assertEquals(msg.getRepeatedForeignEnumList().length, 0);
  134. assertEquals(msg.getRepeatedForeignMessageList().length, 0);
  135. });
  136. /**
  137. * Test presence for proto3 optional fields.
  138. */
  139. it('testProto3Optional', function() {
  140. var msg = new proto.jspb.test.TestProto3();
  141. assertEquals(msg.getOptionalInt32(), 0);
  142. assertEquals(msg.getOptionalInt64(), 0);
  143. assertEquals(msg.getOptionalUint32(), 0);
  144. assertEquals(msg.getOptionalUint64(), 0);
  145. assertEquals(msg.getOptionalSint32(), 0);
  146. assertEquals(msg.getOptionalSint64(), 0);
  147. assertEquals(msg.getOptionalFixed32(), 0);
  148. assertEquals(msg.getOptionalFixed64(), 0);
  149. assertEquals(msg.getOptionalSfixed32(), 0);
  150. assertEquals(msg.getOptionalSfixed64(), 0);
  151. assertEquals(msg.getOptionalFloat(), 0);
  152. assertEquals(msg.getOptionalDouble(), 0);
  153. assertEquals(msg.getOptionalString(), '');
  154. // TODO(b/26173701): when we change bytes fields default getter to return
  155. // Uint8Array, we'll want to switch this assertion to match the u8 case.
  156. assertEquals(typeof msg.getOptionalBytes(), 'string');
  157. assertEquals(msg.getOptionalBytes_asU8() instanceof Uint8Array, true);
  158. assertEquals(typeof msg.getOptionalBytes_asB64(), 'string');
  159. assertEquals(msg.getOptionalBytes().length, 0);
  160. assertEquals(msg.getOptionalBytes_asU8().length, 0);
  161. assertEquals(msg.getOptionalBytes_asB64(), '');
  162. assertEquals(msg.getOptionalForeignEnum(),
  163. proto.jspb.test.Proto3Enum.PROTO3_FOO);
  164. assertEquals(msg.getOptionalForeignMessage(), undefined);
  165. assertEquals(msg.getOptionalForeignMessage(), undefined);
  166. // Serializing an empty proto yields the empty string.
  167. assertEquals(msg.serializeBinary().length, 0);
  168. // Values start as unset, but can be explicitly set even to default values
  169. // like 0.
  170. assertFalse(msg.hasOptionalInt32());
  171. msg.setOptionalInt32(0);
  172. assertTrue(msg.hasOptionalInt32());
  173. assertFalse(msg.hasOptionalInt64());
  174. msg.setOptionalInt64(0);
  175. assertTrue(msg.hasOptionalInt64());
  176. assertFalse(msg.hasOptionalString());
  177. msg.setOptionalString("");
  178. assertTrue(msg.hasOptionalString());
  179. // Now the proto will have a non-zero size, even though its values are 0.
  180. var serialized = msg.serializeBinary();
  181. assertNotEquals(serialized.length, 0);
  182. var msg2 = proto.jspb.test.TestProto3.deserializeBinary(serialized);
  183. assertTrue(msg2.hasOptionalInt32());
  184. assertTrue(msg2.hasOptionalInt64());
  185. assertTrue(msg2.hasOptionalString());
  186. // We can clear fields to go back to empty.
  187. msg2.clearOptionalInt32();
  188. assertFalse(msg2.hasOptionalInt32());
  189. msg2.clearOptionalString();
  190. assertFalse(msg2.hasOptionalString());
  191. });
  192. /**
  193. * Test that all fields can be set ,and read via a serialization roundtrip.
  194. */
  195. it('testProto3FieldSetGet', function () {
  196. var msg = new proto.jspb.test.TestProto3();
  197. msg.setSingularInt32(-42);
  198. msg.setSingularInt64(-0x7fffffff00000000);
  199. msg.setSingularUint32(0x80000000);
  200. msg.setSingularUint64(0xf000000000000000);
  201. msg.setSingularSint32(-100);
  202. msg.setSingularSint64(-0x8000000000000000);
  203. msg.setSingularFixed32(1234);
  204. msg.setSingularFixed64(0x1234567800000000);
  205. msg.setSingularSfixed32(-1234);
  206. msg.setSingularSfixed64(-0x1234567800000000);
  207. msg.setSingularFloat(1.5);
  208. msg.setSingularDouble(-1.5);
  209. msg.setSingularBool(true);
  210. msg.setSingularString('hello world');
  211. msg.setSingularBytes(BYTES);
  212. var submsg = new proto.jspb.test.ForeignMessage();
  213. submsg.setC(16);
  214. msg.setSingularForeignMessage(submsg);
  215. msg.setSingularForeignEnum(proto.jspb.test.Proto3Enum.PROTO3_BAR);
  216. msg.setRepeatedInt32List([-42]);
  217. msg.setRepeatedInt64List([-0x7fffffff00000000]);
  218. msg.setRepeatedUint32List([0x80000000]);
  219. msg.setRepeatedUint64List([0xf000000000000000]);
  220. msg.setRepeatedSint32List([-100]);
  221. msg.setRepeatedSint64List([-0x8000000000000000]);
  222. msg.setRepeatedFixed32List([1234]);
  223. msg.setRepeatedFixed64List([0x1234567800000000]);
  224. msg.setRepeatedSfixed32List([-1234]);
  225. msg.setRepeatedSfixed64List([-0x1234567800000000]);
  226. msg.setRepeatedFloatList([1.5]);
  227. msg.setRepeatedDoubleList([-1.5]);
  228. msg.setRepeatedBoolList([true]);
  229. msg.setRepeatedStringList(['hello world']);
  230. msg.setRepeatedBytesList([BYTES]);
  231. submsg = new proto.jspb.test.ForeignMessage();
  232. submsg.setC(1000);
  233. msg.setRepeatedForeignMessageList([submsg]);
  234. msg.setRepeatedForeignEnumList([proto.jspb.test.Proto3Enum.PROTO3_BAR]);
  235. msg.setOneofString('asdf');
  236. var serialized = msg.serializeBinary();
  237. msg = proto.jspb.test.TestProto3.deserializeBinary(serialized);
  238. assertEquals(msg.getSingularInt32(), -42);
  239. assertEquals(msg.getSingularInt64(), -0x7fffffff00000000);
  240. assertEquals(msg.getSingularUint32(), 0x80000000);
  241. assertEquals(msg.getSingularUint64(), 0xf000000000000000);
  242. assertEquals(msg.getSingularSint32(), -100);
  243. assertEquals(msg.getSingularSint64(), -0x8000000000000000);
  244. assertEquals(msg.getSingularFixed32(), 1234);
  245. assertEquals(msg.getSingularFixed64(), 0x1234567800000000);
  246. assertEquals(msg.getSingularSfixed32(), -1234);
  247. assertEquals(msg.getSingularSfixed64(), -0x1234567800000000);
  248. assertEquals(msg.getSingularFloat(), 1.5);
  249. assertEquals(msg.getSingularDouble(), -1.5);
  250. assertEquals(msg.getSingularBool(), true);
  251. assertEquals(msg.getSingularString(), 'hello world');
  252. assertEquals(true, bytesCompare(msg.getSingularBytes(), BYTES));
  253. assertEquals(msg.getSingularForeignMessage().getC(), 16);
  254. assertEquals(msg.getSingularForeignEnum(),
  255. proto.jspb.test.Proto3Enum.PROTO3_BAR);
  256. assertElementsEquals(msg.getRepeatedInt32List(), [-42]);
  257. assertElementsEquals(msg.getRepeatedInt64List(), [-0x7fffffff00000000]);
  258. assertElementsEquals(msg.getRepeatedUint32List(), [0x80000000]);
  259. assertElementsEquals(msg.getRepeatedUint64List(), [0xf000000000000000]);
  260. assertElementsEquals(msg.getRepeatedSint32List(), [-100]);
  261. assertElementsEquals(msg.getRepeatedSint64List(), [-0x8000000000000000]);
  262. assertElementsEquals(msg.getRepeatedFixed32List(), [1234]);
  263. assertElementsEquals(msg.getRepeatedFixed64List(), [0x1234567800000000]);
  264. assertElementsEquals(msg.getRepeatedSfixed32List(), [-1234]);
  265. assertElementsEquals(msg.getRepeatedSfixed64List(), [-0x1234567800000000]);
  266. assertElementsEquals(msg.getRepeatedFloatList(), [1.5]);
  267. assertElementsEquals(msg.getRepeatedDoubleList(), [-1.5]);
  268. assertElementsEquals(msg.getRepeatedBoolList(), [true]);
  269. assertElementsEquals(msg.getRepeatedStringList(), ['hello world']);
  270. assertEquals(msg.getRepeatedBytesList().length, 1);
  271. assertEquals(true, bytesCompare(msg.getRepeatedBytesList()[0], BYTES));
  272. assertEquals(msg.getRepeatedForeignMessageList().length, 1);
  273. assertEquals(msg.getRepeatedForeignMessageList()[0].getC(), 1000);
  274. assertElementsEquals(msg.getRepeatedForeignEnumList(),
  275. [proto.jspb.test.Proto3Enum.PROTO3_BAR]);
  276. assertEquals(msg.getOneofString(), 'asdf');
  277. });
  278. /**
  279. * Test that oneofs continue to have a notion of field presence.
  280. */
  281. it('testOneofs', function() {
  282. // Default instance.
  283. var msg = new proto.jspb.test.TestProto3();
  284. assertEquals(msg.getOneofUint32(), 0);
  285. assertEquals(msg.getOneofForeignMessage(), undefined);
  286. assertEquals(msg.getOneofString(), '');
  287. assertEquals(msg.getOneofBytes(), '');
  288. assertFalse(msg.hasOneofUint32());
  289. assertFalse(msg.hasOneofForeignMessage());
  290. assertFalse(msg.hasOneofString());
  291. assertFalse(msg.hasOneofBytes());
  292. // Integer field.
  293. msg.setOneofUint32(42);
  294. assertEquals(msg.getOneofUint32(), 42);
  295. assertEquals(msg.getOneofForeignMessage(), undefined);
  296. assertEquals(msg.getOneofString(), '');
  297. assertEquals(msg.getOneofBytes(), '');
  298. assertTrue(msg.hasOneofUint32());
  299. assertFalse(msg.hasOneofForeignMessage());
  300. assertFalse(msg.hasOneofString());
  301. assertFalse(msg.hasOneofBytes());
  302. // Sub-message field.
  303. var submsg = new proto.jspb.test.ForeignMessage();
  304. msg.setOneofForeignMessage(submsg);
  305. assertEquals(msg.getOneofUint32(), 0);
  306. assertEquals(msg.getOneofForeignMessage(), submsg);
  307. assertEquals(msg.getOneofString(), '');
  308. assertEquals(msg.getOneofBytes(), '');
  309. assertFalse(msg.hasOneofUint32());
  310. assertTrue(msg.hasOneofForeignMessage());
  311. assertFalse(msg.hasOneofString());
  312. assertFalse(msg.hasOneofBytes());
  313. // String field.
  314. msg.setOneofString('hello');
  315. assertEquals(msg.getOneofUint32(), 0);
  316. assertEquals(msg.getOneofForeignMessage(), undefined);
  317. assertEquals(msg.getOneofString(), 'hello');
  318. assertEquals(msg.getOneofBytes(), '');
  319. assertFalse(msg.hasOneofUint32());
  320. assertFalse(msg.hasOneofForeignMessage());
  321. assertTrue(msg.hasOneofString());
  322. assertFalse(msg.hasOneofBytes());
  323. // Bytes field.
  324. msg.setOneofBytes(goog.crypt.base64.encodeString('\u00FF\u00FF'));
  325. assertEquals(msg.getOneofUint32(), 0);
  326. assertEquals(msg.getOneofForeignMessage(), undefined);
  327. assertEquals(msg.getOneofString(), '');
  328. assertEquals(msg.getOneofBytes_asB64(),
  329. goog.crypt.base64.encodeString('\u00FF\u00FF'));
  330. assertFalse(msg.hasOneofUint32());
  331. assertFalse(msg.hasOneofForeignMessage());
  332. assertFalse(msg.hasOneofString());
  333. assertTrue(msg.hasOneofBytes());
  334. });
  335. /**
  336. * Test that "default"-valued primitive fields are not emitted on the wire.
  337. */
  338. it('testNoSerializeDefaults', function() {
  339. var msg = new proto.jspb.test.TestProto3();
  340. // Set each primitive to a non-default value, then back to its default, to
  341. // ensure that the serialization is actually checking the value and not just
  342. // whether it has ever been set.
  343. msg.setSingularInt32(42);
  344. msg.setSingularInt32(0);
  345. msg.setSingularDouble(3.14);
  346. msg.setSingularDouble(0.0);
  347. msg.setSingularBool(true);
  348. msg.setSingularBool(false);
  349. msg.setSingularString('hello world');
  350. msg.setSingularString('');
  351. msg.setSingularBytes(goog.crypt.base64.encodeString('\u00FF\u00FF'));
  352. msg.setSingularBytes('');
  353. msg.setSingularForeignMessage(new proto.jspb.test.ForeignMessage());
  354. msg.setSingularForeignMessage(null);
  355. msg.setSingularForeignEnum(proto.jspb.test.Proto3Enum.PROTO3_BAR);
  356. msg.setSingularForeignEnum(proto.jspb.test.Proto3Enum.PROTO3_FOO);
  357. msg.setOneofUint32(32);
  358. msg.clearOneofUint32();
  359. var serialized = msg.serializeBinary();
  360. assertEquals(0, serialized.length);
  361. });
  362. /**
  363. * Test that base64 string and Uint8Array are interchangeable in bytes fields.
  364. */
  365. it('testBytesFieldsInterop', function() {
  366. var msg = new proto.jspb.test.TestProto3();
  367. // Set as a base64 string and check all the getters work.
  368. msg.setSingularBytes(BYTES_B64);
  369. assertTrue(bytesCompare(msg.getSingularBytes_asU8(), BYTES));
  370. assertTrue(bytesCompare(msg.getSingularBytes_asB64(), BYTES));
  371. assertTrue(bytesCompare(msg.getSingularBytes(), BYTES));
  372. // Test binary serialize round trip doesn't break it.
  373. msg = proto.jspb.test.TestProto3.deserializeBinary(msg.serializeBinary());
  374. assertTrue(bytesCompare(msg.getSingularBytes_asU8(), BYTES));
  375. assertTrue(bytesCompare(msg.getSingularBytes_asB64(), BYTES));
  376. assertTrue(bytesCompare(msg.getSingularBytes(), BYTES));
  377. msg = new proto.jspb.test.TestProto3();
  378. // Set as a Uint8Array and check all the getters work.
  379. msg.setSingularBytes(BYTES);
  380. assertTrue(bytesCompare(msg.getSingularBytes_asU8(), BYTES));
  381. assertTrue(bytesCompare(msg.getSingularBytes_asB64(), BYTES));
  382. assertTrue(bytesCompare(msg.getSingularBytes(), BYTES));
  383. });
  384. it('testTimestampWellKnownType', function() {
  385. var msg = new proto.google.protobuf.Timestamp();
  386. msg.fromDate(new Date(123456789));
  387. assertEquals(123456, msg.getSeconds());
  388. assertEquals(789000000, msg.getNanos());
  389. var date = msg.toDate();
  390. assertEquals(123456789, date.getTime());
  391. var anotherMsg = proto.google.protobuf.Timestamp.fromDate(date);
  392. assertEquals(msg.getSeconds(), anotherMsg.getSeconds());
  393. assertEquals(msg.getNanos(), anotherMsg.getNanos());
  394. });
  395. it('testStructWellKnownType', function() {
  396. var jsObj = {
  397. abc: "def",
  398. number: 12345.678,
  399. nullKey: null,
  400. boolKey: true,
  401. listKey: [1, null, true, false, "abc"],
  402. structKey: {foo: "bar", somenum: 123},
  403. complicatedKey: [{xyz: {abc: [3, 4, null, false]}}, "zzz"]
  404. };
  405. var struct = proto.google.protobuf.Struct.fromJavaScript(jsObj);
  406. var jsObj2 = struct.toJavaScript();
  407. assertEquals("def", jsObj2.abc);
  408. assertEquals(12345.678, jsObj2.number);
  409. assertEquals(null, jsObj2.nullKey);
  410. assertEquals(true, jsObj2.boolKey);
  411. assertEquals("abc", jsObj2.listKey[4]);
  412. assertEquals("bar", jsObj2.structKey.foo);
  413. assertEquals(4, jsObj2.complicatedKey[0].xyz.abc[1]);
  414. });
  415. });