Missing != operator, added test for all of them.

This commit is contained in:
Marvin Blum
2015-10-25 13:15:51 +01:00
parent 2e7e198047
commit 9db5c2042d
5 changed files with 62 additions and 5 deletions

View File

@@ -326,7 +326,7 @@ func parseParameter(out bool) (string, int) {
func parseExpression(out bool) string {
output := parseArith()
for accept("<") || accept(">") || accept("&") || accept("|") || accept("=") {
for accept("<") || accept(">") || accept("&") || accept("|") || accept("=") || accept("!") {
if accept("<") {
output += "<"
next()
@@ -341,9 +341,13 @@ func parseExpression(out bool) string {
next()
expect("|")
output += "||"
} else {
} else if accept("=") {
output += "="
next()
} else {
next()
expect("=")
output += "!="
}
if accept("=") {

View File

@@ -94,6 +94,13 @@ func TestParserBuildinFunctionCall(t *testing.T) {
equal(t, got, want)
}
func TestParserOperator(t *testing.T) {
got := getCompiled(t, "test/parser_operator.asl")
want := "if (x==y&&x!=y&&x<=y&&x>=y&&x<y&&x>y) then {\n};\n"
equal(t, got, want)
}
func getCompiled(t *testing.T, file string) string {
code, err := ioutil.ReadFile(file)