mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-05 23:41:44 +00:00
Fix #7634. Support formatting signed numbers.
This commit is contained in:
@@ -144,7 +144,7 @@ format_grammar = lark.Lark(
|
||||
| mul_div "*" function -> multiply
|
||||
| mul_div "/" function -> divide
|
||||
|
||||
function: round | number | int | format_length | lower | upper | title | concat | substr | variable | ESCAPED_STRING | NUMBER | "(" expression ")"
|
||||
function: round | number | int | format_length | lower | upper | title | concat | substr | variable | ESCAPED_STRING | SIGNED_NUMBER | "(" expression ")"
|
||||
|
||||
variable: "{{" query_path "}}"
|
||||
query_path: /[^}]+/
|
||||
|
||||
@@ -54,6 +54,7 @@ class TestFormat:
|
||||
def test_number_formatting(self):
|
||||
assert subject.format("round(123, 5)") == "125"
|
||||
assert subject.format('round("123", 5)') == "125"
|
||||
assert subject.format('round(-123, 5)') == "-125"
|
||||
assert subject.format("int(123.123)") == "123"
|
||||
assert subject.format("int(123)") == "123"
|
||||
assert subject.format("number(123)") == "123"
|
||||
|
||||
Reference in New Issue
Block a user