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'); |
| 8 |
7 #import('../../../pkg/unittest/unittest.dart'); | 9 #import('../../../pkg/unittest/unittest.dart'); |
8 #import('../../pub/yaml/yaml.dart'); | 10 #import('../../pub/yaml/yaml.dart'); |
9 #import('../../pub/yaml/deep_equals.dart'); | 11 #import('../../pub/yaml/deep_equals.dart'); |
10 #import('../../../tests/utils/test_utils.dart'); | 12 #import('../../../tests/utils/test_utils.dart'); |
11 | 13 |
12 /** Constructs a new yaml.YamlMap, optionally from a normal Map. */ | 14 /** Constructs a new yaml.YamlMap, optionally from a normal Map. */ |
13 Map yamlMap([Map from]) => | 15 Map yamlMap([Map from]) => |
14 from == null ? new YamlMap() : new YamlMap.from(from); | 16 from == null ? new YamlMap() : new YamlMap.from(from); |
15 | 17 |
16 /** | 18 /** |
(...skipping 10 matching lines...) Expand all Loading... |
27 * 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 |
28 * list of values when loaded. | 30 * list of values when loaded. |
29 */ | 31 */ |
30 expectYamlStreamLoads(List expected, String source) { | 32 expectYamlStreamLoads(List expected, String source) { |
31 var actual = loadYamlStream(cleanUpLiteral(source)); | 33 var actual = loadYamlStream(cleanUpLiteral(source)); |
32 Expect.isTrue(deepEquals(expected, actual), | 34 Expect.isTrue(deepEquals(expected, actual), |
33 'expectYamlStreamLoads(expected: <$expected>, actual: <$actual>)'); | 35 'expectYamlStreamLoads(expected: <$expected>, actual: <$actual>)'); |
34 } | 36 } |
35 | 37 |
36 main() { | 38 main() { |
37 var infinity = Math.parseDouble("Infinity"); | 39 var infinity = parseDouble("Infinity"); |
38 var nan = Math.parseDouble("NaN"); | 40 var nan = parseDouble("NaN"); |
39 | 41 |
40 group('YamlMap', () { | 42 group('YamlMap', () { |
41 group('accepts as a key', () { | 43 group('accepts as a key', () { |
42 _expectKeyWorks(keyFn()) { | 44 _expectKeyWorks(keyFn()) { |
43 var map = yamlMap(); | 45 var map = yamlMap(); |
44 map[keyFn()] = 5; | 46 map[keyFn()] = 5; |
45 Expect.isTrue(map.containsKey(keyFn())); | 47 Expect.isTrue(map.containsKey(keyFn())); |
46 Expect.equals(5, map[keyFn()]); | 48 Expect.equals(5, map[keyFn()]); |
47 } | 49 } |
48 | 50 |
(...skipping 1805 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1854 A null: null | 1856 A null: null |
1855 Also a null: # Empty | 1857 Also a null: # Empty |
1856 Not a null: "" | 1858 Not a null: "" |
1857 Booleans: [ true, True, false, FALSE ] | 1859 Booleans: [ true, True, false, FALSE ] |
1858 Integers: [ 0, 0o7, 0x3A, -19 ] | 1860 Integers: [ 0, 0o7, 0x3A, -19 ] |
1859 Floats: [ 0., -0.0, .5, +12e03, -2E+05 ] | 1861 Floats: [ 0., -0.0, .5, +12e03, -2E+05 ] |
1860 Also floats: [ .inf, -.Inf, +.INF, .NAN ]'''); | 1862 Also floats: [ .inf, -.Inf, +.INF, .NAN ]'''); |
1861 }); | 1863 }); |
1862 }); | 1864 }); |
1863 } | 1865 } |
OLD | NEW |