summaryrefslogtreecommitdiff
path: root/unittests
diff options
context:
space:
mode:
authorDylan Baker <dylan@pnwbakers.com>2016-06-10 14:06:11 -0700
committerDylan Baker <dylan@pnwbakers.com>2016-06-13 11:31:47 -0700
commit230fe96934233f764af1a2c732397f805f82a0d7 (patch)
tree66ceb70b1177c266fe08511a853d8544aa947b23 /unittests
parentc693dd0a7a52c9f02203637d5ec62ed8b68a08d9 (diff)
generators/modules: Add GLSL types representations
This adds a new module with glsl type representations. The immediate plan it to use these in the gen_vs_in_fp64 generator to reduce runtime by removing the need for the cols and rows functions, which are expensive. These may be applicable to other generators, but those will have to wait. Signed-off-by: Dylan Baker <dylanx.c.baker@intel.com> Reviewed-by: Andres Gomez <agomez@igalia.com>
Diffstat (limited to 'unittests')
-rw-r--r--unittests/generators/test_types.py79
1 files changed, 79 insertions, 0 deletions
diff --git a/unittests/generators/test_types.py b/unittests/generators/test_types.py
new file mode 100644
index 000000000..f60282c4e
--- /dev/null
+++ b/unittests/generators/test_types.py
@@ -0,0 +1,79 @@
+# encoding=utf-8
+# Copyright © 2016 Intel Corporation
+
+# Permission is hereby granted, free of charge, to any person obtaining a copy
+# of this software and associated documentation files (the "Software"), to deal
+# in the Software without restriction, including without limitation the rights
+# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+# copies of the Software, and to permit persons to whom the Software is
+# furnished to do so, subject to the following conditions:
+
+# The above copyright notice and this permission notice shall be included in
+# all copies or substantial portions of the Software.
+
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+# SOFTWARE.
+
+"""Tests from generated_tests/modules/types.py"""
+
+from __future__ import (
+ absolute_import, division, print_function, unicode_literals
+)
+import itertools
+import os
+import sys
+
+import nose.tools as nt
+
+from .. import utils
+
+# Add <piglit root>/generated_tests to the module path, this allows it to be
+# imported for testing.
+sys.path.insert(0, os.path.abspath(
+ os.path.join(os.path.dirname(__file__), '..', '..', 'generated_tests')))
+
+# pylint can't figure out the sys.path manipulation.
+from modules import types # pylint: disable=import-error
+
+
+@utils.nose.Skip(not __debug__, 'Test requires debug asserts')
+def test_container_is_type_assert():
+ """modules.types.Container: Only accept one of is_scalar or is_vector or is_matrix"""
+ for s, v, m in itertools.product([True, False], repeat=3):
+ # Don't test the valid case
+ if [s, v, m].count(True) == 0:
+ continue
+
+ with nt.assert_raises(AssertionError):
+ types.Container('foo', is_scalar=s, is_vector=v, is_matrix=m,
+ contains=types.FLOAT)
+
+
+def test_matrix_is_square():
+ """modules.types.Matrix.square: works for square matricies"""
+ for mat in [types.MAT2, types.DMAT3X3]:
+ nt.eq_(mat.square, True)
+
+
+def test_matrix_is_not_square():
+ """modules.types.Matrix.square: works for non-square matricies"""
+ nt.eq_(types.MAT2X4.square, False)
+
+
+@utils.nose.Skip(not __debug__, 'Test requires debug asserts')
+@nt.raises(AssertionError)
+def test_type_int_float_assert():
+ """modules.types.Type: only integer or floating can be passed."""
+ types.Type('foo', integer=True, floating=True, size=32)
+
+
+@utils.nose.Skip(not __debug__, 'Test requires debug asserts')
+@nt.raises(AssertionError)
+def test_type_float_signed_assert():
+ """modules.types.Type: floating types must be signed."""
+ types.Type('foo', floating=True, signed=False, size=32)