Skip to content

Commit

Permalink
chimpler#281: Added tests covering broken += operator behaviour
Browse files Browse the repository at this point in the history
  • Loading branch information
Peter Zaitcev authored and Peter Zaitcev committed Sep 25, 2022
1 parent be660de commit 447bb4a
Showing 1 changed file with 38 additions and 0 deletions.
38 changes: 38 additions & 0 deletions tests/test_config_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -816,6 +816,17 @@ def test_self_append_array(self):
)
assert config.get("x") == [1, 2, 3, 4]

def test_self_append_array_inside_dict(self):
config = ConfigFactory.parse_string(
"""
d {
x = [1,2]
x += [3,4]
}
"""
)
assert config.get("d.x") == [1, 2, 3, 4]

def test_self_append_string(self):
'''
Should be equivalent to
Expand All @@ -830,6 +841,22 @@ def test_self_append_string(self):
)
assert config.get("x") == "abc def"

def test_self_append_string_inside_dict(self):
'''
Should be equivalent to
x = abc
x = ${?x} def
'''
config = ConfigFactory.parse_string(
"""
d {
x = abc
x += def
}
"""
)
assert config.get("d.x") == "abc def"

def test_self_append_non_existent_string(self):
'''
Should be equivalent to x = ${?x} def
Expand Down Expand Up @@ -858,6 +885,17 @@ def test_self_append_object(self):
)
assert config.get("x") == {'a': 1, 'b': 2}

def test_self_append_object_inside_dict(self):
config = ConfigFactory.parse_string(
"""
d {
x = {a: 1}
x += {b: 2}
}
"""
)
assert config.get("d.x") == {'a': 1, 'b': 2}

def test_self_append_nonexistent_object(self):
config = ConfigFactory.parse_string(
"""
Expand Down

0 comments on commit 447bb4a

Please sign in to comment.