[pypy-commit] creflect default: adapt next test

arigo noreply at buildbot.pypy.org
Tue Nov 18 17:51:37 CET 2014


Author: Armin Rigo <arigo at tunes.org>
Branch: 
Changeset: r75:760e20f512dc
Date: 2014-11-18 17:51 +0100
http://bitbucket.org/cffi/creflect/changeset/760e20f512dc/

Log:	adapt next test

diff --git a/test/codegen/glob-003g.c b/test/codegen/glob-003g.c
--- a/test/codegen/glob-003g.c
+++ b/test/codegen/glob-003g.c
@@ -2,61 +2,14 @@
 
 # ____________________________________________________________
 
-int testglob_003g(char *r)
+void testglob_003g(crx_builder_t *cb)
 {
-    int e = 0;
-    char v[48];
-    if (!r)
-        return 63 + 1;
+    crx_type_t *t1;
     {
-        int z1, z2;
-        (void)(ab << 1);  /* check that 'ab' is an integer */
-        z1 = !((ab * 0 + 4) << (sizeof(int)*8-2));
-        z2 = !((ab * 0L + 4L) << (sizeof(long)*8-2));
-        if (ab == (short)ab) {
-            r += sprintf(r, "short");
-            sprintf(v, "%d", (int)ab);
-        }
-        else if ((ab * 0 - 1) > 0) {    /* unsigned */
-            if (ab != (unsigned long long)ab) {
-                r += sprintf(r, "#error unsigned integer constant 'ab' is too large\n");
-                e = -1;
-                goto f1;
-            }
-            if (z1) {
-                r += sprintf(r, "unsigned int");
-                sprintf(v, "%u", (unsigned int)ab);
-            }
-            else if (z2) {
-                r += sprintf(r, "unsigned long");
-                sprintf(v, "%lu", (unsigned long)ab);
-            }
-            else {
-                r += sprintf(r, "unsigned long long");
-                sprintf(v, "%llu", (unsigned long long)ab);
-            }
-        }
-        else {    /* signed */
-            if (ab != (long long)ab) {
-                r += sprintf(r, "#error integer constant 'ab' is too large\n");
-                e = -1;
-                goto f1;
-            }
-            if (z1) {
-                r += sprintf(r, "int");
-                sprintf(v, "%d", (int)ab);
-            }
-            else if (z2) {
-                r += sprintf(r, "long");
-                sprintf(v, "%ld", (long)ab);
-            }
-            else {
-                r += sprintf(r, "long long");
-                sprintf(v, "%lld", (long long)ab);
-            }
-        }
+        crx_int_const_t v;
+        (void)((ab) << 1);  /* check that 'ab' is an integer */
+        t1 = CRX_INT_CONST(cb, ab, &v, 1);
+        cb->define_int_const(cb, "ab", t1, &v);
+#expect INTCONST ab = int -42
     }
-    r += sprintf(r, " const ab = %s;\n", v);
- f1:
-    return e;
 }


More information about the pypy-commit mailing list