class basic_test: def setUp(self): self.f_un = GRSpec(env_vars="x", sys_vars="y", env_init="x", env_prog="x", sys_init="y",sys_safety=["y -> X(!y)","!y -> X(y)"], sys_prog="y && x") self.dcounter = GRSpec(sys_vars={"y": (0,5)}, sys_init=["y=0"], sys_prog=["y=0", "y=5"]) def tearDown(self): self.f_un = None self.dcounter = None def test_check_syntax(self): assert gr1cint.check_syntax(REFERENCE_SPECFILE) assert not gr1cint.check_syntax("foo") def test_to_gr1c(self): assert gr1cint.check_syntax(self.f_un.to_gr1c() ) assert gr1cint.check_syntax(self.dcounter.to_gr1c() ) def test_check_realizable(self): assert not gr1cint.check_realizable(self.f_un) self.f_un.sys_safety = [] assert gr1cint.check_realizable(self.f_un) assert gr1cint.check_realizable(self.dcounter) def test_synthesize(self): self.f_un.sys_safety = [] # Make it realizable mach = gr1cint.synthesize(self.f_un) assert mach is not None assert len(mach.inputs) == 1 and mach.inputs.has_key("x") assert len(mach.outputs) == 1 and mach.outputs.has_key("y") mach = gr1cint.synthesize(self.dcounter) assert mach is not None assert len(mach.inputs) == 0 assert len(mach.outputs) == 1 and mach.outputs.has_key("y") assert len(mach.states) == 3
class basic_test: def setUp(self): self.f_un = GRSpec(env_vars="x", sys_vars="y", env_init="x", env_prog="x", sys_init="y",sys_safety=["y -> X(!y)","!y -> X(y)"], sys_prog="y && x") self.dcounter = GRSpec(sys_vars={"y": (0,5)}, sys_init=["y=0"], sys_prog=["y=0", "y=5"]) def tearDown(self): self.f_un = None self.dcounter = None def test_check_syntax(self): assert gr1cint.check_syntax(REFERENCE_SPECFILE) assert not gr1cint.check_syntax("foo") def test_to_gr1c(self): assert gr1cint.check_syntax(self.f_un.to_gr1c() ) assert gr1cint.check_syntax(self.dcounter.to_gr1c() ) def test_check_realizable(self): assert not gr1cint.check_realizable(self.f_un, init_option="ALL_ENV_EXIST_SYS_INIT") self.f_un.sys_safety = [] assert gr1cint.check_realizable(self.f_un, init_option="ALL_ENV_EXIST_SYS_INIT") assert gr1cint.check_realizable(self.f_un, init_option="ALL_INIT") assert gr1cint.check_realizable(self.dcounter, init_option="ALL_ENV_EXIST_SYS_INIT") self.dcounter.sys_init = [] assert gr1cint.check_realizable(self.dcounter, init_option="ALL_INIT") def test_synthesize(self): self.f_un.sys_safety = [] # Make it realizable mach = gr1cint.synthesize(self.f_un, init_option="ALL_ENV_EXIST_SYS_INIT") assert mach is not None assert len(mach.inputs) == 1 and mach.inputs.has_key("x") assert len(mach.outputs) == 1 and mach.outputs.has_key("y") mach = gr1cint.synthesize(self.dcounter, init_option="ALL_ENV_EXIST_SYS_INIT") assert mach is not None assert len(mach.inputs) == 0 assert len(mach.outputs) == 1 and mach.outputs.has_key("y") assert len(mach.states) == 3 # In the notation of gr1c SYSINIT: True;, so the strategy must # account for every initial state, i.e., for y=0, y=1, y=2, ... self.dcounter.sys_init = [] mach = gr1cint.synthesize(self.dcounter, init_option="ALL_INIT") assert mach is not None print mach assert len(mach.inputs) == 0 assert len(mach.outputs) == 1 and mach.outputs.has_key("y") assert len(mach.states) == 7