added a test for mirrored studs

Mon, 24 Jun 2019 00:51:04 +0300

author
Teemu Piippo <teemu@hecknology.net>
date
Mon, 24 Jun 2019 00:51:04 +0300
changeset 83
bd840d5dc8d8
parent 82
75b5241a35ec
child 84
55d52e25267f

added a test for mirrored studs

tests/subfiles.py file | annotate | diff | comparison | revisions
--- a/tests/subfiles.py	Mon Jun 24 00:38:18 2019 +0300
+++ b/tests/subfiles.py	Mon Jun 24 00:51:04 2019 +0300
@@ -278,11 +278,32 @@
                     )
                     break
 
+@problem_type('mirrored-studs',
+    severity = 'warning',
+    message = lambda primitive: str.format(
+        '"{primitive}" should not be mirrored',
+        primitive = primitive,
+    )
+)
+def mirrored_studs_test(model):
+    for subfile_reference in model.subfile_references:
+        # Test whether any stud subfile is mirrored.
+        # A subfile is mirrored if its determinant is negative.
+        if subfile_reference.subfile_path.startswith('stu') \
+        and subfile_reference.subfile_path != 'stud4.dat' \
+        and subfile_reference.matrix.determinant() < 0:
+            yield report_problem(
+                'mirrored-studs',
+                bad_object = subfile_reference,
+                primitive = subfile_reference.subfile_path,
+            )
+
 manifest = {
     'tests': [
         determinant_test,
         scaling_legality_test,
         dependent_subfile_tests,
         category_test,
+        mirrored_studs_test,
     ],
 }

mercurial