24 lines
439 B
Go
24 lines
439 B
Go
package boolean
|
|
|
|
import (
|
|
"testing"
|
|
"fmt"
|
|
"bufio"
|
|
"strings"
|
|
)
|
|
|
|
func TestSimpleExpr(t *testing.T) {
|
|
stream := bufio.NewReader(strings.NewReader("(x + 10) + 5 + -10"))
|
|
token_stream, err := Tokenize(stream)
|
|
if err != nil {
|
|
t.Error(err)
|
|
}
|
|
expr, err := ParseExpr(token_stream)
|
|
if err != nil {
|
|
t.Error(err)
|
|
}
|
|
fmt.Printf("EVAL : %s - %s\n", expr, expr.Value(map[string]Expr{
|
|
"x": NumericConstant{2.5},
|
|
}))
|
|
}
|