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

Side by Side Diff: packages/yaml/test/yaml_node_wrapper_test.dart

Issue 1400473008: Roll Observatory packages and add a roll script (Closed) Base URL: git@github.com:dart-lang/observatory_pub_packages.git@master
Patch Set: Created 5 years, 2 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
« no previous file with comments | « packages/yaml/test/utils.dart ('k') | packages/yaml/test/yaml_test.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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 yaml.node_wrapper_test;
6
7 import 'package:source_span/source_span.dart';
8 import 'package:test/test.dart';
9 import 'package:yaml/yaml.dart';
10
11 main() {
12 test("YamlMap() with no sourceUrl", () {
13 var map = new YamlMap();
14 expect(map, isEmpty);
15 expect(map.nodes, isEmpty);
16 expect(map.span, isNullSpan(isNull));
17 });
18
19 test("YamlMap() with a sourceUrl", () {
20 var map = new YamlMap(sourceUrl: "source");
21 expect(map.span, isNullSpan(Uri.parse("source")));
22 });
23
24 test("YamlList() with no sourceUrl", () {
25 var list = new YamlList();
26 expect(list, isEmpty);
27 expect(list.nodes, isEmpty);
28 expect(list.span, isNullSpan(isNull));
29 });
30
31 test("YamlList() with a sourceUrl", () {
32 var list = new YamlList(sourceUrl: "source");
33 expect(list.span, isNullSpan(Uri.parse("source")));
34 });
35
36 test("YamlMap.wrap() with no sourceUrl", () {
37 var map = new YamlMap.wrap({
38 "list": [1, 2, 3],
39 "map": {
40 "foo": "bar",
41 "nested": [4, 5, 6]
42 },
43 "scalar": "value"
44 });
45
46 expect(map, equals({
47 "list": [1, 2, 3],
48 "map": {
49 "foo": "bar",
50 "nested": [4, 5, 6]
51 },
52 "scalar": "value"
53 }));
54
55 expect(map.span, isNullSpan(isNull));
56 expect(map["list"], new isInstanceOf<YamlList>());
57 expect(map["list"].nodes[0], new isInstanceOf<YamlScalar>());
58 expect(map["list"].span, isNullSpan(isNull));
59 expect(map["map"], new isInstanceOf<YamlMap>());
60 expect(map["map"].nodes["foo"], new isInstanceOf<YamlScalar>());
61 expect(map["map"]["nested"], new isInstanceOf<YamlList>());
62 expect(map["map"].span, isNullSpan(isNull));
63 expect(map.nodes["scalar"], new isInstanceOf<YamlScalar>());
64 expect(map.nodes["scalar"].value, "value");
65 expect(map.nodes["scalar"].span, isNullSpan(isNull));
66 expect(map["scalar"], "value");
67 expect(map.keys, unorderedEquals(["list", "map", "scalar"]));
68 expect(map.nodes.keys, everyElement(new isInstanceOf<YamlScalar>()));
69 expect(map.nodes[new YamlScalar.wrap("list")], equals([1, 2, 3]));
70 });
71
72 test("YamlMap.wrap() with a sourceUrl", () {
73 var map = new YamlMap.wrap({
74 "list": [1, 2, 3],
75 "map": {
76 "foo": "bar",
77 "nested": [4, 5, 6]
78 },
79 "scalar": "value"
80 }, sourceUrl: "source");
81
82 var source = Uri.parse("source");
83 expect(map.span, isNullSpan(source));
84 expect(map["list"].span, isNullSpan(source));
85 expect(map["map"].span, isNullSpan(source));
86 expect(map.nodes["scalar"].span, isNullSpan(source));
87 });
88
89 test("YamlList.wrap() with no sourceUrl", () {
90 var list = new YamlList.wrap([
91 [1, 2, 3],
92 {
93 "foo": "bar",
94 "nested": [4, 5, 6]
95 },
96 "value"
97 ]);
98
99 expect(list, equals([
100 [1, 2, 3],
101 {
102 "foo": "bar",
103 "nested": [4, 5, 6]
104 },
105 "value"
106 ]));
107
108 expect(list.span, isNullSpan(isNull));
109 expect(list[0], new isInstanceOf<YamlList>());
110 expect(list[0].nodes[0], new isInstanceOf<YamlScalar>());
111 expect(list[0].span, isNullSpan(isNull));
112 expect(list[1], new isInstanceOf<YamlMap>());
113 expect(list[1].nodes["foo"], new isInstanceOf<YamlScalar>());
114 expect(list[1]["nested"], new isInstanceOf<YamlList>());
115 expect(list[1].span, isNullSpan(isNull));
116 expect(list.nodes[2], new isInstanceOf<YamlScalar>());
117 expect(list.nodes[2].value, "value");
118 expect(list.nodes[2].span, isNullSpan(isNull));
119 expect(list[2], "value");
120 });
121
122 test("YamlList.wrap() with a sourceUrl", () {
123 var list = new YamlList.wrap([
124 [1, 2, 3],
125 {
126 "foo": "bar",
127 "nested": [4, 5, 6]
128 },
129 "value"
130 ]);
131
132 expect(list.span, isNullSpan(isNull));
133 expect(list[0].span, isNullSpan(isNull));
134 expect(list[1].span, isNullSpan(isNull));
135 expect(list.nodes[2].span, isNullSpan(isNull));
136 });
137
138 test("re-wrapped objects equal one another", () {
139 var list = new YamlList.wrap([
140 [1, 2, 3],
141 {"foo": "bar"}
142 ]);
143
144 expect(list[0] == list[0], isTrue);
145 expect(list[0].nodes == list[0].nodes, isTrue);
146 expect(list[0] == new YamlList.wrap([1, 2, 3]), isFalse);
147 expect(list[1] == list[1], isTrue);
148 expect(list[1].nodes == list[1].nodes, isTrue);
149 expect(list[1] == new YamlMap.wrap({"foo": "bar"}), isFalse);
150 });
151 }
152
153 Matcher isNullSpan(sourceUrl) => predicate((span) {
154 expect(span, new isInstanceOf<SourceSpan>());
155 expect(span.length, equals(0));
156 expect(span.text, isEmpty);
157 expect(span.start, equals(span.end));
158 expect(span.start.offset, equals(0));
159 expect(span.start.line, equals(0));
160 expect(span.start.column, equals(0));
161 expect(span.sourceUrl, sourceUrl);
162 return true;
163 });
OLDNEW
« no previous file with comments | « packages/yaml/test/utils.dart ('k') | packages/yaml/test/yaml_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698