Commits

Anonymous committed 7f1e911

#94: Mainlining directly

  • Participants
  • Parent commits a151b6d

Comments (0)

Files changed (3)

src/tests/system/t094.c

+/*
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program 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.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ */
+
+/**
+ * System Test 094
+ *
+ * Regression test for issue #94:
+ * Fix image integer loading so it re-uses static ints (-1,0,1).
+ *
+ * Log
+ * ---
+ *
+ * 2007/02/06   #94: First
+ */
+
+#include "pm.h"
+#include "stdio.h"
+
+
+extern unsigned char usrlib_img[];
+
+
+int main(void)
+{
+    PmReturn_t retval;
+
+    retval = pm_init(MEMSPACE_FLASH, usrlib_img);
+    PM_RETURN_IF_ERROR(retval);
+
+    retval = pm_run((uint8_t *)"t094");
+    pm_reportResult(retval);
+    return (int)retval;
+}

src/tests/system/t094.py

+# PyMite - A flyweight Python interpreter for 8-bit microcontrollers and more.
+# Copyright 2002 Dean Hall
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License
+# as published by the Free Software Foundation; either version 2
+# of the License, or (at your option) any later version.
+#
+# This program 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.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License along
+# with this program; if not, write to the Free Software Foundation, Inc.,
+# 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+#
+
+#
+# System Test 094
+#
+# Regression test for issue #94:
+# Fix image integer loading so it re-uses static ints (-1,0,1).
+#
+
+kn1 = 1 - 2
+k0 = kn1 + 1
+k1 = k0 + 1
+
+id1 = id(-1)
+id2 = id(kn1)
+assert id1 == id2
+
+id1 = id(0)
+id2 = id(k0)
+assert id1 == id2
+
+id1 = id(1)
+id2 = id(k1)
+assert id1 == id2
 {
     PmReturn_t retval = PM_RET_OK;
     PmObjDesc_t od;
+    int32_t intval;
 
     /* get the object descriptor */
     od.od_type = (PmType_t)mem_getByte(memspace, paddr);
 
         /* if it's a simple type */
         case OBJ_TYPE_INT:
-        case OBJ_TYPE_FLT:
-            /* allocate simple obj */
-            retval = heap_getChunk(sizeof(PmInt_t), (uint8_t **)r_pobj);
-            PM_RETURN_IF_ERROR(retval);
+            /* Read the integer value (little endian) */
+            intval = mem_getInt(memspace, paddr);
 
-            /* Set the object's type */
-            OBJ_SET_TYPE(**r_pobj, od.od_type);
-
-            /* Read in the object's value (little endian) */
-            ((pPmInt_t)*r_pobj)->val = mem_getInt(memspace, paddr);
+            /* Create an integer object with the value */
+            retval = int_new(intval, r_pobj);
             break;
 
         case OBJ_TYPE_STR: