WIP components (as built)
This commit is contained in:
98 files changed
+2746
-1204
No files matched your search
@@ -1,6 +1,7 @@
|
||||
package mujica
|
||||
|
||||
import (
|
||||
"math"
|
||||
"testing"
|
||||
|
||||
"github.com/egoist/mygo/ui"
|
||||
@@ -43,3 +44,35 @@ func TestViolinPlotSnapshot(t *testing.T) {
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
func TestViolinPlotFiniteBandwidthAndFlatShape(t *testing.T) {
|
||||
charts2MustPanic(t, func(c *ui.Context) {
|
||||
ViolinPlot(c, []BoxGroup{{Name: "Flat", Values: []float64{4, 4}}}, ViolinPlotOptions{Frame: ChartFrame{Label: "Flat"}, Bandwidth: math.NaN()})
|
||||
})
|
||||
}
|
||||
|
||||
func TestViolinPlotLargeDataAndDisabled(t *testing.T) {
|
||||
values := make([]float64, 100_000)
|
||||
for i := range values {
|
||||
values[i] = float64(i % 100)
|
||||
}
|
||||
groups := []BoxGroup{{Name: "Sample", Values: values}}
|
||||
h := &chartHarness{build: func(c *ui.Context) ChartResult {
|
||||
return ViolinPlot(c, groups, ViolinPlotOptions{Frame: ChartFrame{Label: "Large violin"}})
|
||||
}}
|
||||
tt := ui.NewTester(h.view, 520, 420)
|
||||
tabTo(t, tt, "Large violin")
|
||||
tt.Key(0, ui.KeyRight)
|
||||
if chartReadout(tt) != "Sample · median 49.5 · quartiles 24.75–74.25 · 100000 values" {
|
||||
t.Fatalf("large readout %q", chartReadout(tt))
|
||||
}
|
||||
shown := ui.Local(h.res.Element, "mujica.violin.visible", func() []int { return nil })
|
||||
if len(*shown) != 1 {
|
||||
t.Fatalf("built %d violins", len(*shown))
|
||||
}
|
||||
h.disabled = true
|
||||
tt.Frame()
|
||||
if h.res.Point != -1 {
|
||||
t.Fatalf("disabled violin %d", h.res.Point)
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user