Bladeren bron

Fixed a test reporting bad results

luis 7 jaren geleden
bovenliggende
commit
0e1e145a1a

+ 2 - 0
Makefile

@@ -43,6 +43,8 @@ builder:
 	git commit -m "Droning building $$(date)"
 	git push builder master
 
+test: 
+	make -C go test
 
 
 

+ 2 - 2
go/Makefile

@@ -30,10 +30,10 @@ $(BIN): deps
 
 # generate
 generate:
-	GOPATH="$(GOPATH)" go generate ./src/...
+	GOPATH="$(GOPATH)" go generate -v ./src/...
 
 test:
-	$(ENV) go test ./src/...
+	$(ENV) gocov test ./src/... | gocov report
 
 #$(BIN): $(addprefix src/,$(SOURCE))
 #	echo $<

+ 0 - 103
go/src/flow/cover.out

@@ -1,103 +0,0 @@
-mode: set
-flow/flow.go:48.18,56.2 1 1
-flow/flow.go:59.28,61.2 1 1
-flow/flow.go:64.56,68.2 2 0
-flow/flow.go:71.79,73.27 2 1
-flow/flow.go:83.2,84.16 2 1
-flow/flow.go:88.2,89.22 2 1
-flow/flow.go:73.27,74.24 1 1
-flow/flow.go:75.19,76.17 1 0
-flow/flow.go:77.11,79.39 2 1
-flow/flow.go:84.16,87.3 2 0
-flow/flow.go:94.41,97.2 1 1
-flow/flow.go:102.65,105.27 2 1
-flow/flow.go:117.2,118.16 2 1
-flow/flow.go:123.2,123.6 1 1
-flow/flow.go:105.27,106.24 1 1
-flow/flow.go:107.19,108.17 1 1
-flow/flow.go:109.11,112.39 2 1
-flow/flow.go:118.16,121.3 2 1
-flow/flow.go:123.6,125.38 2 1
-flow/flow.go:128.3,129.25 2 1
-flow/flow.go:125.38,126.12 1 0
-flow/flow.go:135.44,139.2 3 1
-flow/flow.go:142.60,143.32 1 1
-flow/flow.go:150.2,150.23 1 1
-flow/flow.go:143.32,145.23 2 1
-flow/flow.go:148.3,148.19 1 1
-flow/flow.go:145.23,147.4 1 1
-flow/flow.go:155.42,157.2 1 1
-flow/flow.go:160.64,161.18 1 1
-flow/flow.go:164.2,165.36 2 1
-flow/flow.go:161.18,163.3 1 0
-flow/flow.go:167.91,169.27 2 1
-flow/flow.go:173.2,175.22 2 1
-flow/flow.go:186.2,187.15 2 1
-flow/flow.go:169.27,171.3 1 0
-flow/flow.go:175.22,178.32 3 1
-flow/flow.go:182.3,182.66 1 1
-flow/flow.go:178.32,181.4 2 1
-flow/flow.go:183.3,185.3 1 1
-flow/flow.go:191.53,192.14 1 1
-flow/flow.go:195.2,196.34 2 1
-flow/flow.go:192.14,194.3 1 0
-flow/flow.go:196.34,200.32 3 1
-flow/flow.go:212.3,219.36 5 1
-flow/flow.go:200.32,202.14 1 1
-flow/flow.go:205.4,206.20 2 1
-flow/flow.go:210.4,210.56 1 1
-flow/flow.go:202.14,204.5 1 1
-flow/flow.go:206.20,209.5 2 0
-flow/flow.go:227.32,231.29 3 1
-flow/flow.go:234.2,235.27 2 1
-flow/flow.go:239.2,240.33 2 1
-flow/flow.go:251.2,251.21 1 1
-flow/flow.go:231.29,233.3 1 1
-flow/flow.go:235.27,237.3 1 1
-flow/flow.go:240.33,242.31 2 1
-flow/flow.go:248.3,248.26 1 1
-flow/flow.go:242.31,243.14 1 1
-flow/flow.go:246.4,246.46 1 1
-flow/flow.go:243.14,245.5 1 1
-flow/flow.go:255.46,262.33 4 1
-flow/flow.go:272.2,276.27 4 1
-flow/flow.go:262.33,264.31 2 1
-flow/flow.go:270.3,270.42 1 1
-flow/flow.go:264.31,269.4 1 1
-flow/flow.go:284.75,286.2 1 1
-flow/flow.go:288.62,289.31 1 1
-flow/flow.go:289.31,291.3 1 1
-flow/operation.go:18.23,20.2 1 1
-flow/operation.go:23.30,23.32 0 0
-flow/operation.go:44.33,46.2 1 0
-flow/operation.go:49.50,51.2 1 1
-flow/operation.go:54.68,55.23 1 1
-flow/operation.go:58.2,58.16 1 1
-flow/operation.go:61.2,61.25 1 1
-flow/operation.go:64.2,67.12 3 1
-flow/operation.go:55.23,57.3 1 1
-flow/operation.go:58.16,60.3 1 0
-flow/operation.go:61.25,63.3 1 1
-flow/operation.go:71.41,73.2 1 1
-flow/operation.go:79.39,85.49 1 1
-flow/operation.go:85.49,86.35 1 1
-flow/operation.go:90.4,90.21 1 1
-flow/operation.go:86.35,89.5 2 0
-flow/operation.go:94.42,100.49 1 1
-flow/operation.go:100.49,103.4 2 1
-flow/operation.go:106.44,112.49 1 1
-flow/operation.go:112.49,114.11 2 1
-flow/operation.go:118.4,119.33 2 1
-flow/operation.go:129.4,138.14 4 1
-flow/operation.go:114.11,117.5 2 0
-flow/operation.go:119.33,121.18 2 1
-flow/operation.go:125.5,125.39 1 1
-flow/operation.go:121.18,124.6 2 0
-flow/operation.go:143.43,148.33 1 1
-flow/operation.go:148.33,148.59 1 1
-flow/operation.go:149.49,149.70 1 1
-flow/operation.go:153.32,157.49 1 1
-flow/operation.go:157.49,157.100 2 0
-flow/utils.go:8.28,12.16 3 1
-flow/utils.go:16.2,18.8 2 1
-flow/utils.go:12.16,15.3 2 0

+ 21 - 14
go/src/flow/flow.go

@@ -6,7 +6,6 @@ import (
 	"flow/registry"
 	"fmt"
 	"io"
-	"log"
 	"os"
 	"reflect"
 )
@@ -33,7 +32,8 @@ type opEntry struct {
 type Flow struct {
 	registry *registry.Registry
 
-	consts     []Data
+	consts     map[string]Data
+
 	data       map[string]Data // Should be named, to fetch later
 	operations map[string]opEntry
 
@@ -49,7 +49,7 @@ func New() *Flow {
 	return &Flow{
 		registry: Global,
 		// Data
-		consts:     []Data{},
+		consts:     map[string]Data{},
 		data:       map[string]Data{},
 		operations: map[string]opEntry{},
 	}
@@ -75,7 +75,7 @@ func (f *Flow) DefOp(id string, name string, params ...interface{}) Operation {
 		case *operation:
 			inputs[i] = v
 		default:
-			log.Println("WARNING defining const with value", v)
+			//log.Println("WARNING defining const with value", v)
 			inputs[i] = f.Const(v).(*operation)
 		}
 	}
@@ -108,7 +108,7 @@ func (f *Flow) Op(name string, params ...interface{}) Operation {
 			inputs[i] = v
 		default:
 			// fail here
-			log.Println("WARNING defining const with value", v)
+			//log.Println("WARNING defining const with value", v)
 			inputs[i] = f.Const(v).(*operation)
 		}
 	}
@@ -121,21 +121,27 @@ func (f *Flow) Op(name string, params ...interface{}) Operation {
 	}
 	// generate ID
 	for {
-		uuid := puuid()
-		if _, ok := f.operations[uuid]; ok {
+		id := RandString(8)
+		if _, ok := f.operations[id]; ok {
 			continue
 		}
-		f.operations[uuid] = opEntry{name, inputs, executor}
-		return opFunc(f, uuid)
+		f.operations[id] = opEntry{name, inputs, executor}
+		return opFunc(f, id)
 	}
 	// Initialize opfunc maybe
 }
 
 // Const returns a const operation
 func (f *Flow) Const(value Data) Operation {
-	f.consts = append(f.consts, value)
-	refID := len(f.consts) - 1
-	return opConst(f, refID)
+	// generate ID
+	for {
+		id := RandString(8)
+		if _, ok := f.consts[id]; ok {
+			continue
+		}
+		f.consts[id] = value
+		return opConst(f, id)
+	}
 }
 
 // Var operation
@@ -226,17 +232,18 @@ func (f *Flow) Analyse(w io.Writer, params ...Data) {
 
 func (f *Flow) String() string {
 	ret := bytes.NewBuffer(nil)
+	fmt.Fprintf(ret, "Flow\n")
 	// consts
 	fmt.Fprintf(ret, "consts:\n")
 	for i, v := range f.consts {
-		fmt.Fprintf(ret, "  [%d] %v\n", i, v)
+		fmt.Fprintf(ret, "  [%s] %v\n", i, v)
 	}
 	fmt.Fprintf(ret, "data:\n") // Or variable
 	for k, v := range f.data {
 		fmt.Fprintf(ret, "  [%v] %v\n", k, v)
 	}
 
-	fmt.Fprintf(ret, "operations:\n")
+	fmt.Fprintf(ret, "funcs:\n")
 	for k, v := range f.operations {
 		fmt.Fprintf(ret, "  [%s] %s(", k, v.name)
 		for j, in := range v.inputs {

+ 40 - 21
go/src/flow/flow_test.go

@@ -9,9 +9,14 @@ import (
 
 	vecasm "github.com/gohxs/vec-benchmark/asm"
 
-	. "flow/internal/check"
+	"flow/internal/assert"
+	"flow/registry"
 )
 
+func init() {
+	assert.Quiet = true
+}
+
 func TestSerialize(t *testing.T) {
 	// Does not text yet
 	f := flow.New()
@@ -48,13 +53,16 @@ func TestSerialize(t *testing.T) {
 
 }
 func TestConst(t *testing.T) {
+	assert := assert.A(t)
 	f := flow.New()
 
 	c := f.Const(1)
 	res := c.Process()
-	Expect(t).Eq(res, 1)
+	//Expect(t).Eq(res, 1)
+	assert.Eq(res, 1, "It should be one")
 }
 func TestOp(t *testing.T) {
+	assert := assert.A(t)
 	f := flow.New()
 
 	add := f.Op("vecadd",
@@ -65,10 +73,10 @@ func TestOp(t *testing.T) {
 		[]float32{1, 2, 3},
 	)
 	res, err := f.Run(add)
-	Expect(t).Eq(err, nil)
+	assert.Eq(err, nil)
 
 	test := []float32{3, 6, 9}
-	Expect(t).Eq(test, res)
+	assert.Eq(test, res)
 }
 
 func TestVariable(t *testing.T) {
@@ -76,11 +84,11 @@ func TestVariable(t *testing.T) {
 	v := f.Var("v1", 1)
 
 	res := v.Process()
-	Expect(t).Eq(res, 1)
+	assert.A(t).Eq(res, 1)
 
 	v.Set(2)
 	res = v.Process()
-	Expect(t).Eq(res, 2)
+	assert.Eq(t, res, 2)
 }
 
 func TestCache(t *testing.T) {
@@ -90,7 +98,7 @@ func TestCache(t *testing.T) {
 		var res interface{}
 		for i := 1; i < 5; i++ {
 			res = r.Process()
-			Expect(t).Eq(res, i)
+			assert.Eq(t, res, i)
 		}
 	}
 	{
@@ -98,25 +106,28 @@ func TestCache(t *testing.T) {
 		inc := f.Op("inc")
 		add := f.Op("add", inc, inc)
 		res = add.Process() // 1+1
-		Expect(t).Eq(res, 2)
+		assert.Eq(t, res, 2)
 		res = add.Process() // 2+2
-		Expect(t).Eq(res, 4)
+		assert.Eq(t, res, 4)
 	}
 }
-func TestReference(t *testing.T) {
+func TestDefOp(t *testing.T) {
+	assert := assert.A(t)
 	f := flow.New()
 
-	f.DefOp("1", "vecadd", []float32{1, 2, 3}, []float32{1, 2, 3}) // result 2 4 6
-
-	op := f.Op("vecmul", f.Res("1"), []float32{2, 2, 2}) // 4 8 12
-	Expect(t).NotErr(f.Err())
+	f.DefOp("2", "vecadd", []float32{1, 1, 1}, []float32{2, 2, 2}) // r:3 3 3
+	assert.Eq(f.Err(), nil, "doing DefOp")
 
-	Expect(t).Diff(nil, op)
+	f.DefOp("1", "vecadd", []float32{1, 2, 3}, f.Res("2")) // r: 4 5 6
+	assert.Eq(f.Err(), nil, "doing DefOp")
 
-	desired := []float32{4, 8, 12}
+	op := f.Op("vecmul", f.Res("1"), []float32{2, 2, 2}) //r:8 10 12
+	assert.Eq(f.Err(), nil, "mul operation")
+	assert.NotEq(op, nil, "operation not nil")
 
+	desired := []float32{8, 10, 12}
 	res := op.Process()
-	Expect(t).Eq(res, desired)
+	assert.Eq(desired, res, "vector result should match")
 }
 
 func TestHandler(t *testing.T) {
@@ -127,12 +138,20 @@ func TestHandler(t *testing.T) {
 	op.Process()
 }
 
-func TestRegistry(t *testing.T) {
+func TestLocalRegistry(t *testing.T) {
+	assert := assert.A(t)
+
+	r := registry.New()
+	e := r.Register("test", func() string { return "" })
+	assert.NotEq(e, nil, "registered in a local register")
+
 	f := flow.New()
-	op := f.Op("unknown", 1, 2)
-	op.Process()
+	f.SetRegistry(r)
+	op := f.Op("test")
+	assert.NotEq(op, nil, "operation should be valid")
 
-	Expect(t).Err(f.Err())
+	op = f.Op("none")
+	assert.NotEq(f.Err(), nil, "flow should contain an error")
 }
 
 func BenchmarkComplex(b *testing.B) {

+ 94 - 0
go/src/flow/internal/assert/assert.go

@@ -0,0 +1,94 @@
+package assert
+
+import (
+	"fmt"
+	"os"
+	"path/filepath"
+	"reflect"
+	"runtime"
+	"testing"
+)
+
+// Global setup
+var (
+	Quiet = false
+)
+
+//A return a asserter with testing.T
+func A(t *testing.T) *Checker {
+	return &Checker{T: t}
+}
+
+// Eq global
+func Eq(t *testing.T, a, b interface{}, params ...interface{}) *Checker {
+	return A(t).Eq(a, b, params...)
+}
+
+// NotEq global
+func NotEq(t *testing.T, a, b interface{}, params ...interface{}) *Checker {
+	return A(t).NotEq(a, b, params...)
+}
+
+// Checker test checking helper
+type Checker struct {
+	*testing.T
+}
+
+//Eq check if equal
+func (t *Checker) Eq(a, b interface{}, params ...interface{}) *Checker {
+	msg := fmt.Sprintf("(%s) Expect Eq '%v' got '%v'", fmt.Sprint(params...), a, b)
+
+	if (a == nil || (reflect.ValueOf(a).Kind() == reflect.Ptr && reflect.ValueOf(a).IsNil())) &&
+		(b == nil || (reflect.ValueOf(b).Kind() == reflect.Ptr && reflect.ValueOf(b).IsNil())) {
+		t.pass(msg)
+		return t
+	}
+	if !reflect.DeepEqual(a, b) {
+		t.fail(msg)
+	}
+	t.pass(msg)
+	return t
+}
+
+//NotEq check if different
+func (t *Checker) NotEq(a, b interface{}, params ...interface{}) *Checker {
+	msg := fmt.Sprintf("(%s) Expect NotEq '%v' got '%v'", fmt.Sprint(params...), a, b)
+	if (a == nil || (reflect.ValueOf(a).Kind() == reflect.Ptr && reflect.ValueOf(a).IsNil())) &&
+		(b == nil || (reflect.ValueOf(b).Kind() == reflect.Ptr && reflect.ValueOf(b).IsNil())) {
+		t.fail(msg)
+	}
+	if reflect.DeepEqual(a, b) {
+		t.fail(msg)
+	}
+	t.pass(msg)
+	return t
+}
+
+func (t *Checker) fail(msg string) {
+	file, line := getCaller(3)
+	fmt.Fprintf(os.Stderr, "    %s:%-4s \033[31m[FAIL] \033[01;31m%s\033[0m\n", file, fmt.Sprintf("%d:", line), msg)
+	t.FailNow()
+	//t.FailNow()
+}
+func (t *Checker) pass(msg string) {
+
+	if Quiet {
+		return
+	}
+	file, line := getCaller(3)
+	file = filepath.Base(file)
+	fmt.Fprintf(os.Stderr, "    %s:%-4s \033[32m[PASS]\033[m %s\n", file, fmt.Sprintf("%d:", line), msg)
+}
+
+func getCaller(offs int) (string, int) {
+	var file string
+	var line int
+	for count := offs; ; count++ {
+		_, file, line, _ = runtime.Caller(count)
+		file = filepath.Base(file)
+		if file != "assert.go" {
+			break
+		}
+	}
+	return file, line
+}

+ 0 - 70
go/src/flow/internal/check/check.go

@@ -1,70 +0,0 @@
-package check_test
-
-import (
-	"fmt"
-	"reflect"
-	"testing"
-)
-
-//Expect return a checker
-func Expect(t *testing.T) Checker {
-	return Checker{T: t}
-}
-
-// Checker test checking helper
-type Checker struct {
-	*testing.T
-}
-
-//NotErr check for error
-func (t Checker) NotErr(err error) {
-	msg := fmt.Sprintf("NOTERR Expect NOT [error] got '%v'", err)
-	if err != nil {
-		t.fail(msg)
-	}
-	t.pass(msg)
-}
-
-// Err expects param to be error
-func (t Checker) Err(err error) {
-	msg := fmt.Sprintf("ERR: Expect [error] got '%v'", err)
-	if err == nil {
-		t.fail(msg)
-	}
-	t.pass(msg)
-}
-
-//Eq check if equal
-func (t Checker) Eq(a, b interface{}) {
-	msg := fmt.Sprintf("EQ Expect '%v' got '%v'", b, a)
-	if !reflect.DeepEqual(a, b) {
-		t.fail(msg)
-	}
-	t.pass(msg)
-}
-
-//Diff check if different
-func (t Checker) Diff(a, b interface{}) {
-	msg := fmt.Sprintf("DIFF Expect NOT '%v' got '%v'", a, b)
-
-	if reflect.DeepEqual(a, b) {
-		t.fail(msg)
-	}
-	t.pass(msg)
-}
-
-// NotNil expect param to be non nil
-func (t Checker) NotNil(a interface{}) {
-	msg := fmt.Sprintf("NOTNIL Expect NOT [nil] got %v", a)
-	if a == nil {
-		t.fail(msg)
-	}
-	t.pass(msg)
-}
-
-func (t Checker) fail(msg string) {
-	t.Fatalf("\033[31m[FAIL] %s\033[0m", msg)
-}
-func (t Checker) pass(msg string) {
-	t.Logf("\033[32m[PASS]\033[m %s", msg)
-}

+ 3 - 4
go/src/flow/operation.go

@@ -42,7 +42,7 @@ type operation struct {
 
 // Id returns string Id of the operaton
 func (o *operation) ID() string {
-	return o.id.(string)
+	return fmt.Sprint(o.id)
 }
 
 // Process operation process wrapper
@@ -91,7 +91,7 @@ func opIn(f *Flow, id int) *operation {
 		},
 	}
 }
-func opConst(f *Flow, id int) *operation {
+func opConst(f *Flow, id string) *operation {
 	return &operation{
 		flow: f,
 		id:   id,
@@ -115,6 +115,7 @@ func opFunc(f *Flow, id string) *operation {
 				f.err = fmt.Errorf("invalid operation '%s'", id)
 				return nil
 			}
+
 			callParam := make([]reflect.Value, len(op.inputs))
 			for i, in := range op.inputs {
 				fr := in.processWithCtx(ctx, params...)
@@ -123,9 +124,7 @@ func opFunc(f *Flow, id string) *operation {
 					return nil
 				}
 				callParam[i] = reflect.ValueOf(fr)
-
 			}
-
 			f.trigger("nodeStart", map[string]Data{
 				"id": id,
 			})

+ 5 - 5
go/src/flow/registry/entry_test.go

@@ -1,18 +1,18 @@
 package registry_test
 
 import (
-	. "flow/internal/check"
+	"flow/internal/assert"
 	"flow/registry"
 	"testing"
 )
 
 func TestNewEntryInvalid(t *testing.T) {
-	exp := Expect(t)
+	assert := assert.A(t)
 	e := registry.NewEntry("string")
-	exp.Eq(e.Err(), registry.ErrNotAFunc)
+	assert.Eq(e.Err(), registry.ErrNotAFunc, "entry is not a function")
 }
 func TestNewEntryValid(t *testing.T) {
-	exp := Expect(t)
+	assert := assert.A(t)
 	e := registry.NewEntry(func(a int) int { return 0 })
-	exp.NotErr(e.Err())
+	assert.Eq(e.Err(), nil, "Fetching an entry")
 }

+ 41 - 41
go/src/flow/registry/registry_test.go

@@ -1,137 +1,137 @@
 package registry_test
 
 import (
+	"flow/internal/assert"
 	"flow/registry"
 	"testing"
-
-	. "flow/internal/check"
 )
 
 func TestRegistry(t *testing.T) {
-	expect := Expect(t)
+	assert := assert.A(t)
 
 	r := registry.New()
 	r.Register("vecadd", dummy1)
 
 	e, err := r.Entry("vecadd")
-	expect.NotErr(err)
+	assert.NotEq(err, nil, "fetching entry")
 
 	d := e.Description
 
-	expect.Eq(2, len(d.Inputs))
-	expect.Eq(d.Output, "[]float32")
+	assert.Eq(len(d.Inputs), 2, "should have 2 outputs")
+	assert.Eq(d.Output, "[]float32", "output type")
 
 	t.Log(d)
 
 }
 
 func TestEntry(t *testing.T) {
-	exp := Expect(t)
+	assert := assert.A(t)
 	r := registry.New()
 	e, err := r.Entry("bogus")
-	exp.Err(err)
-	exp.Eq(e, nil)
+
+	assert.NotEq(err, nil, "should get an error")
+	assert.Eq(e, nil, "entry should be nil")
 
 }
 
 func TestRegister(t *testing.T) {
-	exp := Expect(t)
+	assert := assert.A(t)
 	r := registry.New()
 	e := r.Register("func", func(a, b int) int { return 0 })
-	exp.NotErr(e.Err())
+	assert.NotEq(e.Err(), nil, "registering a func")
 }
 func TestRegisterDuplicate(t *testing.T) {
-	exp := Expect(t)
+	assert := assert.A(t)
 	r := registry.New()
 	r.Register("func", func(a, b int) int { return 0 })
 	e := r.Register("func", func(b int) int { return 0 })
-	exp.NotErr(e.Err())
+
+	assert.NotEq(e.Err(), nil, "should allow duplicate")
 }
 func TestRegisterInvalidOutput(t *testing.T) {
-	exp := Expect(t)
+	assert := assert.A(t)
 	r := registry.New()
 	e := r.Register("func", func(a int) {})
-	exp.Eq(e.Err(), registry.ErrOutput)
+	assert.Eq(e.Err(), registry.ErrOutput, "should give output error")
 }
 
 func TestRegisterInvalidInput(t *testing.T) {
-	exp := Expect(t)
+	assert := assert.A(t)
 	r := registry.New()
 	e := r.Register("func", func() int { return 0 })
-
-	exp.NotErr(e.Err())
+	assert.Eq(e.Err(), nil, "should register a func without params")
 }
 
 func TestRegistryGet(t *testing.T) {
-	exp := Expect(t)
+	assert := assert.A(t)
 	r := registry.New()
 	e := r.Register("func", func() int { return 0 })
-	exp.NotErr(e.Err())
+	assert.Eq(e.Err(), nil, "should register func")
 
 	fn, err := r.Get("func")
-	exp.NotErr(err)
-	exp.NotNil(fn)
+	assert.Eq(err, nil, "should fetch a function")
+	assert.NotEq(fn, nil, "fn should not be nil")
 }
 
 func TestRegistryGetEmpty(t *testing.T) {
-	exp := Expect(t)
+	assert := assert.A(t)
 	r := registry.New()
 	fn, err := r.Get("notfoundfunc")
-	exp.Eq(err, registry.ErrNotFound)
-	exp.Eq(fn, nil)
+	assert.Eq(err, registry.ErrNotFound, "should fail fetching a unregistered func")
+	assert.Eq(fn, nil, "should return a <nil> func")
 }
 func TestRegistryGetConstructor(t *testing.T) {
-	exp := Expect(t)
+	assert := assert.A(t)
 	r := registry.New()
 	e := r.Register("func", func() func() int {
 		return func() int {
 			return 0
 		}
 	})
-	exp.NotErr(e.Err())
+	assert.Eq(e.Err(), nil, "should register the constructor func")
 
 	ifn, err := r.Get("func")
-	exp.NotErr(err)
+	assert.Eq(err, nil, "get should not error")
 
 	fn, ok := ifn.(func() int)
-	exp.Eq(ok, true)
+	assert.Eq(ok, true, "function should be the constructor type")
 
 	ret := fn()
-	exp.Eq(ret, 0)
-
+	assert.Eq(ret, 0, "function should return 0")
 }
+
 func TestRegistryGetConstructorParam(t *testing.T) {
-	exp := Expect(t)
-	r := registry.New()
+	assert := assert.A(t)
 
+	r := registry.New()
 	e := r.Register("func2", func(a, b int) func() int {
 		return func() int {
 			return a + b
 		}
 	})
-	exp.NotErr(e.Err())
+	assert.Eq(e.Err(), nil)
 	ifn, err := r.Get("func2", 1, 1)
-	exp.NotErr(err)
-	exp.NotNil(ifn)
+	assert.Eq(err, nil, "should not fail passing params to constructor")
+	assert.NotEq(ifn, nil, "should return a function")
 
 	fn, ok := ifn.(func() int)
-	exp.Eq(ok, true)
+	assert.Eq(ok, true, "function should match the type")
 
 	ret := fn()
-	exp.Eq(ret, 2)
+	assert.Eq(ret, 2, "function should execute")
 
 }
 
 func TestDescriptions(t *testing.T) {
-	expect := Expect(t)
+	assert := assert.A(t)
 
 	r := registry.New()
 	r.Register("vecadd", dummy1)
 	r.Register("vecstr", dummy2)
 
 	d, err := r.Descriptions()
-	expect.NotErr(err)
-	expect.Eq(len(d), 2)
+	assert.Eq(err, nil, "should fetch Descriptions")
+	assert.Eq(len(d), 2, "should contain 2 descriptions")
 
 	t.Log(d)
 

+ 29 - 5
go/src/flow/utils.go

@@ -1,11 +1,8 @@
 package flow
 
-import (
-	"crypto/rand"
-	"fmt"
-)
+import "math/rand"
 
-func puuid() (uuid string) {
+/*func puuid() (uuid string) {
 
 	b := make([]byte, 16)
 	_, err := rand.Read(b)
@@ -16,4 +13,31 @@ func puuid() (uuid string) {
 	uuid = fmt.Sprintf("%X-%X-%X-%X-%X", b[0:4], b[4:6], b[6:8], b[8:10], b[10:])
 
 	return
+}*/
+
+const letterBytes = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"
+const (
+	letterIdxBits = 6                    // 6 bits to represent a letter index
+	letterIdxMask = 1<<letterIdxBits - 1 // All 1-bits, as many as letterIdxBits
+	letterIdxMax  = 63 / letterIdxBits   // # of letter indices fitting in 63 bits
+)
+
+// RandString from stackoverflow
+// https://stackoverflow.com/questions/22892120/how-to-generate-a-random-string-of-a-fixed-length-in-golang
+func RandString(n int) string {
+	b := make([]byte, n)
+	// A rand.Int63() generates 63 random bits, enough for letterIdxMax letters!
+	for i, cache, remain := n-1, rand.Int63(), letterIdxMax; i >= 0; {
+		if remain == 0 {
+			cache, remain = rand.Int63(), letterIdxMax
+		}
+		if idx := int(cache & letterIdxMask); idx < len(letterBytes) {
+			b[i] = letterBytes[idx]
+			i--
+		}
+		cache >>= letterIdxBits
+		remain--
+	}
+
+	return string(b)
 }

+ 3 - 0
go/src/flowserver/cmd/flowserver/main.go

@@ -4,6 +4,7 @@ import (
 	"flow"
 	"flowserver"
 	"fmt"
+	"log"
 	"math/rand"
 	"strings"
 	"time"
@@ -14,6 +15,8 @@ import (
 func main() {
 	prettylog.Global()
 
+	log.Println("Running version:", flowserver.Version)
+
 	flow.Register("str.cat", strCat)
 	flow.Register("str.reverse", strReverse)
 	flow.Register("str.split", strings.Split)

+ 1 - 1
go/src/flowserver/flowserver.go

@@ -14,7 +14,7 @@ import (
 	"github.com/gohxs/webu/chain"
 )
 
-//go:generate go get dev.hexasoftware.com/hxs/genversion
+//go:generate go get github.com/gohxs/genversion
 //go:generate genversion -package flowserver -out version.go
 //
 

+ 0 - 29
go/src/flowserver/util.go

@@ -1,30 +1 @@
 package flowserver
-
-import "math/rand"
-
-const letterBytes = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"
-const (
-	letterIdxBits = 6                    // 6 bits to represent a letter index
-	letterIdxMask = 1<<letterIdxBits - 1 // All 1-bits, as many as letterIdxBits
-	letterIdxMax  = 63 / letterIdxBits   // # of letter indices fitting in 63 bits
-)
-
-// RandString from stackoverflow
-// https://stackoverflow.com/questions/22892120/how-to-generate-a-random-string-of-a-fixed-length-in-golang
-func RandString(n int) string {
-	b := make([]byte, n)
-	// A rand.Int63() generates 63 random bits, enough for letterIdxMax letters!
-	for i, cache, remain := n-1, rand.Int63(), letterIdxMax; i >= 0; {
-		if remain == 0 {
-			cache, remain = rand.Int63(), letterIdxMax
-		}
-		if idx := int(cache & letterIdxMask); idx < len(letterBytes) {
-			b[i] = letterBytes[idx]
-			i--
-		}
-		cache >>= letterIdxBits
-		remain--
-	}
-
-	return string(b)
-}

+ 6 - 0
go/src/flowserver/version.go

@@ -0,0 +1,6 @@
+package flowserver
+
+const (
+  //Version contains version of the package
+  Version = "0.1 - built: 2018-01-23 22:20:02 UTC"
+)