Fix desugaring of assertions

This commit is contained in:
Stanisław Barzowski 2017-09-08 18:17:38 -04:00 committed by Dave Cunningham
parent 4d5365f5e2
commit ad4be04fc1
7 changed files with 10 additions and 0 deletions

View File

@ -349,6 +349,10 @@ func desugar(astPtr *ast.Node, objLevel int) (err error) {
BranchTrue: node.Rest,
BranchFalse: &ast.Error{Expr: node.Message},
}
err = desugar(astPtr, objLevel)
if err != nil {
return err
}
case *ast.Binary:
// some operators get replaced by stdlib functions

1
testdata/assert2.golden vendored Normal file
View File

@ -0,0 +1 @@
true

1
testdata/assert2.input vendored Normal file
View File

@ -0,0 +1 @@
assert 42 == 42; true

1
testdata/assert3.golden vendored Normal file
View File

@ -0,0 +1 @@
RUNTIME ERROR: Assertion failed

1
testdata/assert3.input vendored Normal file
View File

@ -0,0 +1 @@
assert 42 != 42; 42

1
testdata/equals.golden vendored Normal file
View File

@ -0,0 +1 @@
true

1
testdata/equals.input vendored Normal file
View File

@ -0,0 +1 @@
42 == 42