2016-08-02 00:08:51 +00:00
|
|
|
package expr
|
|
|
|
|
|
|
|
import (
|
|
|
|
"encoding/hex"
|
2016-08-05 18:34:17 +00:00
|
|
|
"fmt"
|
2016-08-02 00:08:51 +00:00
|
|
|
"math/rand"
|
2016-08-05 18:34:17 +00:00
|
|
|
"strings"
|
2016-08-02 00:08:51 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
func randStr() string {
|
|
|
|
b := make([]byte, 16)
|
|
|
|
if _, err := rand.Read(b); err != nil {
|
|
|
|
panic(err)
|
|
|
|
}
|
|
|
|
return hex.EncodeToString(b)
|
|
|
|
}
|
2016-08-05 18:34:17 +00:00
|
|
|
|
|
|
|
func exprsJoin(ee []Expr) string {
|
|
|
|
strs := make([]string, len(ee))
|
|
|
|
for i := range ee {
|
2016-08-06 18:20:53 +00:00
|
|
|
strs[i] = fmt.Sprint(ee[i])
|
2016-08-05 18:34:17 +00:00
|
|
|
}
|
|
|
|
return strings.Join(strs, ", ")
|
|
|
|
}
|
|
|
|
|
|
|
|
func exprsEqual(ee1, ee2 []Expr) bool {
|
|
|
|
if len(ee1) != len(ee2) {
|
|
|
|
return false
|
|
|
|
}
|
|
|
|
for i := range ee1 {
|
2016-08-06 18:20:53 +00:00
|
|
|
if !exprEqual(ee1[i], ee2[i]) {
|
2016-08-05 18:34:17 +00:00
|
|
|
return false
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return true
|
|
|
|
}
|
|
|
|
|
|
|
|
func panicf(msg string, args ...interface{}) {
|
|
|
|
panic(fmt.Sprintf(msg, args...))
|
|
|
|
}
|