Fixed BnfNodeParser to allow expressions like 'number hundred' when number is a group
This commit is contained in:
@@ -1,9 +1,20 @@
|
||||
from dataclasses import dataclass
|
||||
|
||||
import core.utils
|
||||
import pytest
|
||||
from core.concept import ConceptParts, Concept
|
||||
from core.tokenizer import Token, TokenKind
|
||||
|
||||
|
||||
@dataclass
|
||||
class Obj:
|
||||
prop1: str
|
||||
prop2: str
|
||||
|
||||
def __hash__(self):
|
||||
return hash((self.prop1, self.prop1))
|
||||
|
||||
|
||||
def get_tokens(lst):
|
||||
res = []
|
||||
for e in lst:
|
||||
@@ -229,3 +240,9 @@ def test_decode_concept_key_id():
|
||||
])
|
||||
def test_dict_product(a, b, expected):
|
||||
assert core.utils.dict_product(a, b) == expected
|
||||
|
||||
|
||||
def test_i_can_make_unique():
|
||||
assert core.utils.make_unique(["a", "a", "b", "c", "c"]) == ["a", "b", "c"]
|
||||
assert core.utils.make_unique([Obj("a", "b"), Obj("a", "c"), Obj("a", "b")]) == [Obj("a", "b"), Obj("a", "c")]
|
||||
assert core.utils.make_unique([Obj("a", "b"), Obj("a", "c")], lambda o: o.prop1) == [Obj("a", "b")]
|
||||
|
||||
Reference in New Issue
Block a user