fix eskip tests, test mml multiple operators on the same level
This commit is contained in:
parent
0f3a64f9af
commit
f7ccebbf93
@ -529,22 +529,24 @@ func checkTerm(t *testing.T, gotName, expectedName string, gotArgs, expectedArgs
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
// legacy bug support
|
if len(gotArgs) != len(expectedArgs) {
|
||||||
for i := len(expectedArgs) - 1; i >= 0; i-- {
|
t.Error("invalid term args length in:", gotName, len(gotArgs), len(expectedArgs))
|
||||||
if _, ok := expectedArgs[i].(int); ok {
|
return
|
||||||
expectedArgs = append(expectedArgs[:i], expectedArgs[i+1:]...)
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
|
|
||||||
if v, ok := expectedArgs[i].(float64); ok && v < 0 {
|
|
||||||
gotArgs = append(gotArgs[:i], gotArgs[i+1:]...)
|
|
||||||
expectedArgs = append(expectedArgs[:i], expectedArgs[i+1:]...)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if len(gotArgs) != len(expectedArgs) {
|
// legacy bug support, dropping numeric arguments:
|
||||||
t.Error("invalid term args length", len(gotArgs), len(expectedArgs))
|
for i, a := range gotArgs {
|
||||||
return
|
ea := expectedArgs[i]
|
||||||
|
switch a.(type) {
|
||||||
|
case int, float64:
|
||||||
|
switch ea.(type) {
|
||||||
|
case int, float64:
|
||||||
|
gotArgs = append(gotArgs[:i], gotArgs[i+1:]...)
|
||||||
|
expectedArgs = append(expectedArgs[:i], expectedArgs[i+1:]...)
|
||||||
|
default:
|
||||||
|
t.Error("invalid argument type at:", i)
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for i, a := range gotArgs {
|
for i, a := range gotArgs {
|
||||||
@ -723,7 +725,7 @@ func TestEskip(t *testing.T) {
|
|||||||
const count = 1 << 9
|
const count = 1 << 9
|
||||||
|
|
||||||
r := generateEskip(count)
|
r := generateEskip(count)
|
||||||
e := eskip.Print(true, r...)
|
e := eskip.Print(eskip.PrettyPrintInfo{Pretty: true}, r...)
|
||||||
b := bytes.NewBufferString(e)
|
b := bytes.NewBufferString(e)
|
||||||
|
|
||||||
s, err := openSyntaxFile("examples/eskip.treerack")
|
s, err := openSyntaxFile("examples/eskip.treerack")
|
||||||
|
@ -434,12 +434,12 @@ operand3:alias = operand2 | binary2;
|
|||||||
operand4:alias = operand3 | binary3;
|
operand4:alias = operand3 | binary3;
|
||||||
operand5:alias = operand4 | binary4;
|
operand5:alias = operand4 | binary4;
|
||||||
|
|
||||||
binary0 = operand0 binary-op0 operand0;
|
binary0 = operand0 (binary-op0 operand0)+;
|
||||||
binary1 = operand1 binary-op1 operand1;
|
binary1 = operand1 (binary-op1 operand1)+;
|
||||||
binary2 = operand2 binary-op2 operand2;
|
binary2 = operand2 (binary-op2 operand2)+;
|
||||||
binary3 = operand3 binary-op3 operand3;
|
binary3 = operand3 (binary-op3 operand3)+;
|
||||||
binary4 = operand4 binary-op4 operand4;
|
binary4 = operand4 (binary-op4 operand4)+;
|
||||||
binary5 = operand5 binary-op5 operand5;
|
binary5 = operand5 (binary-op5 operand5)+;
|
||||||
|
|
||||||
binary-expression:alias = binary0 | binary1 | binary2 | binary3 | binary4 | binary5;
|
binary-expression:alias = binary0 | binary1 | binary2 | binary3 | binary4 | binary5;
|
||||||
|
|
||||||
|
18
mml_test.go
18
mml_test.go
@ -2308,6 +2308,24 @@ func TestMML(t *testing.T) {
|
|||||||
}},
|
}},
|
||||||
}},
|
}},
|
||||||
ignorePosition: true,
|
ignorePosition: true,
|
||||||
|
}, {
|
||||||
|
title: "binary 1, 1, 1",
|
||||||
|
text: "a + b + c",
|
||||||
|
nodes: []*Node{{
|
||||||
|
Name: "binary1",
|
||||||
|
Nodes: []*Node{{
|
||||||
|
Name: "symbol",
|
||||||
|
}, {
|
||||||
|
Name: "add",
|
||||||
|
}, {
|
||||||
|
Name: "symbol",
|
||||||
|
}, {
|
||||||
|
Name: "add",
|
||||||
|
}, {
|
||||||
|
Name: "symbol",
|
||||||
|
}},
|
||||||
|
}},
|
||||||
|
ignorePosition: true,
|
||||||
}, {
|
}, {
|
||||||
title: "binary 3, 4, 5",
|
title: "binary 3, 4, 5",
|
||||||
text: "a * b + c * d == e * f && g || h -> f()",
|
text: "a * b + c * d == e * f && g || h -> f()",
|
||||||
|
Loading…
Reference in New Issue
Block a user