Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
# v1.10.1-alpha0

* Improved `dict` export _(cosmetic)_, pr #462.

# v1.10.0

* Fixed sanatize runtime checking, pr #455.
Expand Down
2 changes: 1 addition & 1 deletion inc/ti/dict.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@

typedef enum
{
TI_DICT_KEY_UUID,
TI_DICT_KEY_INT,
TI_DICT_KEY_STR,
TI_DICT_KEY_UUID,
} ti_dict_enum_e;

typedef struct
Expand Down
4 changes: 2 additions & 2 deletions inc/ti/version.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

#define TI_VERSION_MAJOR 1
#define TI_VERSION_MINOR 10
#define TI_VERSION_PATCH 0
#define TI_VERSION_PATCH 1

/* The syntax version is used to test compatibility with functions
* using the `ti_nodes_check_syntax()` function */
Expand All @@ -25,7 +25,7 @@
* "-rc0"
* ""
*/
#define TI_VERSION_PRE_RELEASE ""
#define TI_VERSION_PRE_RELEASE "-alpha0"

#define TI_MAINTAINER \
"Jeroen van der Heijden <jeroen@cesbit.com>"
Expand Down
10 changes: 8 additions & 2 deletions itest/test_advanced.py
Original file line number Diff line number Diff line change
Expand Up @@ -1571,7 +1571,8 @@ async def test_assign_in_def(self, client):
self.assertEqual(res, '|| x[0] += 1') # formatted closure

async def test_export(self, client):
script = r'''
self.maxDiff = 1800
script = r"""
try(commit('Source: collection `stuff`'));

new_type('Friend');
Expand Down Expand Up @@ -1652,6 +1653,11 @@ async def test_export(self, client):
c: |a, b| a + b,
float: 3.140000,
u: uuid('01a08b43-4abd-7529-82a2-9ae352b2f10f'),
d: dict([
[uuid('01a08b43-4abd-7529-82a2-9ae352b2f10f'), 0],
[0, 1],
['a', 2],
]),
});


Expand All @@ -1665,7 +1671,7 @@ async def test_export(self, client):
.to_type('Root');

'DONE';
'''.lstrip().replace(' ', '\t')
""".lstrip().replace(' ', '\t')
await client.query(script)
res = await client.query('export();')
self.assertEqual(res, script)
Expand Down
16 changes: 9 additions & 7 deletions src/ti/export.c
Original file line number Diff line number Diff line change
Expand Up @@ -396,18 +396,20 @@ static int export__dict_pair(ti_dict_key_t * key,

switch(key->tp)
{
case TI_DICT_KEY_INT:
if (buf_append_fmt(buf, "%"PRIi64", ", key->via.id))
return -1;
break;
case TI_DICT_KEY_UUID:
if (export__uuid(fmt, key->via.uuid) ||
buf_write(buf, ','))
buf_write(buf, ',') ||
buf_write(buf, ' '))
return -1;
break;
case TI_DICT_KEY_INT:
if (buf_append_fmt(buf, "%"PRIi64", ", key->via.id))
return -1;
break;
case TI_DICT_KEY_STR:
if (ti_fmt_strn(fmt, key->via.str.str, key->via.str.n) ||
buf_write(buf, ','))
buf_write(buf, ',') ||
buf_write(buf, ' '))
return -1;
break;
}
Expand Down Expand Up @@ -501,7 +503,7 @@ static int export__val(ti_fmt_t * fmt, ti_val_t * val)
fmt->indent--;
return -(
ti_fmt_indent(fmt) ||
buf_append_str(buf, "])\n")
buf_append_str(buf, "])")
);
}
case TI_VAL_ERROR:
Expand Down
Loading