I can set_attr

This commit is contained in:
2020-11-20 20:14:53 +01:00
parent 0e945fe0fd
commit bc747f89a1
2 changed files with 15 additions and 3 deletions
-3
View File
@@ -691,9 +691,6 @@ class Sheerka(Concept):
return None return None
return new_instances(concept) if return_new else concept return new_instances(concept) if return_new else concept
def fast_get_by_name(self, name):
return self.cache_manager.get(self.CONCEPTS_BY_NAME_ENTRY, name)
def has_id(self, concept_id): def has_id(self, concept_id):
""" """
Returns True if a concept with this id exists in cache Returns True if a concept with this id exists in cache
+15
View File
@@ -1163,6 +1163,21 @@ as:
assert len(res) == 1 assert len(res) == 1
assert res[0].status assert res[0].status
def test_i_can_set_attribute(self):
init = [
"def concept size",
"def concept little",
"def concept house",
"def concept little x as set_attr(x, size, little) ret x",
]
sheerka = self.init_scenario(init)
res = sheerka.evaluate_user_input("eval little house")
assert len(res) == 1
assert res[0].status
assert sheerka.isinstance(res[0].body, "house")
assert sheerka.get_attr(res[0].body, sheerka.new("size")) == sheerka.new("little")
class TestSheerkaNonRegFile(TestUsingFileBasedSheerka): class TestSheerkaNonRegFile(TestUsingFileBasedSheerka):
def test_i_can_def_several_concepts(self): def test_i_can_def_several_concepts(self):