Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(262)

Side by Side Diff: pkg/serialization/test/serialization_test.dart

Issue 23596007: Remove usage of dart:json. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Rebase. Created 7 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 library serialization_test; 5 library serialization_test;
6 6
7 import 'dart:json' as json; 7 import 'dart:convert';
8 import 'package:unittest/unittest.dart'; 8 import 'package:unittest/unittest.dart';
9 import 'package:serialization/serialization.dart'; 9 import 'package:serialization/serialization.dart';
10 import 'package:serialization/src/serialization_helpers.dart'; 10 import 'package:serialization/src/serialization_helpers.dart';
11 import 'package:serialization/src/mirrors_helpers.dart'; 11 import 'package:serialization/src/mirrors_helpers.dart';
12 import 'dart:isolate'; 12 import 'dart:isolate';
13 13
14 part 'test_models.dart'; 14 part 'test_models.dart';
15 15
16 void main() { 16 void main() {
17 var p1 = new Person(); 17 var p1 = new Person();
(...skipping 341 matching lines...) Expand 10 before | Expand all | Expand 10 after
359 var newAddress = s.read(out); 359 var newAddress = s.read(out);
360 expect(newAddress.street, a1.street); 360 expect(newAddress.street, a1.street);
361 expect(newAddress.city, "Kirkland"); 361 expect(newAddress.city, "Kirkland");
362 expect(newAddress.state, "WA"); 362 expect(newAddress.state, "WA");
363 expect(newAddress.zip, "98103"); 363 expect(newAddress.zip, "98103");
364 }); 364 });
365 365
366 test("Straight JSON format", () { 366 test("Straight JSON format", () {
367 var s = new Serialization(); 367 var s = new Serialization();
368 var writer = s.newWriter(const SimpleJsonFormat()); 368 var writer = s.newWriter(const SimpleJsonFormat());
369 var out = json.stringify(writer.write(a1)); 369 var out = JSON.encode(writer.write(a1));
370 var reconstituted = json.parse(out); 370 var reconstituted = JSON.decode(out);
371 expect(reconstituted.length, 4); 371 expect(reconstituted.length, 4);
372 expect(reconstituted[0], "Seattle"); 372 expect(reconstituted[0], "Seattle");
373 }); 373 });
374 374
375 test("Straight JSON format, nested objects", () { 375 test("Straight JSON format, nested objects", () {
376 var p1 = new Person()..name = 'Alice'..address = a1; 376 var p1 = new Person()..name = 'Alice'..address = a1;
377 var s = new Serialization()..selfDescribing = false; 377 var s = new Serialization()..selfDescribing = false;
378 var addressRule = s.addRuleFor(Address)..configureForMaps(); 378 var addressRule = s.addRuleFor(Address)..configureForMaps();
379 var personRule = s.addRuleFor(Person)..configureForMaps(); 379 var personRule = s.addRuleFor(Person)..configureForMaps();
380 var writer = s.newWriter(const SimpleJsonFormat(storeRoundTripInfo: true)); 380 var writer = s.newWriter(const SimpleJsonFormat(storeRoundTripInfo: true));
381 var out = json.stringify(writer.write(p1)); 381 var out = JSON.encode(writer.write(p1));
382 var reconstituted = json.parse(out); 382 var reconstituted = JSON.decode(out);
383 var expected = { 383 var expected = {
384 "name" : "Alice", 384 "name" : "Alice",
385 "rank" : null, 385 "rank" : null,
386 "serialNumber" : null, 386 "serialNumber" : null,
387 "_rule" : personRule.number, 387 "_rule" : personRule.number,
388 "address" : { 388 "address" : {
389 "street" : "N 34th", 389 "street" : "N 34th",
390 "city" : "Seattle", 390 "city" : "Seattle",
391 "state" : null, 391 "state" : null,
392 "zip" : null, 392 "zip" : null,
(...skipping 413 matching lines...) Expand 10 before | Expand all | Expand 10 after
806 806
807 /** 807 /**
808 * Function used in an isolate to make sure that the output passes through 808 * Function used in an isolate to make sure that the output passes through
809 * isolate serialization properly. 809 * isolate serialization properly.
810 */ 810 */
811 void echo() { 811 void echo() {
812 port.receive((msg, reply) { 812 port.receive((msg, reply) {
813 reply.send(msg); 813 reply.send(msg);
814 }); 814 });
815 } 815 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698