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

Side by Side Diff: tests/lib/convert/json_pretty_test.dart

Issue 1128183004: Stop using pkg/matcher in JSON pretty test (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 5 years, 7 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2014, 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 json_pretty_test; 5 library json_pretty_test;
6 6
7 import 'dart:convert'; 7 import 'dart:convert';
8 8
9 import 'package:matcher/matcher.dart'; 9 import "package:expect/expect.dart";
10 10
11 void _testIndentWithNullChar() { 11 void _testIndentWithNullChar() {
12 var encoder = const JsonEncoder.withIndent('\x00'); 12 var encoder = const JsonEncoder.withIndent('\x00');
13 var encoded = encoder.convert([[],[[]]]); 13 var encoded = encoder.convert([[],[[]]]);
14 expect(encoded, "[\n\x00[],\n\x00[\n\x00\x00[]\n\x00]\n]"); 14 Expect.equals("[\n\x00[],\n\x00[\n\x00\x00[]\n\x00]\n]", encoded);
15 } 15 }
16 16
17 void main() { 17 void main() {
18 _testIndentWithNullChar(); 18 _testIndentWithNullChar();
19 19
20 _expect(null, 'null'); 20 _expect(null, 'null');
21 21
22 _expect([[],[[]]], ''' 22 _expect([[],[[]]], '''
23 [ 23 [
24 [], 24 [],
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
84 "bar.dart" 84 "bar.dart"
85 ] 85 ]
86 } 86 }
87 ]'''); 87 ]''');
88 } 88 }
89 89
90 void _expect(Object object, String expected) { 90 void _expect(Object object, String expected) {
91 var encoder = const JsonEncoder.withIndent(' '); 91 var encoder = const JsonEncoder.withIndent(' ');
92 var prettyOutput = encoder.convert(object); 92 var prettyOutput = encoder.convert(object);
93 93
94 expect(prettyOutput, expected); 94 Expect.equals(expected, prettyOutput);
95 95
96 encoder = const JsonEncoder.withIndent(''); 96 encoder = const JsonEncoder.withIndent('');
97 97
98 var flatOutput = encoder.convert(object); 98 var flatOutput = encoder.convert(object);
99 99
100 var flatExpected = const LineSplitter().convert(expected) 100 var flatExpected = const LineSplitter().convert(expected)
101 .map((line) => line.trimLeft()) 101 .map((line) => line.trimLeft())
102 .join('\n'); 102 .join('\n');
103 103
104 expect(flatOutput, flatExpected); 104 Expect.equals(flatExpected, flatOutput);
105 105
106 var compactOutput = JSON.encode(object); 106 var compactOutput = JSON.encode(object);
107 107
108 encoder = const JsonEncoder.withIndent(null); 108 encoder = const JsonEncoder.withIndent(null);
109 expect(encoder.convert(object), compactOutput); 109 Expect.equals(compactOutput, encoder.convert(object));
110 110
111 var prettyDecoded = JSON.decode(prettyOutput); 111 var prettyDecoded = JSON.decode(prettyOutput);
112 112
113 expect(JSON.encode(prettyDecoded), compactOutput); 113 Expect.equals(compactOutput, JSON.encode(prettyDecoded));
114 } 114 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698