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/lib/unittest.dart'; | 9 import '../../../pkg/unittest/lib/unittest.dart'; |
10 import '../../pub/yaml/yaml.dart'; | 10 import '../../pub/yaml/yaml.dart'; |
11 import '../../pub/yaml/deep_equals.dart'; | 11 import '../../pub/yaml/deep_equals.dart'; |
12 import '../../../tests/utils/test_utils.dart'; | 12 import '../../../tests/utils/test_utils.dart'; |
13 | 13 |
14 /** Constructs a new yaml.YamlMap, optionally from a normal Map. */ | 14 /// Constructs a new yaml.YamlMap, optionally from a normal Map. |
15 Map yamlMap([Map from]) => | 15 Map yamlMap([Map from]) => |
16 from == null ? new YamlMap() : new YamlMap.from(from); | 16 from == null ? new YamlMap() : new YamlMap.from(from); |
17 | 17 |
18 /** | 18 /// Asserts that a string containing a single YAML document produces a given |
19 * Asserts that a string containing a single YAML document produces a given | 19 /// value when loaded. |
20 * value when loaded. | |
21 */ | |
22 expectYamlLoads(expected, String source) { | 20 expectYamlLoads(expected, String source) { |
23 var actual = loadYaml(cleanUpLiteral(source)); | 21 var actual = loadYaml(cleanUpLiteral(source)); |
24 Expect.isTrue(deepEquals(expected, actual), | 22 Expect.isTrue(deepEquals(expected, actual), |
25 'expectYamlLoads(expected: <$expected>, actual: <$actual>)'); | 23 'expectYamlLoads(expected: <$expected>, actual: <$actual>)'); |
26 } | 24 } |
27 | 25 |
28 /** | 26 /// Asserts that a string containing a stream of YAML documents produces a given |
29 * Asserts that a string containing a stream of YAML documents produces a given | 27 /// list of values when loaded. |
30 * list of values when loaded. | |
31 */ | |
32 expectYamlStreamLoads(List expected, String source) { | 28 expectYamlStreamLoads(List expected, String source) { |
33 var actual = loadYamlStream(cleanUpLiteral(source)); | 29 var actual = loadYamlStream(cleanUpLiteral(source)); |
34 Expect.isTrue(deepEquals(expected, actual), | 30 Expect.isTrue(deepEquals(expected, actual), |
35 'expectYamlStreamLoads(expected: <$expected>, actual: <$actual>)'); | 31 'expectYamlStreamLoads(expected: <$expected>, actual: <$actual>)'); |
36 } | 32 } |
37 | 33 |
38 main() { | 34 main() { |
39 var infinity = parseDouble("Infinity"); | 35 var infinity = parseDouble("Infinity"); |
40 var nan = parseDouble("NaN"); | 36 var nan = parseDouble("NaN"); |
41 | 37 |
(...skipping 1832 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1874 A null: null | 1870 A null: null |
1875 Also a null: # Empty | 1871 Also a null: # Empty |
1876 Not a null: "" | 1872 Not a null: "" |
1877 Booleans: [ true, True, false, FALSE ] | 1873 Booleans: [ true, True, false, FALSE ] |
1878 Integers: [ 0, 0o7, 0x3A, -19 ] | 1874 Integers: [ 0, 0o7, 0x3A, -19 ] |
1879 Floats: [ 0., -0.0, .5, +12e03, -2E+05 ] | 1875 Floats: [ 0., -0.0, .5, +12e03, -2E+05 ] |
1880 Also floats: [ .inf, -.Inf, +.INF, .NAN ]'''); | 1876 Also floats: [ .inf, -.Inf, +.INF, .NAN ]'''); |
1881 }); | 1877 }); |
1882 }); | 1878 }); |
1883 } | 1879 } |
OLD | NEW |