diff options
author | Damien George <damien@micropython.org> | 2022-06-21 23:45:27 +1000 |
---|---|---|
committer | Damien George <damien@micropython.org> | 2022-06-23 11:46:47 +1000 |
commit | 61ce260ff73b1191a9190c8cac7a7a1bd5b2f274 (patch) | |
tree | 10420f6c4f2bc59f24031d17de28690f41c40e38 /tests/float/complex1.py | |
parent | 0172292762649db91f588107b2163ab6449dc7ca (diff) | |
download | micropython-61ce260ff73b1191a9190c8cac7a7a1bd5b2f274.tar.gz micropython-61ce260ff73b1191a9190c8cac7a7a1bd5b2f274.zip |
py/parsenum: Fix parsing of complex "j" and also "nanj", "infj".
Prior to this commit, complex("j") would return 0j, and complex("nanj")
would return nan+0j. This commit makes sure "j" is tested for after
parsing the number (nan, inf or a decimal), and also supports the case of
"j" on its own.
Signed-off-by: Damien George <damien@micropython.org>
Diffstat (limited to 'tests/float/complex1.py')
-rw-r--r-- | tests/float/complex1.py | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/tests/float/complex1.py b/tests/float/complex1.py index feede0eab3..f4107a1390 100644 --- a/tests/float/complex1.py +++ b/tests/float/complex1.py @@ -4,14 +4,19 @@ print(complex(1)) print(complex(1.2)) print(complex(1.2j)) +print(complex("j")) +print(complex("J")) print(complex("1")) print(complex("1.2")) print(complex("1.2j")) +print(complex("1+j")) print(complex("1+2j")) print(complex("-1-2j")) print(complex("+1-2j")) print(complex(" -1-2j ")) print(complex(" +1-2j ")) +print(complex("nanj")) +print(complex("nan-infj")) print(complex(1, 2)) print(complex(1j, 2j)) |