Esempio n. 1
0
func main() {
	a := "((1 -3 +3*4)+5 > 100) && (2<3)"
	//a = "4"
	a = " (2<3 || 2<1) && 3 <4"

	result, err := evaluator.Eval(a)

	ret, err := evaluator.Evaluate(a)
	fmt.Println(ret, 2222222222222222222)

	fmt.Println(result, 777, evaluator.BigratToBool(result), err)

}
Esempio n. 2
0
func TestEval(t *testing.T) {
	for i, test := range testsEval {
		ret, err := evaluator.Eval(test.in)
		if ret == nil && test.out == nil {
			// ok, do nothing
		} else if ret == nil || test.out == nil {
			t.Errorf("#%d: %s: unexpected nil result: %v vs %v", i, test.in, ret, test.out)
		} else if ret.Cmp(test.out) != 0 {
			t.Errorf("#%d: %s: bad result: got %v expected %v", i, test.in, ret, test.out)
		}
		if (err == nil) != test.ok {
			t.Errorf("#%d: %s: unexpected err result: %t vs %t", i, test.in, (err == nil), test.ok)
		}
	}
}