tests/mirrored-studs.py

Mon, 24 Jun 2019 10:16:36 +0300

author
Teemu Piippo <teemu@hecknology.net>
date
Mon, 24 Jun 2019 10:16:36 +0300
changeset 90
6ae063fd27dc
parent 89
d2b277cb948e
permissions
-rw-r--r--

fixed the collinear test for polygons with identical vertices

89
d2b277cb948e split more tests into new files
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
1 from testsuite import problem_type, report_problem
d2b277cb948e split more tests into new files
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
2 import linetypes
d2b277cb948e split more tests into new files
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
3 from librarystandards import library_standards
d2b277cb948e split more tests into new files
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
4
d2b277cb948e split more tests into new files
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
5 @problem_type('mirrored-studs',
d2b277cb948e split more tests into new files
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
6 severity = 'warning',
d2b277cb948e split more tests into new files
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
7 message = lambda primitive: str.format(
d2b277cb948e split more tests into new files
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
8 '"{primitive}" should not be mirrored',
d2b277cb948e split more tests into new files
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
9 primitive = primitive,
d2b277cb948e split more tests into new files
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
10 )
d2b277cb948e split more tests into new files
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
11 )
d2b277cb948e split more tests into new files
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
12 def mirrored_studs_test(model):
d2b277cb948e split more tests into new files
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
13 for subfile_reference in model.subfile_references:
d2b277cb948e split more tests into new files
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
14 # Test whether any stud subfile is mirrored.
d2b277cb948e split more tests into new files
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
15 # A subfile is mirrored if its determinant is negative.
d2b277cb948e split more tests into new files
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
16 if subfile_reference.subfile_path.startswith('stu') \
d2b277cb948e split more tests into new files
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
17 and subfile_reference.subfile_path != 'stud4.dat' \
d2b277cb948e split more tests into new files
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
18 and subfile_reference.matrix.determinant() < 0:
d2b277cb948e split more tests into new files
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
19 yield report_problem(
d2b277cb948e split more tests into new files
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
20 'mirrored-studs',
d2b277cb948e split more tests into new files
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
21 bad_object = subfile_reference,
d2b277cb948e split more tests into new files
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
22 primitive = subfile_reference.subfile_path,
d2b277cb948e split more tests into new files
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
23 )
d2b277cb948e split more tests into new files
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
24
d2b277cb948e split more tests into new files
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
25 manifest = {'tests': [mirrored_studs_test]}

mercurial