mirror of
https://github.com/Kugelschieber/asl.git
synced 2026-01-18 12:00:25 +00:00
Missing != operator, added test for all of them.
This commit is contained in:
@@ -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("=") {
|
||||
|
||||
@@ -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)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user