mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2024-12-24 10:48:53 +01:00
internal/shader: refactoring
This commit is contained in:
parent
dc1df824a5
commit
5aecd6762c
@ -1202,39 +1202,31 @@ func Fragment(position vec4, texCoord vec2, color vec4) vec4 {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestSyntaxAtan(t *testing.T) {
|
func TestSyntaxAtan(t *testing.T) {
|
||||||
// `atan` takes 1 argument.
|
cases := []struct {
|
||||||
if _, err := compileToIR([]byte(`package main
|
stmt string
|
||||||
|
err bool
|
||||||
|
}{
|
||||||
|
// `atan` takes 1 argument.
|
||||||
|
{stmt: "_ = atan(vec4(0))", err: false},
|
||||||
|
{stmt: "_ = atan(vec4(0), vec4(0))", err: true},
|
||||||
|
|
||||||
func Fragment(position vec4, texCoord vec2, color vec4) vec4 {
|
// `atan2` takes 2 arguments.
|
||||||
return atan(vec4(0))
|
{stmt: "_ = atan2(vec4(0))", err: true},
|
||||||
}
|
{stmt: "_ = atan2(vec4(0), vec4(0))", err: false},
|
||||||
`)); err != nil {
|
|
||||||
t.Error(err)
|
|
||||||
}
|
}
|
||||||
if _, err := compileToIR([]byte(`package main
|
|
||||||
|
for _, c := range cases {
|
||||||
|
_, err := compileToIR([]byte(fmt.Sprintf(`package main
|
||||||
|
|
||||||
func Fragment(position vec4, texCoord vec2, color vec4) vec4 {
|
func Fragment(position vec4, texCoord vec2, color vec4) vec4 {
|
||||||
return atan(vec4(0), vec4(0))
|
%s
|
||||||
}
|
return position
|
||||||
`)); err == nil {
|
}`, c.stmt)))
|
||||||
t.Errorf("error must be non-nil but was nil")
|
if err == nil && c.err {
|
||||||
}
|
t.Errorf("%s must return an error but does not", c.stmt)
|
||||||
// `atan2` takes 2 arguments.
|
} else if err != nil && !c.err {
|
||||||
if _, err := compileToIR([]byte(`package main
|
t.Errorf("%s must not return nil but returned %v", c.stmt, err)
|
||||||
|
}
|
||||||
func Fragment(position vec4, texCoord vec2, color vec4) vec4 {
|
|
||||||
return atan2(vec4(0))
|
|
||||||
}
|
|
||||||
`)); err == nil {
|
|
||||||
t.Errorf("error must be non-nil but was nil")
|
|
||||||
}
|
|
||||||
if _, err := compileToIR([]byte(`package main
|
|
||||||
|
|
||||||
func Fragment(position vec4, texCoord vec2, color vec4) vec4 {
|
|
||||||
return atan2(vec4(0), vec4(0))
|
|
||||||
}
|
|
||||||
`)); err != nil {
|
|
||||||
t.Error(err)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user