# HG changeset patch
# User Teemu Piippo <teemu@hecknology.net>
# Date 1561281460 -10800
# Node ID 1970afe52da4460f79d030735b5b8d74c3f7b977
# Parent  d98502ae1f33cc9bd4b5a01b07d6a498c1f17488
added a test for unknown metacommands

diff -r d98502ae1f33 -r 1970afe52da4 tests/misc.py
--- a/tests/misc.py	Sun Jun 23 12:09:20 2019 +0300
+++ b/tests/misc.py	Sun Jun 23 12:17:40 2019 +0300
@@ -184,6 +184,32 @@
                 bad_object = model.body[index],
             )
 
+@problem_type('unknown-metacommand',
+    severity = 'hold',
+    message = lambda command_text: str.format(
+        'unknown or deprecated metacommand: {command_text}',
+        command_text = command_text,
+    )
+)
+def metacommands_test(model):
+    allowed_metacommand_patterns = [
+        r'^BFC (CLIP|NOCLIP|INVERTNEXT)$',
+        r'^\!TEXMAP (START|NEXT) .+',
+        r'^\!: .+',
+        r'^\!TEXMAP (FALLBACK|END)$',
+    ]
+    import re
+    for element in model.body[model.header_size:]:
+        if isinstance(element, linetypes.MetaCommand):
+            if element.text and not any(
+                re.match(pattern, element.text)
+                for pattern in allowed_metacommand_patterns
+            ):
+                yield report_problem('unknown-metacommand',
+                    bad_object = element,
+                    command_text = element.text,
+                )
+
 manifest = {
     'tests': [
         colours_test,
@@ -197,5 +223,6 @@
         colour_24_test,
         moved_to_with_extension_test,
         bfc_invertnext_not_on_subfile_test,
+        metacommands_test,
     ],
 }