summaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorDamien George <damien.p.george@gmail.com>2015-05-12 23:34:10 +0100
committerDamien George <damien.p.george@gmail.com>2015-05-12 23:34:10 +0100
commitf601390ef899a3b87b92d5075ded98a9766fdd6b (patch)
treeaaf335fec13d7da5308e5e8b4259bd25c2ef0485
parent7bab32ef89d760a8cf4aeb2700725ea88e3fc31c (diff)
downloadmicropython-f601390ef899a3b87b92d5075ded98a9766fdd6b.tar.gz
micropython-f601390ef899a3b87b92d5075ded98a9766fdd6b.zip
unix: Add some extra coverage tests for vstr and attrtuple.
-rw-r--r--tests/unix/extra_coverage.py.exp10
-rw-r--r--unix/coverage.c40
2 files changed, 50 insertions, 0 deletions
diff --git a/tests/unix/extra_coverage.py.exp b/tests/unix/extra_coverage.py.exp
index 565b0dd040..62debadcd0 100644
--- a/tests/unix/extra_coverage.py.exp
+++ b/tests/unix/extra_coverage.py.exp
@@ -1,3 +1,11 @@
+# vstr
+tests
+sts
+
+test
+tes
+larg
+# repl
ame__
__name__ path argv version
@@ -5,3 +13,5 @@ version_info implementation platform byteorder
maxsize exit stdin stdout
stderr exc_info print_exception
ementation
+# attrtuple
+(start=1, stop=2, step=3)
diff --git a/unix/coverage.c b/unix/coverage.c
index bc66ec3f11..757ebf1a2e 100644
--- a/unix/coverage.c
+++ b/unix/coverage.c
@@ -8,8 +8,38 @@
// function to run extra tests for things that can't be checked by scripts
STATIC mp_obj_t extra_coverage(void) {
+ // vstr
+ {
+ printf("# vstr\n");
+ vstr_t *vstr = vstr_new_size(16);
+ vstr_hint_size(vstr, 32);
+ vstr_add_str(vstr, "ts");
+ vstr_ins_byte(vstr, 1, 'e');
+ vstr_ins_char(vstr, 3, 't');
+ vstr_ins_char(vstr, 10, 's');
+ printf("%.*s\n", (int)vstr->len, vstr->buf);
+
+ vstr_cut_head_bytes(vstr, 2);
+ printf("%.*s\n", (int)vstr->len, vstr->buf);
+
+ vstr_cut_tail_bytes(vstr, 10);
+ printf("%.*s\n", (int)vstr->len, vstr->buf);
+
+ vstr_printf(vstr, "t%cst", 'e');
+ printf("%.*s\n", (int)vstr->len, vstr->buf);
+
+ vstr_cut_out_bytes(vstr, 3, 10);
+ printf("%.*s\n", (int)vstr->len, vstr->buf);
+
+ VSTR_FIXED(fix, 4);
+ vstr_add_str(&fix, "large");
+ printf("%.*s\n", (int)fix.len, fix.buf);
+ }
+
// repl autocomplete
{
+ printf("# repl\n");
+
const char *str;
mp_uint_t len = mp_repl_autocomplete("__n", 3, &mp_plat_print, &str);
printf("%.*s\n", (int)len, str);
@@ -20,6 +50,16 @@ STATIC mp_obj_t extra_coverage(void) {
printf("%.*s\n", (int)len, str);
}
+ // attrtuple
+ {
+ printf("# attrtuple\n");
+
+ static const qstr fields[] = {MP_QSTR_start, MP_QSTR_stop, MP_QSTR_step};
+ static const mp_obj_t items[] = {MP_OBJ_NEW_SMALL_INT(1), MP_OBJ_NEW_SMALL_INT(2), MP_OBJ_NEW_SMALL_INT(3)};
+ mp_obj_print_helper(&mp_plat_print, mp_obj_new_attrtuple(fields, 3, items), PRINT_REPR);
+ printf("\n");
+ }
+
return mp_const_none;
}
MP_DEFINE_CONST_FUN_OBJ_0(extra_coverage_obj, extra_coverage);