Ejemplo n.º 1
0
func main() {
	seq := random.New(items)

	for l := 0; l < 3; l++ {
		fmt.Println("Loop ", l)
		for i := 1; i <= len(items); i++ {
			fmt.Printf("\t%v\n", seq.Next())
		}
	}
}
Ejemplo n.º 2
0
func main() {
	seq := sequential.New([]int{1, 2, 3})
	rnd := random.New([]string{"a", "b", "c"})

	prog := program.New()
	prog.Add(seq, 2)
	prog.Add(rnd, 2)

	for i := 0; i < 12; i++ {
		fmt.Printf("%v ", prog.Next())
	}
}
Ejemplo n.º 3
0
func TestProgramRules1x(t *testing.T) {
	p := New()
	p.Add(sequential.New([]int{1, 2, 3}), 1)
	p.Add(random.New([]string{"a", "b", "c"}), 1)

	rand.Seed(1)
	exp := []interface{}{1, "b", 2, "c", 3, "a", 1, "a", 2, "b", 3, "c", 1, "c", 2, "b"}

	for i := 0; i < len(exp); i++ {
		v := p.Next()
		t.Logf("Loop %d, got %v", i, v)

		if v != exp[i] {
			t.Errorf("Expecting %v, got %v", exp[i], v)
		}
	}
}