From 78884c413a20e8604ccb598c8490f2dc469c041f Mon Sep 17 00:00:00 2001 From: Frost Ming Date: Thu, 23 May 2024 17:33:34 +0800 Subject: [PATCH] fix: add back removed case Signed-off-by: Frost Ming --- tests/test_items.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/tests/test_items.py b/tests/test_items.py index f5f9140..8d6723e 100644 --- a/tests/test_items.py +++ b/tests/test_items.py @@ -969,3 +969,19 @@ def encode_decimal(obj): assert api.dumps({"foo": decimal.Decimal("1.23")}) == "foo = 1.23\n" api.unregister_encoder(encode_decimal) + + +def test_no_extra_minus_sign(): + doc = parse("a = -1") + assert doc.as_string() == "a = -1" + doc["a"] *= -1 + assert doc.as_string() == "a = +1" + doc["a"] *= -1 + assert doc.as_string() == "a = -1" + + doc = parse("a = -1.5") + assert doc.as_string() == "a = -1.5" + doc["a"] *= -1 + assert doc.as_string() == "a = +1.5" + doc["a"] *= -1 + assert doc.as_string() == "a = -1.5"