diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-14 20:19:53 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-14 20:19:53 +0000 |
commit | e7ee850d46d54789979bf0c5244bae1825fb7149 (patch) | |
tree | 6e94ed55df9ec749682a3c792ce752d07892b968 /_test/test_int.py | |
parent | Initial commit. (diff) | |
download | python-ruyaml-e7ee850d46d54789979bf0c5244bae1825fb7149.tar.xz python-ruyaml-e7ee850d46d54789979bf0c5244bae1825fb7149.zip |
Adding upstream version 0.91.0.upstream/0.91.0upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to '_test/test_int.py')
-rw-r--r-- | _test/test_int.py | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/_test/test_int.py b/_test/test_int.py new file mode 100644 index 0000000..d409746 --- /dev/null +++ b/_test/test_int.py @@ -0,0 +1,34 @@ +# coding: utf-8 + +import pytest # NOQA + +from .roundtrip import dedent, round_trip_dump, round_trip_load + +# http://yaml.org/type/int.html is where underscores in integers are defined + + +class TestBinHexOct: + def test_calculate(self): + # make sure type, leading zero(s) and underscore are preserved + s = dedent( + """\ + - 42 + - 0b101010 + - 0x_2a + - 0x2A + - 0o00_52 + """ + ) + d = round_trip_load(s) + for idx, elem in enumerate(d): + elem -= 21 + d[idx] = elem + for idx, elem in enumerate(d): + elem *= 2 + d[idx] = elem + for idx, elem in enumerate(d): + t = elem + elem **= 2 + elem //= t + d[idx] = elem + assert round_trip_dump(d) == s |