Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit358ac36

Browse files
authored
Merge pull request#35 from nielstron/fix/variable_comparison
Fix variable comparison and add regression test
2 parents987a5a2 +4c27e6f commit358ac36

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

‎pyformlang/cfg/tests/test_cfg.py‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -280,6 +280,12 @@ def test_concatenation(self):
280280
assertnotnew_cfg.is_empty()
281281
assertnew_cfg.contains([ter_a,ter_a,ter_b,ter_b,ter_a,ter_b])
282282

283+
deftest_concatenation_variable_names(self):
284+
first_lang=CFG({Variable("S")}, {Terminal("S")},Variable("S"), {Production(Variable("S"), [Terminal("S")])})
285+
second_lang=CFG({Variable("S")}, {Terminal("a")},Variable("S"), {Production(Variable("S"), [Terminal("a")])})
286+
concat=first_lang.concatenate(second_lang)
287+
assert"Sa"inconcat
288+
283289
deftest_closure(self):
284290
""" Tests the closure of a cfg """
285291
var_s=Variable("S")

‎pyformlang/cfg/variable.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ def __init__(self, value):
1919
self.index_cfg_converter=None
2020

2121
def__eq__(self,other):
22-
ifisinstance(other,CFGObject):
22+
ifisinstance(other,Variable):
2323
returnself._value==other.value
2424
returnself._value==other
2525

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp