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

Side by Side Diff: sdk/lib/_internal/pub_generated/test/utils_test.dart

Issue 557563002: Store the async-await compiled pub code directly in the repo. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 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
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.
4
5 library utils_test; 1 library utils_test;
6
7 import 'package:unittest/unittest.dart'; 2 import 'package:unittest/unittest.dart';
8 import 'test_pub.dart'; 3 import 'test_pub.dart';
9 import '../lib/src/utils.dart'; 4 import '../lib/src/utils.dart';
10
11 main() { 5 main() {
12 initConfig(); 6 initConfig();
13
14 group('yamlToString()', () { 7 group('yamlToString()', () {
15 test('null', () { 8 test('null', () {
16 expect(yamlToString(null), equals('null')); 9 expect(yamlToString(null), equals('null'));
17 }); 10 });
18
19 test('numbers', () { 11 test('numbers', () {
20 expect(yamlToString(123), equals('123')); 12 expect(yamlToString(123), equals('123'));
21 expect(yamlToString(12.34), equals('12.34')); 13 expect(yamlToString(12.34), equals('12.34'));
22 }); 14 });
23
24 test('does not quote strings that do not need it', () { 15 test('does not quote strings that do not need it', () {
25 expect(yamlToString('a'), equals('a')); 16 expect(yamlToString('a'), equals('a'));
26 expect(yamlToString('some-string'), equals('some-string')); 17 expect(yamlToString('some-string'), equals('some-string'));
27 expect(yamlToString('hey123CAPS'), equals('hey123CAPS')); 18 expect(yamlToString('hey123CAPS'), equals('hey123CAPS'));
28 expect(yamlToString("_under_score"), equals('_under_score')); 19 expect(yamlToString("_under_score"), equals('_under_score'));
29 }); 20 });
30
31 test('quotes other strings', () { 21 test('quotes other strings', () {
32 expect(yamlToString(''), equals('""')); 22 expect(yamlToString(''), equals('""'));
33 expect(yamlToString('123'), equals('"123"')); 23 expect(yamlToString('123'), equals('"123"'));
34 expect(yamlToString('white space'), equals('"white space"')); 24 expect(yamlToString('white space'), equals('"white space"'));
35 expect(yamlToString('"quote"'), equals(r'"\"quote\""')); 25 expect(yamlToString('"quote"'), equals(r'"\"quote\""'));
36 expect(yamlToString("apostrophe'"), equals('"apostrophe\'"')); 26 expect(yamlToString("apostrophe'"), equals('"apostrophe\'"'));
37 expect(yamlToString("new\nline"), equals(r'"new\nline"')); 27 expect(yamlToString("new\nline"), equals(r'"new\nline"'));
38 expect(yamlToString("?unctu@t!on"), equals(r'"?unctu@t!on"')); 28 expect(yamlToString("?unctu@t!on"), equals(r'"?unctu@t!on"'));
39 }); 29 });
40
41 test('lists use JSON style', () { 30 test('lists use JSON style', () {
42 expect(yamlToString([1, 2, 3]), equals('[1,2,3]')); 31 expect(yamlToString([1, 2, 3]), equals('[1,2,3]'));
43 }); 32 });
44
45 test('uses indentation for maps', () { 33 test('uses indentation for maps', () {
46 expect(yamlToString({'a': {'b': 1, 'c': 2}, 'd': 3}), 34 expect(yamlToString({
47 equals(""" 35 'a': {
36 'b': 1,
37 'c': 2
38 },
39 'd': 3
40 }), equals("""
48 a: 41 a:
49 b: 1 42 b: 1
50 c: 2 43 c: 2
51 d: 3""")); 44 d: 3"""));
52 }); 45 });
53
54 test('sorts map keys', () { 46 test('sorts map keys', () {
55 expect(yamlToString({'a': 1, 'c': 2, 'b': 3, 'd': 4}), 47 expect(yamlToString({
56 equals(""" 48 'a': 1,
49 'c': 2,
50 'b': 3,
51 'd': 4
52 }), equals("""
57 a: 1 53 a: 1
58 b: 3 54 b: 3
59 c: 2 55 c: 2
60 d: 4""")); 56 d: 4"""));
61 }); 57 });
62
63 test('quotes map keys as needed', () { 58 test('quotes map keys as needed', () {
64 expect(yamlToString({'no': 1, 'yes!': 2, '123': 3}), 59 expect(yamlToString({
65 equals(""" 60 'no': 1,
61 'yes!': 2,
62 '123': 3
63 }), equals("""
66 "123": 3 64 "123": 3
67 no: 1 65 no: 1
68 "yes!": 2""")); 66 "yes!": 2"""));
69 }); 67 });
70
71 test('handles non-string map keys', () { 68 test('handles non-string map keys', () {
72 var map = new Map(); 69 var map = new Map();
73 map[null] = "null"; 70 map[null] = "null";
74 map[123] = "num"; 71 map[123] = "num";
75 map[true] = "bool"; 72 map[true] = "bool";
76 73 expect(yamlToString(map), equals("""
77 expect(yamlToString(map),
78 equals("""
79 123: num 74 123: num
80 null: null 75 null: null
81 true: bool""")); 76 true: bool"""));
82 }); 77 });
83
84 test('handles empty maps', () { 78 test('handles empty maps', () {
85 expect(yamlToString({}), equals("{}")); 79 expect(yamlToString({}), equals("{}"));
86 expect(yamlToString({'a': {}, 'b': {}}), equals(""" 80 expect(yamlToString({
81 'a': {},
82 'b': {}
83 }), equals("""
87 a: {} 84 a: {}
88 b: {}""")); 85 b: {}"""));
89 }); 86 });
90 }); 87 });
91 } 88 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698