ebiten: add more tests

Updates #1963
This commit is contained in:
Hajime Hoshi 2022-01-17 20:53:58 +09:00
parent 4940159e5b
commit 406b8a4a08

View File

@ -1464,6 +1464,42 @@ func Fragment(position vec4, texCoord vec2, color vec4) vec4 {
func TestShaderOperatorVecAndNumber(t *testing.T) {
if _, err := ebiten.NewShader([]byte(`package main
func Fragment(position vec4, texCoord vec2, color vec4) vec4 {
a := vec2(1) + 2
return a.xxyy
}`)); err != nil {
t.Error(err)
}
if _, err := ebiten.NewShader([]byte(`package main
func Fragment(position vec4, texCoord vec2, color vec4) vec4 {
a := vec2(1) + 2.1
return a.xxyy
}`)); err != nil {
t.Error(err)
}
if _, err := ebiten.NewShader([]byte(`package main
func Fragment(position vec4, texCoord vec2, color vec4) vec4 {
a := vec2(1) % 2
return a.xxyy
}`)); err == nil {
t.Errorf("error must be non-nil but was nil")
}
if _, err := ebiten.NewShader([]byte(`package main
func Fragment(position vec4, texCoord vec2, color vec4) vec4 {
a := vec2(1) % 2.1
return a.xxyy
}`)); err == nil {
t.Errorf("error must be non-nil but was nil")
}
if _, err := ebiten.NewShader([]byte(`package main
func Fragment(position vec4, texCoord vec2, color vec4) vec4 {
a := vec2(1)
a += 2