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

Side by Side 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 unified diff | Download patch
« no previous file with comments | « pubspec.yaml ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 'package:test/test.dart'; 7 import 'package:test/test.dart';
8 import 'package:yaml/yaml.dart'; 8 import 'package:yaml/yaml.dart';
9 9
10 import 'utils.dart'; 10 import 'utils.dart';
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
47 }); 47 });
48 48
49 test("2.0", () { 49 test("2.0", () {
50 expectYamlFails(""" 50 expectYamlFails("""
51 %YAML 2.0 51 %YAML 2.0
52 --- text 52 --- text
53 """); 53 """);
54 }); 54 });
55 }); 55 });
56 56
57 test("includes source span information", () {
58 var yaml = loadYamlNode(r"""
59 - foo:
60 bar
61 - 123
62 """);
63
64 expect(yaml.span.start.line, equals(0));
65 expect(yaml.span.start.column, equals(0));
66 expect(yaml.span.end.line, equals(3));
67 expect(yaml.span.end.column, equals(0));
68
69 var map = yaml.nodes.first;
70 expect(map.span.start.line, equals(0));
71 expect(map.span.start.column, equals(2));
72 expect(map.span.end.line, equals(2));
73 expect(map.span.end.column, equals(0));
74
75 var key = map.nodes.keys.first;
76 expect(key.span.start.line, equals(0));
77 expect(key.span.start.column, equals(2));
78 expect(key.span.end.line, equals(0));
79 expect(key.span.end.column, equals(5));
80
81 var value = map.nodes.values.first;
82 expect(value.span.start.line, equals(1));
83 expect(value.span.start.column, equals(4));
84 expect(value.span.end.line, equals(1));
85 expect(value.span.end.column, equals(7));
86
87 var scalar = yaml.nodes.last;
88 expect(scalar.span.start.line, equals(2));
89 expect(scalar.span.start.column, equals(2));
90 expect(scalar.span.end.line, equals(2));
91 expect(scalar.span.end.column, equals(5));
92 });
93
57 // The following tests are all taken directly from the YAML spec 94 // The following tests are all taken directly from the YAML spec
58 // (http://www.yaml.org/spec/1.2/spec.html). Most of them are code examples 95 // (http://www.yaml.org/spec/1.2/spec.html). Most of them are code examples
59 // that are directly included in the spec, but additional tests are derived 96 // that are directly included in the spec, but additional tests are derived
60 // from the prose. 97 // from the prose.
61 98
62 // A few examples from the spec are deliberately excluded, because they test 99 // A few examples from the spec are deliberately excluded, because they test
63 // features that this implementation doesn't intend to support (character 100 // features that this implementation doesn't intend to support (character
64 // encoding detection and user-defined tags). More tests are commented out, 101 // encoding detection and user-defined tags). More tests are commented out,
65 // because they're intended to be supported but not yet implemented. 102 // because they're intended to be supported but not yet implemented.
66 103
(...skipping 1772 matching lines...) Expand 10 before | Expand all | Expand 10 after
1839 A null: null 1876 A null: null
1840 Also a null: # Empty 1877 Also a null: # Empty
1841 Not a null: "" 1878 Not a null: ""
1842 Booleans: [ true, True, false, FALSE ] 1879 Booleans: [ true, True, false, FALSE ]
1843 Integers: [ 0, 0o7, 0x3A, -19 ] 1880 Integers: [ 0, 0o7, 0x3A, -19 ]
1844 Floats: [ 0., -0.0, .5, +12e03, -2E+05 ] 1881 Floats: [ 0., -0.0, .5, +12e03, -2E+05 ]
1845 Also floats: [ .inf, -.Inf, +.INF, .NAN ]'''); 1882 Also floats: [ .inf, -.Inf, +.INF, .NAN ]''');
1846 }); 1883 });
1847 }); 1884 });
1848 } 1885 }
OLDNEW
« 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