[Piglit] [PATCH 1/2] glslparsertest: Added some few more struct construction tests

Andres Gomez agomez at igalia.com
Fri Aug 5 14:43:24 UTC 2016


This set focus on checking invalid structs construction. Specifically,
adds a test to check that only implicit conversions are perform and
vector conversions of the type vec3 to vec2 through dropping the z
component are not allowed.
---
 tests/glslparsertest/glsl2/constructor-29.vert | 13 +++++++++++++
 tests/glslparsertest/glsl2/constructor-30.vert | 13 +++++++++++++
 tests/glslparsertest/glsl2/constructor-31.vert | 15 +++++++++++++++
 tests/glslparsertest/glsl2/constructor-32.vert | 15 +++++++++++++++
 tests/glslparsertest/glsl2/constructor-33.vert | 15 +++++++++++++++
 tests/glslparsertest/glsl2/constructor-34.vert | 15 +++++++++++++++
 6 files changed, 86 insertions(+)
 create mode 100644 tests/glslparsertest/glsl2/constructor-29.vert
 create mode 100644 tests/glslparsertest/glsl2/constructor-30.vert
 create mode 100644 tests/glslparsertest/glsl2/constructor-31.vert
 create mode 100644 tests/glslparsertest/glsl2/constructor-32.vert
 create mode 100644 tests/glslparsertest/glsl2/constructor-33.vert
 create mode 100644 tests/glslparsertest/glsl2/constructor-34.vert

diff --git a/tests/glslparsertest/glsl2/constructor-29.vert b/tests/glslparsertest/glsl2/constructor-29.vert
new file mode 100644
index 0000000..eecab51
--- /dev/null
+++ b/tests/glslparsertest/glsl2/constructor-29.vert
@@ -0,0 +1,13 @@
+// [config]
+// expect_result: fail
+// glsl_version: 1.20
+// [end config]
+
+/* FAIL */
+#version 120
+struct s { vec2 f; };
+
+void main()
+{
+    s t = s(vec3(1.0, 3.0, 0.0)); // Only Section 4.1.10 “Implicit Conversions.” are allowed
+}
diff --git a/tests/glslparsertest/glsl2/constructor-30.vert b/tests/glslparsertest/glsl2/constructor-30.vert
new file mode 100644
index 0000000..eecab51
--- /dev/null
+++ b/tests/glslparsertest/glsl2/constructor-30.vert
@@ -0,0 +1,13 @@
+// [config]
+// expect_result: fail
+// glsl_version: 1.20
+// [end config]
+
+/* FAIL */
+#version 120
+struct s { vec2 f; };
+
+void main()
+{
+    s t = s(vec3(1.0, 3.0, 0.0)); // Only Section 4.1.10 “Implicit Conversions.” are allowed
+}
diff --git a/tests/glslparsertest/glsl2/constructor-31.vert b/tests/glslparsertest/glsl2/constructor-31.vert
new file mode 100644
index 0000000..fafaf85
--- /dev/null
+++ b/tests/glslparsertest/glsl2/constructor-31.vert
@@ -0,0 +1,15 @@
+// [config]
+// expect_result: fail
+// glsl_version: 1.20
+// [end config]
+
+/* FAIL */
+#version 120
+struct s1 { float f; };
+
+struct s2 { s1 g; };
+
+void main()
+{
+    s2 t = s2(1); // Only Section 4.1.10 “Implicit Conversions.” are allowed
+}
diff --git a/tests/glslparsertest/glsl2/constructor-32.vert b/tests/glslparsertest/glsl2/constructor-32.vert
new file mode 100644
index 0000000..b27dcac
--- /dev/null
+++ b/tests/glslparsertest/glsl2/constructor-32.vert
@@ -0,0 +1,15 @@
+// [config]
+// expect_result: fail
+// glsl_version: 1.20
+// [end config]
+
+/* FAIL */
+#version 120
+struct s1 { float f; };
+
+struct s2 { s1 g; };
+
+void main()
+{
+    s1 t = s1(s1(1)); // Only Section 4.1.10 “Implicit Conversions.” are allowed
+}
diff --git a/tests/glslparsertest/glsl2/constructor-33.vert b/tests/glslparsertest/glsl2/constructor-33.vert
new file mode 100644
index 0000000..46add14
--- /dev/null
+++ b/tests/glslparsertest/glsl2/constructor-33.vert
@@ -0,0 +1,15 @@
+// [config]
+// expect_result: fail
+// glsl_version: 1.20
+// [end config]
+
+/* FAIL */
+#version 120
+struct s1 { float f; };
+
+struct s2 { s1 g; };
+
+void main()
+{
+    s2 t = s2(s2(s1(1))); // Only Section 4.1.10 “Implicit Conversions.” are allowed
+}
diff --git a/tests/glslparsertest/glsl2/constructor-34.vert b/tests/glslparsertest/glsl2/constructor-34.vert
new file mode 100644
index 0000000..46f1c27
--- /dev/null
+++ b/tests/glslparsertest/glsl2/constructor-34.vert
@@ -0,0 +1,15 @@
+// [config]
+// expect_result: pass
+// glsl_version: 1.20
+// [end config]
+
+/* PASS */
+#version 120
+struct s1 { float f; };
+
+struct s2 { s1 g; };
+
+void main()
+{
+    s2 t = s2(s1(1)); // an implicit conversion should happen here
+}
-- 
2.8.1



More information about the Piglit mailing list