def test_attribute_entity(): assert is_satisfiable( BASE_PROGRAMS + ["entity(mark,root,0).", "attribute((mark,type),0,bar)."] ) assert not is_satisfiable( BASE_PROGRAMS + ["entity(invalid,root,0).", "attribute((mark,type),0,bar)."] )
def test_domain_invlid(): assert not is_satisfiable(BASE_PROGRAMS + ["attribute((mark,type),0,invalid)."]) assert not is_satisfiable(BASE_PROGRAMS + ["attribute((scale,type),0,invalid)."]) assert not is_satisfiable(BASE_PROGRAMS + ["attribute((scale,channel),0,invalid)."]) assert not is_satisfiable( BASE_PROGRAMS + ["attribute((encoding,channel),0,invalid)."] )
def test_duplicate_attribute(): assert is_satisfiable( BASE_PROGRAMS + ["attribute((mark,type),0,bar).", "attribute((mark,type),1,line)."] ) assert not is_satisfiable( BASE_PROGRAMS + ["attribute((mark,type),0,bar).", "attribute((mark,type),0,line)."] )
def test_text_mark_without_text_channel(): b = hard.blocks["text_mark_without_text_channel"] assert isinstance(b, Block) p = helpers.program + b.program assert is_satisfiable(p + """ attribute(mark_type,m1,text). entity(encoding,m1,e1). attribute(channel,e1,text). :- violation(_). """) assert is_satisfiable(p + """ attribute(mark_type,m1,text). entity(encoding,m1,e1). attribute(channel,e1,x). entity(encoding,m1,e2). attribute(channel,e2,text). :- violation(_). """) assert not is_satisfiable(p + """ attribute(mark_type,m1,text). entity(encoding,m1,e1). attribute(channel,e1,x). entity(encoding,m1,e2). attribute(channel,e2,y). :- violation(_). """) assert not is_satisfiable(p + """ attribute(mark_type,m1,text). entity(encoding,m1,e1). attribute(channel,e1,x). entity(encoding,m1,e2). attribute(channel,e2,y). attribute(channel,e3,text). :- violation(_). """)
def test_domain_valid(): assert is_satisfiable(BASE_PROGRAMS + ["attribute((mark,type),0,bar)."]) assert is_satisfiable(BASE_PROGRAMS + ["attribute((scale,type),0,linear)."]) assert is_satisfiable(BASE_PROGRAMS + ["attribute((scale,channel),0,x)."]) assert is_satisfiable(BASE_PROGRAMS + ["attribute((encoding,channel),0,x)."])
def test_fields(): assert is_satisfiable( BASE_PROGRAMS + ["attribute((field,name),0,foo).", "attribute((encoding,field),1,foo)."] ) assert not is_satisfiable(BASE_PROGRAMS + ["attribute((encoding,field),0,foo)."])