summaryrefslogtreecommitdiffstatshomepage
path: root/py/builtin.c
diff options
context:
space:
mode:
authorAndrew Scheller <github@loowis.durge.org>2014-05-01 21:21:43 +0100
committerAndrew Scheller <github@loowis.durge.org>2014-05-01 21:21:43 +0100
commit37067666ee24b018f260a011375f65aa69b49041 (patch)
tree9b062622de8f0f35a6d4b3c909ad720d2668d847 /py/builtin.c
parent1f85d6255d6929edbcfc087e4e07c2fde39c3632 (diff)
downloadmicropython-37067666ee24b018f260a011375f65aa69b49041.tar.gz
micropython-37067666ee24b018f260a011375f65aa69b49041.zip
Fix the builtin min() and max() functions (and add tests).
Fixes #539
Diffstat (limited to 'py/builtin.c')
-rw-r--r--py/builtin.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/py/builtin.c b/py/builtin.c
index 250a3558e8..b586792020 100644
--- a/py/builtin.c
+++ b/py/builtin.c
@@ -245,7 +245,7 @@ STATIC mp_obj_t mp_builtin_max(uint n_args, const mp_obj_t *args) {
mp_obj_t max_obj = NULL;
mp_obj_t item;
while ((item = mp_iternext(iterable)) != MP_OBJ_STOP_ITERATION) {
- if (max_obj == NULL || mp_binary_op(MP_BINARY_OP_LESS, max_obj, item)) {
+ if (max_obj == NULL || (mp_binary_op(MP_BINARY_OP_LESS, max_obj, item) == mp_const_true)) {
max_obj = item;
}
}
@@ -257,7 +257,7 @@ STATIC mp_obj_t mp_builtin_max(uint n_args, const mp_obj_t *args) {
// given many args
mp_obj_t max_obj = args[0];
for (int i = 1; i < n_args; i++) {
- if (mp_binary_op(MP_BINARY_OP_LESS, max_obj, args[i])) {
+ if (mp_binary_op(MP_BINARY_OP_LESS, max_obj, args[i]) == mp_const_true) {
max_obj = args[i];
}
}
@@ -274,7 +274,7 @@ STATIC mp_obj_t mp_builtin_min(uint n_args, const mp_obj_t *args) {
mp_obj_t min_obj = NULL;
mp_obj_t item;
while ((item = mp_iternext(iterable)) != MP_OBJ_STOP_ITERATION) {
- if (min_obj == NULL || mp_binary_op(MP_BINARY_OP_LESS, item, min_obj)) {
+ if (min_obj == NULL || (mp_binary_op(MP_BINARY_OP_LESS, item, min_obj) == mp_const_true)) {
min_obj = item;
}
}
@@ -286,7 +286,7 @@ STATIC mp_obj_t mp_builtin_min(uint n_args, const mp_obj_t *args) {
// given many args
mp_obj_t min_obj = args[0];
for (int i = 1; i < n_args; i++) {
- if (mp_binary_op(MP_BINARY_OP_LESS, args[i], min_obj)) {
+ if (mp_binary_op(MP_BINARY_OP_LESS, args[i], min_obj) == mp_const_true) {
min_obj = args[i];
}
}