micropython/tests/unix/extra_coverage.py.exp
Damien George 165aab12a3 py/repl: Generalise REPL autocomplete to use qstr probing.
This patch changes the way REPL autocomplete finds matches.  It now probes
the target object for all qstrs via mp_load_method_maybe to look for a
match with the given input string.  Similar to how the builtin dir()
function works, this new algorithm now find all methods and instances of
user-defined classes including attributes of their parent classes.  This
helps a lot at the REPL prompt for user-discovery and to autocomplete names
even for classes that are derived.

The downside is that this new algorithm is slower than the previous one,
and in particular will be slower the more qstrs there are in the system.
But because REPL autocomplete is primarily used in an interactive way it is
not that important to make it fast, as long as it is "fast enough" compared
to human reaction.

On a slow microcontroller (CPU running at 16MHz) the autocomplete time for
a list of 35 names in the outer namespace (pressing tab at a bare prompt)
takes about 160ms with this algorithm, compared to about 40ms for the
previous implementation (this time includes the actual printing of the
names as well).  This time of 160ms is very reasonable especially given the
new functionality of listing all the names.

This patch also decreases code size by:

   bare-arm:    +0
minimal x86:  -128
   unix x64:  -128
unix nanbox:  -224
      stm32:   -88
     cc3200:   -80
    esp8266:   -92
      esp32:   -84
2018-02-19 16:12:44 +11:00

96 lines
1.0 KiB
Plaintext

# mp_printf
-123 +123 123
-0123
123
123
1ABCDEF
ab abc
false true
(null)
-2147483648
2147483648
80000000
80000000
abc
# vstr
tests
sts
test
tes
RuntimeError:
RuntimeError:
# repl
ame__
__class__ __name__ argv byteorder
exc_info exit getsizeof implementation
maxsize modules path platform
print_exception stderr stdin
stdout version version_info
ementation
# attrtuple
(start=1, stop=2, step=3)
# str
1
# bytearray
data
# mpz
1
12345678
0
0
# runtime utils
TypeError: unsupported type for __abs__: 'str'
TypeError: unsupported types for __divmod__: 'str', 'str'
Warning: test
# format float
?
+1e+00
+1e+00
# binary
122
456
# scheduler
sched(0)=1
sched(1)=1
sched(2)=1
sched(3)=1
sched(4)=0
unlocked
3
2
1
0
0123456789 b'0123456789'
7300
7300
7300
7300
None
None
None
None
None
None
b'123'
b'123'
b'123'
OSError
0
OSError
None
None
frzstr1
frzmpy1
frzstr_pkg1.__init__
1
frzmpy_pkg1.__init__
1
frzstr_pkg2.mod
1
frzmpy_pkg2.mod
1
ZeroDivisionError