Added QueryResult and patched bugs
QueryResult now stores result items and position data, which aligns more
strongly with the rest of the library features than a plain
[]interface[}. The design of the parser_test unittest was revised to
use array/map/scalar serialization (like match_test), since Go 1.3
redesigned maps to randomly order their keys. Since naive comparisons of
map data is now no longer possible, the unittest now sorts map
keys:value combinations.
* Patched a bug where getPosition("") was returning an invalid Position
* Revised parser_test to use serialization for comparisons for Go 1.3
This commit is contained in:
+3
-12
@@ -396,6 +396,7 @@ func TestDocumentPositions(t *testing.T) {
|
||||
assertPosition(t,
|
||||
"[foo]\nbar=42\nbaz=69",
|
||||
map[string]Position{
|
||||
"": Position{1, 1},
|
||||
"foo": Position{1, 1},
|
||||
"foo.bar": Position{2, 1},
|
||||
"foo.baz": Position{3, 1},
|
||||
@@ -406,6 +407,7 @@ func TestDocumentPositionsWithSpaces(t *testing.T) {
|
||||
assertPosition(t,
|
||||
" [foo]\n bar=42\n baz=69",
|
||||
map[string]Position{
|
||||
"": Position{1, 1},
|
||||
"foo": Position{1, 3},
|
||||
"foo.bar": Position{2, 3},
|
||||
"foo.baz": Position{3, 3},
|
||||
@@ -416,20 +418,9 @@ func TestDocumentPositionsWithGroupArray(t *testing.T) {
|
||||
assertPosition(t,
|
||||
"[[foo]]\nbar=42\nbaz=69",
|
||||
map[string]Position{
|
||||
"": Position{1, 1},
|
||||
"foo": Position{1, 1},
|
||||
"foo.bar": Position{2, 1},
|
||||
"foo.baz": Position{3, 1},
|
||||
})
|
||||
}
|
||||
|
||||
func TestDocumentPositionsEmptyPath(t *testing.T) {
|
||||
text := "[foo]\nbar=42\nbaz=69"
|
||||
tree, err := Load(text)
|
||||
if err != nil {
|
||||
t.Errorf("Error loading document text: `%v`", text)
|
||||
t.Errorf("Error: %v", err)
|
||||
}
|
||||
if pos := tree.GetPosition(""); !pos.Invalid() {
|
||||
t.Errorf("Valid position was returned for empty path")
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user