From 7a06ae45306bc72c196bc069d6efd66f41d72261 Mon Sep 17 00:00:00 2001 From: Hajime Hoshi Date: Sat, 12 Sep 2020 20:16:03 +0900 Subject: [PATCH] ebiten: Add shader tests --- shader_test.go | 47 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) diff --git a/shader_test.go b/shader_test.go index df59a76a6..c2b8f4400 100644 --- a/shader_test.go +++ b/shader_test.go @@ -372,3 +372,50 @@ func Fragment(position vec4, texCoord vec2, color vec4) vec4 { t.Errorf("error must be non-nil but was nil") } } + +func TestShaderUnspportedSyntax(t *testing.T) { + if _, err := NewShader([]byte(`package main + +func Fragment(position vec4, texCoord vec2, color vec4) vec4 { + x := func() { + } + _ = x + return vec4(0) +} +`)); err == nil { + t.Errorf("error must be non-nil but was nil") + } + + if _, err := NewShader([]byte(`package main + +func Fragment(position vec4, texCoord vec2, color vec4) vec4 { + go func() { + }() + return vec4(0) +} +`)); err == nil { + t.Errorf("error must be non-nil but was nil") + } + + if _, err := NewShader([]byte(`package main + +func Fragment(position vec4, texCoord vec2, color vec4) vec4 { + ch := make(chan int) + _ = ch + return vec4(0) +} +`)); err == nil { + t.Errorf("error must be non-nil but was nil") + } + + if _, err := NewShader([]byte(`package main + +func Fragment(position vec4, texCoord vec2, color vec4) vec4 { + x := 1i + _ = x + return vec4(0) +} +`)); err == nil { + t.Errorf("error must be non-nil but was nil") + } +}