I can manage infinite recursion when building concept
This commit is contained in:
@@ -43,11 +43,7 @@ class TestSheerkaNonRegMemory(TestUsingMemoryBasedSheerka):
|
||||
assert evaluated == simplec("one", 1)
|
||||
|
||||
def test_i_can_recognize_concept_with_concept_body(self):
|
||||
sheerka = self.get_sheerka()
|
||||
concept_one = Concept(name="one")
|
||||
concept_un = Concept(name="un", body="one")
|
||||
sheerka.test_only_add_in_cache(concept_one)
|
||||
sheerka.test_only_add_in_cache(concept_un)
|
||||
sheerka, context, concept_one, concept_un = self.init_concepts("one", Concept(name="un", body="one"))
|
||||
|
||||
res = sheerka.evaluate_user_input("un")
|
||||
return_value = res[0].value
|
||||
@@ -202,9 +198,10 @@ as:
|
||||
assert evaluated.get_value("a") == concept_foo
|
||||
|
||||
def test_i_can_recognize_concept_with_variable_and_python_as_body(self):
|
||||
sheerka = self.get_sheerka()
|
||||
hello_a = sheerka.test_only_add_in_cache(Concept(name="hello a", body="'hello ' + a").def_var("a"))
|
||||
sheerka.test_only_add_in_cache(Concept(name="foo", body="'foo'"))
|
||||
sheerka, context, hello_a, foo = self.init_concepts(
|
||||
Concept(name="hello a", body="'hello ' + a").def_var("a"),
|
||||
Concept(name="foo", body="'foo'")
|
||||
)
|
||||
|
||||
res = sheerka.evaluate_user_input("hello foo")
|
||||
assert len(res) == 1
|
||||
@@ -1199,6 +1196,18 @@ as:
|
||||
assert res[0].status
|
||||
assert sheerka.isinstance(res[0].body, BuiltinConcepts.TO_MULTI)
|
||||
|
||||
def test_i_can_evaluate_pseudo_recursive_definition(self):
|
||||
init = [
|
||||
"def concept a + b as a + b",
|
||||
]
|
||||
sheerka = self.init_scenario(init)
|
||||
|
||||
res = sheerka.evaluate_user_input("eval 1 + 1")
|
||||
|
||||
assert len(res) == 1
|
||||
assert res[0].status
|
||||
assert res[0].body == 2
|
||||
|
||||
|
||||
class TestSheerkaNonRegFile(TestUsingFileBasedSheerka):
|
||||
def test_i_can_def_several_concepts(self):
|
||||
|
||||
Reference in New Issue
Block a user