Skip to content

Commit

Permalink
Showing 2 changed files with 25 additions and 2 deletions.
19 changes: 19 additions & 0 deletions spec/std/yaml/yaml_spec.cr
Original file line number Diff line number Diff line change
@@ -92,6 +92,25 @@ describe "YAML" do
ex.column_number.should eq(3)
end
end

it "has correct line/number info (2)" do
begin
parser = YAML::PullParser.new <<-MSG
authors:
- [foo] bar
MSG

parser.read_stream do
parser.read_document do
parser.read_scalar
end
end
rescue ex : YAML::ParseException
ex.line_number.should eq(1)
ex.column_number.should eq(2)
end
end
end
end

8 changes: 6 additions & 2 deletions src/yaml/pull_parser.cr
Original file line number Diff line number Diff line change
@@ -223,17 +223,21 @@ class YAML::PullParser
end

def problem_line_number
problem_mark.line
problem? ? problem_mark.line : line_number
end

def problem_column_number
problem_mark.column
problem? ? problem_mark.column : column_number
end

def problem_mark
@parser.as(LibYAML::InternalParser*).value.problem_mark
end

private def problem?
@parser.as(LibYAML::InternalParser*).value.problem
end

def close
LibYAML.yaml_parser_delete(@parser)
LibYAML.yaml_event_delete(pointerof(@event))

0 comments on commit db70dee

Please sign in to comment.