Pin feature ordering to vanilla runtime

This commit is contained in:
Daniar Mannanov 2026-08-11 09:29:17 +03:00
parent a73b689449
commit e9fe526300
5 changed files with 264 additions and 1 deletions

View file

@ -1,6 +1,9 @@
package worldgen
import "testing"
import (
"reflect"
"testing"
)
func TestFeatureDatapackLoadsAndLinks(t *testing.T) {
set, err := LoadFeatureSet()
@ -42,3 +45,38 @@ func TestFeatureDatapackLoadsAndLinks(t *testing.T) {
t.Fatalf("spring lava placement = %+v, err=%v", lavaPlan, err)
}
}
func TestFeatureStepsAgainstVanillaRuntimeVectors(t *testing.T) {
set := &FeatureSet{Biomes: map[string]BiomeGeneration{
"a": {Features: [][]string{{"f1"}, {"f3", "f4"}}},
"b": {Features: [][]string{{"f2", "f1"}, {"f5", "f4"}}},
}}
for _, test := range []struct {
name string
order []string
want [][]string
}{
{"ab", []string{"a", "b"}, [][]string{{"f2", "f1"}, {"f5", "f3", "f4"}}},
{"ba", []string{"b", "a"}, [][]string{{"f2", "f1"}, {"f3", "f5", "f4"}}},
} {
t.Run(test.name, func(t *testing.T) {
got, err := set.FeatureSteps(test.order)
if err != nil {
t.Fatal(err)
}
if !reflect.DeepEqual(got, test.want) {
t.Fatalf("steps = %v, want %v", got, test.want)
}
})
}
}
func TestFeatureStepsRejectsCycles(t *testing.T) {
set := &FeatureSet{Biomes: map[string]BiomeGeneration{
"a": {Features: [][]string{{"f1", "f2"}}},
"b": {Features: [][]string{{"f2", "f1"}}},
}}
if _, err := set.FeatureSteps([]string{"a", "b"}); err == nil {
t.Fatal("cyclic feature order succeeded")
}
}