Fixed BnfNodeParser to allow expressions like 'number hundred' when number is a group
This commit is contained in:
@@ -494,3 +494,32 @@ class TestSheerkaEvaluateConcept(TestUsingMemoryBasedSheerka):
|
||||
evaluated = sheerka.evaluate_concept(self.get_context(sheerka, True), one)
|
||||
assert evaluated.key == one.key
|
||||
assert evaluated.body == 1
|
||||
|
||||
def test_i_can_evaluate_thousand_concept(self):
|
||||
sheerka, context, thousand, number, forties, forty, one = self.init_concepts(
|
||||
Concept("thousand", body="number * 1000").def_var("number"),
|
||||
Concept("number"),
|
||||
Concept("forties", body="forty + number").def_var("forty").def_var("number"),
|
||||
Concept("forty", body="40"),
|
||||
Concept("one", body="1"),
|
||||
eval_body=True
|
||||
)
|
||||
|
||||
one = sheerka.new("one")
|
||||
number2 = sheerka.new("number")
|
||||
number2.compiled["one"] = one
|
||||
number2.compiled[ConceptParts.BODY] = one
|
||||
forties = sheerka.new("forties")
|
||||
forties.compiled["forty"] = sheerka.new("forty")
|
||||
forties.compiled["number"] = number2
|
||||
|
||||
number1 = sheerka.new("number")
|
||||
number1.compiled["forties"] = forties
|
||||
number1.compiled[ConceptParts.BODY] = forties
|
||||
|
||||
forty_one_thousand = sheerka.new("thousand")
|
||||
forty_one_thousand.compiled["number"] = number1
|
||||
|
||||
evaluated = sheerka.evaluate_concept(context, forty_one_thousand)
|
||||
|
||||
assert evaluated.body == 41000
|
||||
|
||||
Reference in New Issue
Block a user