WIP components (as built)

This commit is contained in:
ZacharyZhang-NY committed 2026-10-05 15:51:57 -04:00
1 parent a22527cceb
commit ade219840e
70 files changed
+2610 -235

No files matched your search

+44
View File
@@ -1,6 +1,8 @@
package mujica
import (
"fmt"
"math"
"testing"
"github.com/egoist/mygo/ui"
@@ -67,3 +69,45 @@ func TestParameterPanelSnapshot(t *testing.T) {
ui.Column(c).Padding(16).Children(func() { ParameterPanel(c, paramSample(&temp, &topP)) })
})
}
func TestParameterPanelRejectsNonFiniteAndOutOfRange(t *testing.T) {
for _, v := range []float64{math.NaN(), math.Inf(1), -1, 3} {
t.Run(fmt.Sprint(v), func(t *testing.T) {
defer func() {
if recover() == nil {
t.Fatal("invalid parameter value accepted")
}
}()
ui.NewTester(func(c *ui.Context) {
Use(c, Settings{})
ParameterPanel(c, []ModelParam{{Label: "Temperature", Value: &v, Min: 0, Max: 2, Step: 0.1, Default: 1}})
}, 400, 300)
})
}
}
func TestParameterPanelRequiresDefaultOnStepGrid(t *testing.T) {
v := 0.9
defer func() {
if recover() == nil {
t.Fatal("off-grid default accepted")
}
}()
ui.NewTester(func(c *ui.Context) {
Use(c, Settings{})
ParameterPanel(c, []ModelParam{{Label: "Temperature", Value: &v, Min: 0, Max: 2, Step: 0.1, Default: 0.95}})
}, 400, 300)
}
func TestParameterPanelRequiresValueOnStepGrid(t *testing.T) {
v := 0.5
defer func() {
if recover() == nil {
t.Fatal("off-grid value accepted")
}
}()
ui.NewTester(func(c *ui.Context) {
Use(c, Settings{})
ParameterPanel(c, []ModelParam{{Label: "Temperature", Value: &v, Min: 0, Max: 1, Step: 0.2, Default: 0.4}})
}, 400, 300)
}