Beispiel #1
0
def test_bug_28():
	# This is (ab*)* and it caused some defects.
	abstar = FSM(
		alphabet = {'a', 'b'},
		states   = {0, 1},
		initial  = 0,
		finals   = {1},
		map = {
			0: {'a': 1},
			1: {'b': 1}
		}
	)
	assert abstar.accepts("a")
	assert not abstar.accepts("b")
	assert abstar.accepts("ab")
	assert abstar.accepts("abb")
	abstarstar = abstar.star()
	assert abstarstar.accepts("a")
	assert not abstarstar.accepts("b")
	assert abstarstar.accepts("ab")
	assert not abstar.star().accepts("bb")
Beispiel #2
0
def test_oblivion_crawl(a):
	# When crawling a new FSM, we should avoid generating an oblivion state.
	# `abc` has no oblivion state... all the results should not as well!
	abc = FSM(
		alphabet = {"a", "b", "c"},
		states = {0, 1, 2, 3},
		initial = 0,
		finals = {3},
		map = {
			0 : {"a" : 1},
			1 : {"b" : 2},
			2 : {"c" : 3},
		}
	)
	assert len((abc + abc).states) == 7
	assert len(abc.star().states) == 3
	assert len((abc * 3).states) == 10
	assert len(reversed(abc).states) == 4
	assert len((abc | abc).states) == 4
	assert len((abc & abc).states) == 4
	assert len((abc ^ abc).states) == 1
	assert len((abc - abc).states) == 1