示例#1
0
 def test_marking_equality(self):
     test_marking = cfc.Marking()
     test_marking.produce_token('p1')
     test_marking.produce_token('p2')
     test_marking2 = cfc.Marking()
     test_marking2.produce_token('p2')
     test_marking2.produce_token('p1')
     self.assertEquals(test_marking, test_marking2)
示例#2
0
 def test_trim_path_buffer(self):
     checker = cfc.LogChecker(cfc.Net(), [])
     good_marking = cfc.Marking()
     bad_marking = cfc.Marking()
     duplicate_marking = cfc.Marking()
     good_marking.tokens = ['p1', 'p2']
     duplicate_marking.tokens = ['p1', 'p2']
     bad_marking.tokens = ['p3']
     bad_marking.missing_tokens = ['p4']
     checker.path_buffer = [good_marking, bad_marking, duplicate_marking]
     checker.trim_path_buffer()
     self.assertEquals(len(checker.path_buffer), 1)
     self.assertEquals(['p1', 'p2'], checker.path_buffer[0].tokens)
示例#3
0
 def test_keep_least_divergent_markings(self):
     checker = cfc.LogChecker(cfc.Net(), [])
     best_marking = cfc.Marking()
     bad_marking1 = cfc.Marking()
     bad_marking2 = cfc.Marking()
     best_marking.tokens = ['p1']
     bad_marking1.tokens = ['p2']
     bad_marking2.tokens = ['p2']
     best_marking.missing_tokens = ['p4']
     bad_marking1.missing_tokens = ['p4', 'p5']
     bad_marking2.missing_tokens = ['p4', 'p5', 'p6']
     checker.path_buffer = [best_marking, bad_marking1, bad_marking2]
     checker.keep_least_divergent_markings()
     self.assertEquals(len(checker.path_buffer), 1)
     self.assertEquals(['p1'], checker.path_buffer[0].tokens)
示例#4
0
 def test_fire_transition_by_name_multiple_illegal_options(self):
     test_net = cfc.Net()
     test_net.add_transition('t2',
                             'sample transition',
                             input_places=['p1', 'p2'],
                             output_places=['p6'])
     test_net.add_transition('t1',
                             'sample transition',
                             input_places=['p1', 'p2', 'p3'],
                             output_places=['p5'])
     test_net.add_transition('t3',
                             'sample transition',
                             input_places=['p4'],
                             output_places=['p7'])
     test_net.add_transition('t4',
                             'different transition',
                             input_places=['p1', 'p3'],
                             output_places=['p8'])
     test_marking = cfc.Marking()
     test_marking.produce_token('p1')
     test_marking.produce_token('p3')
     test_net.fire_transition_by_name('sample transition', test_marking)
     self.assertIn('p5', test_marking.tokens)
     self.assertNotIn('p6', test_marking.tokens)
     self.assertNotIn('p7', test_marking.tokens)
     self.assertNotIn('p8', test_marking.tokens)
示例#5
0
 def test_resolve_expected_final_marking(self):
     checker = cfc.LogChecker(cfc.Net(), [])
     marking = cfc.Marking()
     marking.tokens = ['p1']
     checker.path_buffer = [marking, marking]
     output = checker.resolve_expected_final_marking(['p1'])
     self.assertEquals(len(output.tokens), 0)
示例#6
0
 def test_delete_dupllicate_markings(self):
     checker = cfc.LogChecker(cfc.Net(), [])
     marking = cfc.Marking()
     marking.tokens = ['p1']
     checker.path_buffer = [marking, marking, marking]
     checker.delete_duplicate_markings()
     self.assertEquals(len(checker.path_buffer), 1)
示例#7
0
 def test_test_transition(self):
     test_net = cfc.Net()
     test_net.add_transition('t1',
                             'sample transition',
                             input_places=['p1'],
                             output_places=['p2'])
     test_marking = cfc.Marking()
     result = test_net.test_transition('t1', test_marking)
     self.assertEquals(1, result)
示例#8
0
 def test_fire_transition_by_name_single_option(self):
     test_net = cfc.Net()
     test_net.add_transition('t1',
                             'sample transition',
                             input_places=['p1'],
                             output_places=['p2'])
     test_marking = cfc.Marking()
     test_marking.produce_token('p1')
     test_net.fire_transition_by_name('sample transition', test_marking)
     self.assertIn('p2', test_marking.tokens)
示例#9
0
 def test_fire_with_missing(self):
     test_net = cfc.Net()
     test_net.add_transition('t1',
                             'sample transition',
                             input_places=['p1'],
                             output_places=['p2'])
     test_marking = cfc.Marking()
     test_net.fire_transition('t1', test_marking)
     self.assertIn('p2', test_marking.tokens)
     self.assertIn('p1', test_marking.missing_tokens)
示例#10
0
 def test_fire_transition_by_name_multiple_legal_options(self):
     test_net = cfc.Net()
     test_net.add_transition('t1', 'sample transition', input_places=['p1'])
     test_net.add_transition('t2',
                             'sample transition',
                             input_places=['p1', 'p2'])
     test_net.add_transition('t3', 'sample transition', input_places=['p3'])
     test_net.add_transition('t4',
                             'different transition',
                             input_places=['p1', 'p2'],
                             output_places=['p8'])
     test_marking = cfc.Marking()
     test_marking.produce_token('p1')
     test_marking.produce_token('p2')
     with self.assertRaises(cfc.MultiPathError) as context:
         test_net.fire_transition_by_name('sample transition', test_marking)
         self.assertTrue(
             context.possible_paths == ['t1', 't2'],
             msg="found multiple fireable transitions: ['t1', 't2']")
示例#11
0
 def test_consume_token(self):
     test_marking = cfc.Marking()
     test_marking.produce_token('p1')
     test_marking.consume_token('p1')
     self.assertNotIn('p1', test_marking.tokens)
示例#12
0
 def test_produce_token(self):
     test_marking = cfc.Marking()
     test_marking.produce_token('p1')
     self.assertIn('p1', test_marking.tokens)
示例#13
0
 def test_has_token(self):
     test_marking = cfc.Marking()
     test_marking.produce_token('p1')
     self.assertTrue(test_marking.has_token('p1'))