Switch from Asuka to MyGo, keeping the API client and the feature set: - servers: saved servers, passwordless and password login, proxy, self-signed certificates, per-server device tokens (Keystore), connect form, instance list sheet with switch/disconnect - sessions: virtualized list, search, new session, rename/archive/delete, running indicator, event stream keeps it live - chat: pushed window with system back bar, streaming Markdown via ui/markdown, reasoning and tool rows with image previews, footer menu (read aloud via a Kotlin TTS plugin, copy, fork), user message menu (copy, revert, fork), context usage ring and detail sheet, attachments (photos/files via the document picker), permissions - release builds allow plain http:// LAN servers (Go's net/http dials directly, no cleartext manifest needed) - a local fork of MyGo (third_party/mygo) lowers the Android host's minSdk to 24 (Android 7.0); Go 1.27.4 via mise Version 0.3.0.
48 lines
1.4 KiB
Go
48 lines
1.4 KiB
Go
package shader
|
|
|
|
import (
|
|
"math"
|
|
"testing"
|
|
|
|
"github.com/egoist/mygo/internal/shaderir"
|
|
"github.com/egoist/mygo/ui"
|
|
)
|
|
|
|
// Uniforms take numbers of any of Go's kinds, alone, in slices and in
|
|
// arrays, and integers keep their low 32 bits.
|
|
func TestSet(t *testing.T) {
|
|
f := math.Float32bits
|
|
for _, c := range []struct {
|
|
kind shaderir.BasicType
|
|
n int
|
|
v any
|
|
want []uint32
|
|
}{
|
|
{shaderir.Float, 9, [9]float32{1, 2, 3, 4, 5, 6, 7, 8, 9}, []uint32{f(1), f(2), f(3), f(4), f(5), f(6), f(7), f(8), f(9)}},
|
|
{shaderir.Float, 4, [4]float64{0.5, 1, 2, 3}, []uint32{f(0.5), f(1), f(2), f(3)}},
|
|
{shaderir.Int, 2, [2]int{-1, 7}, []uint32{0xFFFFFFFF, 7}},
|
|
{shaderir.Uint, 1, int64(-1), []uint32{0xFFFFFFFF}},
|
|
{shaderir.Uint, 1, uint32(0x9E3779B9), []uint32{0x9E3779B9}},
|
|
{shaderir.Int, 1, uint32(0xFFFFFFFF), []uint32{0xFFFFFFFF}},
|
|
{shaderir.Bool, 3, []bool{true, false, true}, []uint32{1, 0, 1}},
|
|
{shaderir.Uint, 2, []uint8{3, 255}, []uint32{3, 255}},
|
|
{shaderir.Float, 1, 3, []uint32{f(3)}},
|
|
{shaderir.Float, 4, ui.Color{R: 255, A: 255}, []uint32{f(1), 0, 0, f(1)}},
|
|
} {
|
|
lanes := make([]uint32, c.n)
|
|
set(lanes, c.kind, "X", c.v)
|
|
for i := range c.want {
|
|
if lanes[i] != c.want[i] {
|
|
t.Errorf("%T %v: lanes %#x, want %#x", c.v, c.v, lanes, c.want)
|
|
break
|
|
}
|
|
}
|
|
}
|
|
defer func() {
|
|
if recover() == nil {
|
|
t.Error("a string set a uniform")
|
|
}
|
|
}()
|
|
set(make([]uint32, 1), shaderir.Float, "X", "1")
|
|
}
|