float_publication_test.py (2175B)
1 #!/usr/bin/env python3 2 """Closed binary64 cohort identity and publisher checks.""" 3 import unittest 4 from pathlib import Path 5 from native_library_migration import BINARY64_SUPPORT, alias 6 from repair_support_fixture import add_binary64_support, updated_module_rows 7 8 9 class PublicationTests(unittest.TestCase): 10 def setUp(self): 11 self.candidates = {alias(name): (dict(legacy=name, path=path), b'!export *\n') 12 for name, path in BINARY64_SUPPORT.items()} 13 14 def test_complete_cohort(self): 15 rows, declarations = add_binary64_support([], self.candidates, []) 16 self.assertEqual(len(rows), 13) 17 self.assertEqual(len(declarations), 13) 18 self.assertEqual(updated_module_rows(rows, self.candidates), rows) 19 self.assertTrue(all(Path(path).is_file() for path in BINARY64_SUPPORT.values())) 20 workspace = dict(row.split('\t') for row in Path('tricu.workspace').read_text().splitlines()[1:]) 21 for name, path in BINARY64_SUPPORT.items():self.assertEqual(workspace[alias(name)], path) 22 23 def test_missing_or_changed_provider(self): 24 for name in self.candidates: 25 bad = dict(self.candidates);del bad[name] 26 with self.assertRaises(ValueError):add_binary64_support([], bad, []) 27 record, payload = self.candidates[name] 28 for field in ['legacy', 'path']: 29 bad = dict(self.candidates);bad[name] = (dict(record, **{field: 'wrong'}), payload) 30 with self.assertRaises(ValueError):add_binary64_support([], bad, []) 31 32 def test_ownership(self): 33 for name, path in BINARY64_SUPPORT.items(): 34 for row in [['module',name,alias(name),'lib/other.tri','source'], 35 ['module','other','other',path,'source']]: 36 with self.assertRaises(ValueError):add_binary64_support([], self.candidates, [row]) 37 with self.assertRaises(ValueError):add_binary64_support(['\t'.join(row)], self.candidates, []) 38 39 def test_ordinary_membership_is_closed(self): 40 with self.assertRaises(ValueError):updated_module_rows([], self.candidates) 41 42 43 if __name__ == '__main__':unittest.main()