File tree Expand file tree Collapse file tree 2 files changed +40
-0
lines changed Expand file tree Collapse file tree 2 files changed +40
-0
lines changed Original file line number Diff line number Diff line change 1+ require " yaml"
2+ require " spec"
3+
4+ describe YAML ::Nodes do
5+ describe " .parse" do
6+ it " attaches location to scalar nodes" do
7+ doc = YAML ::Nodes .parse %( 1)
8+ node = doc.nodes[0 ]
9+ node.location.should eq({1 , 1 })
10+ node.end_line.should eq(1 )
11+ node.end_column.should eq(2 )
12+ end
13+
14+ it " attaches location to sequence nodes" do
15+ doc = YAML ::Nodes .parse %( [1])
16+ node = doc.nodes[0 ]
17+ node.location.should eq({1 , 1 })
18+ node.end_line.should eq(1 )
19+ node.end_column.should eq(4 )
20+ end
21+
22+ it " attaches location to mapping nodes" do
23+ doc = YAML ::Nodes .parse %( {"a":1})
24+ node = doc.nodes[0 ]
25+ node.location.should eq({1 , 1 })
26+ node.end_line.should eq(1 )
27+ node.end_column.should eq(8 )
28+ end
29+
30+ it " attaches location to alias nodes" do
31+ doc = YAML ::Nodes .parse %( [&a 1, *a])
32+ node = doc.nodes[0 ].as(YAML ::Nodes ::Sequence ).nodes[1 ]
33+ node.location.should eq({1 , 8 })
34+ node.end_line.should eq(1 )
35+ node.end_column.should eq(10 )
36+ end
37+ end
38+ end
Original file line number Diff line number Diff line change @@ -102,12 +102,14 @@ abstract class YAML::Parser
102102
103103 protected def parse_scalar
104104 value = anchor(@pull_parser .anchor, new_scalar)
105+ end_value(value)
105106 @pull_parser .read_next
106107 value
107108 end
108109
109110 protected def parse_alias
110111 value = get_anchor(@pull_parser .anchor.not_nil!)
112+ end_value(value)
111113 @pull_parser .read_next
112114 value
113115 end
You can’t perform that action at this time.
0 commit comments