def test_try_prove_diverge(): atoms = [I, K, B, C, W, S] max_atom_count = 3 max_steps = 20 with pomagma.util.in_temp_dir(): with open('source.facts', 'w') as f: f.write('# test terms') for term in iter_terms(atoms, max_atom_count): f.write('\n') f.write('EQUAL BOT {}'.format(print_term(term))) try_prove_diverge( 'source.facts', 'unproven.facts', 'theorems.facts', max_steps) with open('theorems.facts') as f: for line in f: line = line.split('#')[0].strip() if line.startswith('EQUAL BOT '): term = parse_term(line[len('EQUAL BOT '):]) with pytest.raises(Diverged): try_converge(term, max_steps) elif line.startswith('NLESS ') and line.endswith(' BOT'): term = parse_term(line[len('NLESS '): 1 - len(' BOT')]) with pytest.raises(Converged): try_converge(term, max_steps) elif line: raise ValueError('Bad line:\n{}'.format(line))
def assert_diverges(string): steps = 10 term = parse_term(string) with pytest.raises(Diverged): try_converge(term, steps)
def test_www_diverges(): WWW = (W, (W,), (W,),) assert converge_step(WWW) == WWW with pytest.raises(Diverged): try_converge(WWW, 1)