summaryrefslogtreecommitdiff
path: root/tests/float/complex1.py
AgeCommit message (Collapse)Author
2025-06-10py/parsenum: Fix parsing complex literals with negative real part.Jeff Epler
If a complex literal had a negative real part and a positive imaginary part, it was not parsed properly because the imaginary part also came out negative. Includes a test of complex parsing, which fails without this fix. Co-authored-by: ComplexSymbol <141301057+ComplexSymbol@users.noreply.github.com> Signed-off-by: Jeff Epler <jepler@gmail.com>
2022-06-23py/parsenum: Fix parsing of complex "j" and also "nanj", "infj".Damien George
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>
2022-06-23py/parsenum: Support parsing complex numbers of the form "a+bj".Jim Mussared
To conform with CPython. Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
2022-02-02all: Update Python formatting to latest Black version 22.1.0.Damien George
Signed-off-by: Damien George <damien@micropython.org>
2020-03-30tests: Format all Python code with black, except tests in basics subdir.David Lechner
This adds the Python files in the tests/ directory to be formatted with ./tools/codeformat.py. The basics/ subdirectory is excluded for now so we aren't changing too much at once. In a few places `# fmt: off`/`# fmt: on` was used where the code had special formatting for readability or where the test was actually testing the specific formatting.
2020-02-11tests/basics: Add tests for equality between bool and int/float/complex.Damien George
False/True should be implicitly converted to 0/1 when compared with numeric types.
2017-10-10py/formatfloat: Don't print the negative sign of a NaN value.Damien George
NaN may have the sign bit set but it has no meaning, so don't print it out.
2017-09-26py/objfloat: Support raising a negative number to a fractional power.Damien George
This returns a complex number, following CPython behaviour. For ports that don't have complex numbers enabled this will raise a ValueError which gives a fail-safe for scripts that were written assuming complex numbers exist.
2017-09-04py/obj: Fix comparison of float/complex NaN with itself.Damien George
IEEE floating point is specified such that a comparison of NaN with itself returns false, and Python respects these semantics. This patch makes uPy also have these semantics. The fix has a minor impact on the speed of the object-equality fast-path, but that seems to be unavoidable and it's much more important to have correct behaviour (especially in this case where the wrong answer for nan==nan is silently returned).
2017-04-04tests/float: Add tests for hashing float and complex numbers.Damien George
2017-03-06tests/float/complex1: Split out intbig test.Paul Sokolovsky
2017-02-03tests/float: Add tests for zero to a negative power.Damien George
2017-01-19tests/float: Add test for assigning to attribute of complex number.Damien George
2016-12-21tests: Add tests to improve coverage of runtime.c.Rami Ali
2015-05-13py: Fix printing of complex number when imaginary part is nanstijn
2015-04-04tests: Add tests to exercise lexer; and some more complex number tests.Damien George
2015-04-04tests: Add missing tests for builtins, and many other things.Damien George
2015-03-25tests: Add tests for SyntaxError, TypeError, and other missing things.Damien George
This is intended to improve coverage of the test suite.
2015-03-14tests: Add some more tests for complex numbers and ure module.Damien George
2015-03-02tests: Add tests for builtins: all, any, sum, abs.Damien George
2015-03-02tests: Add tests for op special meths, ubinascii, complex.Damien George