aboutsummaryrefslogtreecommitdiff
path: root/spec/test/parser.go
diff options
context:
space:
mode:
authorRyo Nihei <nihei.dev@gmail.com>2022-06-11 21:40:38 +0900
committerRyo Nihei <nihei.dev@gmail.com>2022-06-11 22:27:52 +0900
commit52ad315a0df8a346953e570e8be472709b81cc6a (patch)
tree5221784eacd9efcc63d83297d8e2b60f8acbc1bd /spec/test/parser.go
parentRemove the kind field from a node corresponding to an anonymous terminal symbol (diff)
downloadcotia-52ad315a0df8a346953e570e8be472709b81cc6a.tar.gz
cotia-52ad315a0df8a346953e570e8be472709b81cc6a.tar.xz
Support the underscore symbol matching any symbols in vartan-test command
Diffstat (limited to 'spec/test/parser.go')
-rw-r--r--spec/test/parser.go5
1 files changed, 3 insertions, 2 deletions
diff --git a/spec/test/parser.go b/spec/test/parser.go
index 483e553..f255381 100644
--- a/spec/test/parser.go
+++ b/spec/test/parser.go
@@ -89,7 +89,8 @@ func DiffTree(expected, actual *Tree) []*TreeDiff {
if expected == nil && actual == nil {
return nil
}
- if actual.Kind != expected.Kind {
+ // _ matches any symbols.
+ if expected.Kind != "_" && actual.Kind != expected.Kind {
msg := fmt.Sprintf("unexpected kind: expected '%v' but got '%v'", expected.Kind, actual.Kind)
return []*TreeDiff{
newTreeDiff(expected, actual, msg),
@@ -103,7 +104,7 @@ func DiffTree(expected, actual *Tree) []*TreeDiff {
}
var diffs []*TreeDiff
for i, exp := range expected.Children {
- if ds := DiffTree(actual.Children[i], exp); len(ds) > 0 {
+ if ds := DiffTree(exp, actual.Children[i]); len(ds) > 0 {
diffs = append(diffs, ds...)
}
}