micropython/tests/feature_check
Jim Mussared 692d36d779 py: Implement partial PEP-498 (f-string) support.
This implements (most of) the PEP-498 spec for f-strings and is based on
https://github.com/micropython/micropython/pull/4998 by @klardotsh.

It is implemented in the lexer as a syntax translation to `str.format`:
  f"{a}" --> "{}".format(a)

It also supports:
  f"{a=}" --> "a={}".format(a)

This is done by extracting the arguments into a temporary vstr buffer,
then after the string has been tokenized, the lexer input queue is saved
and the contents of the temporary vstr buffer are injected into the lexer
instead.

There are four main limitations:
- raw f-strings (`fr` or `rf` prefixes) are not supported and will raise
  `SyntaxError: raw f-strings are not supported`.

- literal concatenation of f-strings with adjacent strings will fail
    "{}" f"{a}" --> "{}{}".format(a)    (str.format will incorrectly use
                                         the braces from the non-f-string)
    f"{a}" f"{a}" --> "{}".format(a) "{}".format(a) (cannot concatenate)

- PEP-498 requires the full parser to understand the interpolated
  argument, however because this entirely runs in the lexer it cannot
  resolve nested braces in expressions like
    f"{'}'}"

- The !r, !s, and !a conversions are not supported.

Includes tests and cpydiffs.

Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
2021-08-14 16:58:40 +10:00
..
README tests: Rename run-tests to run-tests.py for consistency. 2021-03-12 19:56:09 +11:00
async_check.py tests/feature_check: Check for lack of pass result rather than failure. 2021-04-15 00:52:56 +10:00
async_check.py.exp
bytearray.py tests: Add feature check for bytearray and skip corresponding tests. 2019-10-29 22:22:37 +11:00
bytearray.py.exp tests: Add feature check for bytearray and skip corresponding tests. 2019-10-29 22:22:37 +11:00
byteorder.py all: Rename "sys" module to "usys". 2020-09-04 00:10:24 +10:00
byteorder.py.exp
complex.py tests: Format all Python code with black, except tests in basics subdir. 2020-03-30 13:21:58 +11:00
complex.py.exp
const.py tests/feature_check: Check for lack of pass result rather than failure. 2021-04-15 00:52:56 +10:00
const.py.exp
coverage.py tests: Format all Python code with black, except tests in basics subdir. 2020-03-30 13:21:58 +11:00
coverage.py.exp
float.py tests: Format all Python code with black, except tests in basics subdir. 2020-03-30 13:21:58 +11:00
float.py.exp
fstring.py py: Implement partial PEP-498 (f-string) support. 2021-08-14 16:58:40 +10:00
fstring.py.exp py: Implement partial PEP-498 (f-string) support. 2021-08-14 16:58:40 +10:00
int_big.py
int_big.py.exp
native_check.py tests/feature_check: Check for lack of pass result rather than failure. 2021-04-15 00:52:56 +10:00
native_check.py.exp
repl_emacs_check.py
repl_emacs_check.py.exp
repl_words_move_check.py lib/mp-readline: Add word-based move/delete EMACS key sequences. 2020-01-12 13:09:27 +11:00
repl_words_move_check.py.exp lib/mp-readline: Add word-based move/delete EMACS key sequences. 2020-01-12 13:09:27 +11:00
reverse_ops.py tests: Format all Python code with black, except tests in basics subdir. 2020-03-30 13:21:58 +11:00
reverse_ops.py.exp
set_check.py tests/feature_check: Check for lack of pass result rather than failure. 2021-04-15 00:52:56 +10:00
set_check.py.exp
slice.py tests: Add feature check for slice and skip corresponding tests. 2019-10-29 22:22:37 +11:00
slice.py.exp tests: Add feature check for slice and skip corresponding tests. 2019-10-29 22:22:37 +11:00
uio_module.py tests: Format all Python code with black, except tests in basics subdir. 2020-03-30 13:21:58 +11:00
uio_module.py.exp tests: Add feature check for uio module and skip corresponding tests. 2019-10-29 22:22:37 +11:00

README

This directory doesn't contain real tests, but code snippets to detect
various interpreter features, which can't be/inconvenient to detecte by
other means. Scripts here are executed by run-tests.py at the beginning of
testsuite to decide what other test groups to run/exclude.