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

Side by Side Diff: utils/tests/pub/yaml_test.dart

Issue 10886055: Add a friendly error message for using a tab as indentation. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 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
« utils/pub/yaml/parser.dart ('K') | « utils/pub/yaml/parser.dart ('k') | 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) 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('yaml_test'); 5 #library('yaml_test');
6 6
7 #import('dart:math'); 7 #import('dart:math');
8 8
9 #import('../../../pkg/unittest/unittest.dart'); 9 #import('../../../pkg/unittest/unittest.dart');
10 #import('../../pub/yaml/yaml.dart'); 10 #import('../../pub/yaml/yaml.dart');
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
63 Expect.equals('baz', normalMap[yamlMap({'foo': 'bar'})]); 63 Expect.equals('baz', normalMap[yamlMap({'foo': 'bar'})]);
64 }); 64 });
65 65
66 test('treats YamlMap keys the same as normal maps', () { 66 test('treats YamlMap keys the same as normal maps', () {
67 var map = yamlMap(); 67 var map = yamlMap();
68 map[{'a': 'b'}] = 5; 68 map[{'a': 'b'}] = 5;
69 Expect.equals(5, map[yamlMap({'a': 'b'})]); 69 Expect.equals(5, map[yamlMap({'a': 'b'})]);
70 }); 70 });
71 }); 71 });
72 72
73 group('has a friendly error message for', () {
74 test('using a tab as indentation', () {
75 Expect.throws(() => loadYaml('foo:\n\tbar'),
Bob Nystrom 2012/08/30 16:43:51 expect(() => loadYaml('foo:\n\tbar'), throwsA(
nweiz 2012/08/30 19:19:02 Done, although just "contains()" doesn't work here
76 (e) => e.toString().contains('\\t is not allowed as indentation'));
77 });
78
79 test('using a tab not as indentation', () {
80 Expect.throws(() => loadYaml('''
81 "foo
82 \tbar"
83 error'''),
84 (e) => !e.toString().contains('\\t is not allowed as indentation'));
Bob Nystrom 2012/08/30 16:43:51 Ditto. We're trying to phase out all uses of Expe
nweiz 2012/08/30 19:19:02 Done.
85 });
86 });
87
73 // The following tests are all taken directly from the YAML spec 88 // The following tests are all taken directly from the YAML spec
74 // (http://www.yaml.org/spec/1.2/spec.html). Most of them are code examples 89 // (http://www.yaml.org/spec/1.2/spec.html). Most of them are code examples
75 // that are directly included in the spec, but additional tests are derived 90 // that are directly included in the spec, but additional tests are derived
76 // from the prose. 91 // from the prose.
77 92
78 // A few examples from the spec are deliberately excluded, because they test 93 // A few examples from the spec are deliberately excluded, because they test
79 // features that this implementation doesn't intend to support (character 94 // features that this implementation doesn't intend to support (character
80 // encoding detection and user-defined tags). More tests are commented out, 95 // encoding detection and user-defined tags). More tests are commented out,
81 // because they're intended to be supported but not yet implemented. 96 // because they're intended to be supported but not yet implemented.
82 97
(...skipping 1773 matching lines...) Expand 10 before | Expand all | Expand 10 after
1856 A null: null 1871 A null: null
1857 Also a null: # Empty 1872 Also a null: # Empty
1858 Not a null: "" 1873 Not a null: ""
1859 Booleans: [ true, True, false, FALSE ] 1874 Booleans: [ true, True, false, FALSE ]
1860 Integers: [ 0, 0o7, 0x3A, -19 ] 1875 Integers: [ 0, 0o7, 0x3A, -19 ]
1861 Floats: [ 0., -0.0, .5, +12e03, -2E+05 ] 1876 Floats: [ 0., -0.0, .5, +12e03, -2E+05 ]
1862 Also floats: [ .inf, -.Inf, +.INF, .NAN ]'''); 1877 Also floats: [ .inf, -.Inf, +.INF, .NAN ]''');
1863 }); 1878 });
1864 }); 1879 });
1865 } 1880 }
OLDNEW
« utils/pub/yaml/parser.dart ('K') | « utils/pub/yaml/parser.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698