Commit 9504b8b0 authored by Antoine Martin's avatar Antoine Martin Committed by Etienne Renault

ltl-desugar: more tests

parent d8633ee7
......@@ -30,7 +30,7 @@ func Desugar(formula string, aliases map[string][]string) (string, error) {
formula = formula[len("xxx("):]
xp, xpLen, err := findExpr(formula)
if err != nil {
return "", fmt.Errorf("couldn't expand expression: %v", err)
return "", fmt.Errorf("couldn't identify expression: %v", err)
}
x, err := parseExpr(xp)
......
......@@ -44,6 +44,26 @@ func TestSimpleVarExpand(t *testing.T) {
expected: `("a1" || "a2" || "a3" || "a4")`,
shouldFail: false,
},
// 1
{
variable: SimpleVar{
name: "a",
},
aliases: map[string][]string{},
expected: "",
shouldFail: true,
},
// 2
{
variable: SimpleVar{
name: "a",
},
aliases: map[string][]string{
"a": []string{},
},
expected: "",
shouldFail: true,
},
}
for i, test := range tests {
......@@ -87,6 +107,30 @@ func TestBoolExpressionExpand(t *testing.T) {
expected: `(("a1 == 2") || ("a2 == 2"))`,
shouldFail: false,
},
// 1
{
expr: BoolExpression{
lhs: "a",
operator: "==",
rhs: "2",
},
aliases: map[string][]string{
"a": []string{},
},
expected: "",
shouldFail: true,
},
// 2
{
expr: BoolExpression{
lhs: "a",
operator: "==",
rhs: "2",
},
aliases: map[string][]string{},
expected: "",
shouldFail: true,
},
}
for i, test := range tests {
......@@ -132,6 +176,48 @@ func TestDesugar(t *testing.T) {
expected: `F (("a1 == 2") || ("a2 == 2"))`,
shouldFail: false,
},
// 2
{
formula: `F any("not_in_map")`,
aliases: map[string][]string{},
expected: "",
shouldFail: true,
},
// 3
{
formula: `F any("a a")`,
aliases: map[string][]string{},
expected: "",
shouldFail: true,
},
// 4
{
formula: `F any("a a a a")`,
aliases: map[string][]string{},
expected: "",
shouldFail: true,
},
// 5
{
formula: `F any("")`,
aliases: map[string][]string{},
expected: "",
shouldFail: true,
},
// 6
{
formula: `F any(""`,
aliases: map[string][]string{},
expected: "",
shouldFail: true,
},
// 7
{
formula: `F any(a == 2)`,
aliases: map[string][]string{},
expected: "",
shouldFail: true,
},
}
for i, test := range tests {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment