1. tuck
  2. pymite

Commits

Dean Hall  committed bea5b57

Fixes Issue 184

  • Participants
  • Parent commits 46b7a9e
  • Branches v10

Comments (0)

Files changed (3)

File src/tests/system/t384.c

View file
  • Ignore whitespace
+/*
+# This file is Copyright 2011 Dean Hall.
+#
+# This file is part of the Python-on-a-Chip program.
+# Python-on-a-Chip is free software: you can redistribute it and/or modify
+# it under the terms of the GNU LESSER GENERAL PUBLIC LICENSE Version 2.1.
+#
+# Python-on-a-Chip is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+# A copy of the GNU LESSER GENERAL PUBLIC LICENSE Version 2.1
+# is seen in the file COPYING up one directory from this.
+*/
+
+/**
+ * System Test 384
+ */
+
+#include "pm.h"
+
+
+#define HEAP_SIZE 0x2000
+
+extern unsigned char usrlib_img[];
+
+
+int main(void)
+{
+    uint8_t heap[HEAP_SIZE];
+    PmReturn_t retval;
+
+    retval = pm_init(heap, HEAP_SIZE, MEMSPACE_PROG, usrlib_img);
+    PM_RETURN_IF_ERROR(retval);
+
+    retval = pm_run((uint8_t *)"t384");
+    C_ASSERT((int)retval == PM_RET_EX_TYPE);
+    if (retval == PM_RET_EX_TYPE) return (int)PM_RET_OK;
+    return (int)retval;
+}

File src/tests/system/t384.py

View file
  • Ignore whitespace
+# This file is Copyright 2011 Dean Hall.
+#
+# This file is part of the Python-on-a-Chip program.
+# Python-on-a-Chip is free software: you can redistribute it and/or modify
+# it under the terms of the GNU LESSER GENERAL PUBLIC LICENSE Version 2.1.
+#
+# Python-on-a-Chip is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+# A copy of the GNU LESSER GENERAL PUBLIC LICENSE Version 2.1
+# is seen in the file COPYING up one directory from this.
+
+#
+# System Test 384
+#
+
+assert None == None
+assert None is None
+assert (None is not None) == False
+assert (not None is None) == False
+assert (None != None) == False
+assert (1 is None) == False
+assert (1 == None) == False
+assert (1 is not None) == True
+assert (not 1 is None) == True
+assert (1 != None) == True
+
+
+def foo(): pass
+def bar(): pass
+
+assert (foo is None) == False
+assert foo is not None
+assert (None is foo) == False
+assert None is not foo
+
+assert (foo is bar) == False
+assert foo is not bar
+assert (bar is foo) == False
+assert bar is not foo

File src/vm/interp.c

View file
  • Ignore whitespace
 
                 /* Handle all integer-to-integer (or bool) comparisons */
                 if (((OBJ_GET_TYPE(TOS) == OBJ_TYPE_INT)
-                     || (OBJ_GET_TYPE(TOS) == OBJ_TYPE_BOOL))
+                     || (OBJ_GET_TYPE(TOS) == OBJ_TYPE_BOOL)
+                     || (OBJ_GET_TYPE(TOS) == OBJ_TYPE_NON))
                     && ((OBJ_GET_TYPE(TOS1) == OBJ_TYPE_INT)
-                        || (OBJ_GET_TYPE(TOS1) == OBJ_TYPE_BOOL)))
+                        || (OBJ_GET_TYPE(TOS1) == OBJ_TYPE_BOOL)
+                        || (OBJ_GET_TYPE(TOS1) == OBJ_TYPE_NON)))
                 {
                     int32_t a = ((pPmInt_t)TOS1)->val;
                     int32_t b = ((pPmInt_t)TOS)->val;
                             }
                             break;
 
+                        case COMP_IS:
+                            pobj3 = (TOS == TOS1) ? PM_TRUE : PM_FALSE;
+                            break;
+
+                        case COMP_IS_NOT:
+                            pobj3 = (TOS != TOS1) ? PM_TRUE : PM_FALSE;
+                            break;
+
                         default:
                             /* Other comparisons are not implemented */
                             PM_RAISE(retval, PM_RET_EX_SYS);