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

Unified Diff: test/yaml_test.dart

Issue 1329183002: Fix source spans for scalars. (Closed) Base URL: git@github.com:dart-lang/yaml@master
Patch Set: Created 5 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « pubspec.yaml ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/yaml_test.dart
diff --git a/test/yaml_test.dart b/test/yaml_test.dart
index 8091dc5b2063c71024ef100f8366dc8ffcd0503f..c4601d50d23d6693d974880ccb99511532145815 100644
--- a/test/yaml_test.dart
+++ b/test/yaml_test.dart
@@ -54,6 +54,43 @@ main() {
});
});
+ test("includes source span information", () {
+ var yaml = loadYamlNode(r"""
+- foo:
+ bar
+- 123
+""");
+
+ expect(yaml.span.start.line, equals(0));
+ expect(yaml.span.start.column, equals(0));
+ expect(yaml.span.end.line, equals(3));
+ expect(yaml.span.end.column, equals(0));
+
+ var map = yaml.nodes.first;
+ expect(map.span.start.line, equals(0));
+ expect(map.span.start.column, equals(2));
+ expect(map.span.end.line, equals(2));
+ expect(map.span.end.column, equals(0));
+
+ var key = map.nodes.keys.first;
+ expect(key.span.start.line, equals(0));
+ expect(key.span.start.column, equals(2));
+ expect(key.span.end.line, equals(0));
+ expect(key.span.end.column, equals(5));
+
+ var value = map.nodes.values.first;
+ expect(value.span.start.line, equals(1));
+ expect(value.span.start.column, equals(4));
+ expect(value.span.end.line, equals(1));
+ expect(value.span.end.column, equals(7));
+
+ var scalar = yaml.nodes.last;
+ expect(scalar.span.start.line, equals(2));
+ expect(scalar.span.start.column, equals(2));
+ expect(scalar.span.end.line, equals(2));
+ expect(scalar.span.end.column, equals(5));
+ });
+
// The following tests are all taken directly from the YAML spec
// (http://www.yaml.org/spec/1.2/spec.html). Most of them are code examples
// that are directly included in the spec, but additional tests are derived
« no previous file with comments | « pubspec.yaml ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698