OLD | NEW |
---|---|
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 Loading... | |
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 Loading... | |
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 } |
OLD | NEW |