示例#1
0
func TestInvalidRuleNb(t *testing.T) {
	defer func() {
		if err := recover(); err == nil {
			t.Errorf("expected panic, nothing happened")
		}
	}()

	p := New()
	p.Add(sequential.New([]int{1}), 0)
}
示例#2
0
文件: main.go 项目: TeddyRilliot/list
func main() {
	seq := sequential.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())
		}
	}
}
示例#3
0
文件: main.go 项目: TeddyRilliot/list
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())
	}
}
示例#4
0
func TestProgramRule1x(t *testing.T) {
	p := New()
	p.Add(sequential.New([]int{1, 2, 3}), 1)

	exp := []interface{}{1, 2, 3, 1, 2, 3, 1, 2, 3}

	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)
		}
	}
}
示例#5
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)
		}
	}
}