P08-03: 配置の通常操作受入
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
#!/usr/bin/env python3
|
||||
"""Whole-checker positive and semantic corruption tests; synthetic proof only."""
|
||||
import copy
|
||||
import re
|
||||
import importlib.util
|
||||
import json
|
||||
from pathlib import Path
|
||||
@@ -27,6 +28,52 @@ C = module('placement_checker_test', ROOT/'tools/check_p08_normal_placement_evid
|
||||
F = module('placement_synthetic_fixture', ROOT/'tests/fixtures/p08-03/checker_fixture.py')
|
||||
D = module('placement_collector_test', ROOT/'tools/run_p08_normal_placement.py')
|
||||
|
||||
def check_passive_endpoint_types(passive, placement):
|
||||
"""Focused source contract; native parsing and startup remain pending."""
|
||||
if not re.search(r'^extends RefCounted\s*$', placement, re.M):
|
||||
raise ValueError('placement inheritance')
|
||||
observer = passive.split('class InputObserver extends Node:', 1)[1].split('\nfunc ', 1)[0]
|
||||
field = re.search(r'^\tvar endpoint:\s*(\w+)', observer, re.M)
|
||||
if not field or field[1] not in ('RefCounted', 'Object', 'Variant'):
|
||||
raise ValueError('incompatible RefCounted endpoint')
|
||||
if 'endpoint != null' not in observer:
|
||||
raise ValueError('missing null guard')
|
||||
if not re.search(r'input_observer\.endpoint\s*=\s*self', passive):
|
||||
raise ValueError('missing root endpoint')
|
||||
modal = passive.split('func button(', 1)[1].split('\nfunc ', 1)[0]
|
||||
if not re.search(r'input_observer\.endpoint\s*=\s*null', modal):
|
||||
raise ValueError('modal endpoint must remain null')
|
||||
if 'input_observer.queue_free()' not in modal or 'input_observer = old_observer' not in modal:
|
||||
raise ValueError('modal cleanup/restore')
|
||||
if 'null_modal_receipts_only' not in passive:
|
||||
raise ValueError('missing modal attribution')
|
||||
|
||||
|
||||
class PassiveTypingTests(unittest.TestCase):
|
||||
def setUp(self):
|
||||
self.passive = (ROOT/'tests/fixtures/p08-03/passive_placement.gd').read_text()
|
||||
self.placement = (ROOT/'tests/fixtures/p08-03/placement.gd').read_text()
|
||||
|
||||
def test_actual_fixture_types(self):
|
||||
check_passive_endpoint_types(self.passive, self.placement)
|
||||
|
||||
def test_node_endpoint_rejected(self):
|
||||
with self.assertRaisesRegex(ValueError, 'incompatible RefCounted'):
|
||||
check_passive_endpoint_types(self.passive.replace('endpoint: RefCounted', 'endpoint: Node'), self.placement)
|
||||
|
||||
def test_missing_guard_rejected(self):
|
||||
with self.assertRaisesRegex(ValueError, 'null guard'):
|
||||
check_passive_endpoint_types(self.passive.replace('endpoint != null', 'true'), self.placement)
|
||||
|
||||
def test_modal_dispatch_rejected(self):
|
||||
with self.assertRaisesRegex(ValueError, 'modal endpoint'):
|
||||
check_passive_endpoint_types(self.passive.replace('input_observer.endpoint = null', 'input_observer.endpoint = self'), self.placement)
|
||||
|
||||
def test_modal_cleanup_rejected(self):
|
||||
with self.assertRaisesRegex(ValueError, 'cleanup/restore'):
|
||||
check_passive_endpoint_types(self.passive.replace('input_observer.queue_free()', 'pass'), self.placement)
|
||||
|
||||
|
||||
class EvidenceTests(unittest.TestCase):
|
||||
def setUp(self):
|
||||
scratch = ROOT/'tests/fixtures/p08-03/.scratch'
|
||||
|
||||
Reference in New Issue
Block a user