Author: Armin Rigo <[email protected]>
Branch:
Changeset: r92:f71495c9c2aa
Date: 2014-11-18 20:38 +0100
http://bitbucket.org/cffi/creflect/changeset/f71495c9c2aa/
Log: long double test. Add some older test files that I forgot.
diff --git a/test/cgcompile.c b/test/cgcompile.c
--- a/test/cgcompile.c
+++ b/test/cgcompile.c
@@ -73,6 +73,7 @@
int found = 0;
TT(float);
TT(double);
+ TT(long double);
assert(found == sz);
#undef TT
return newtype(g);
@@ -201,7 +202,7 @@
else if (strcmp(t->text, "double") == 0)
printf("%f\n", value->as_double);
else if (strcmp(t->text, "long double") == 0)
- printf("%f\n", (double)value->as_double);
+ printf("%f\n", (double)value->as_long_double);
else {
printf("???\n");
abort();
diff --git a/test/codegen/func-001c.c b/test/codegen/func-001c.c
new file mode 100644
--- /dev/null
+++ b/test/codegen/func-001c.c
@@ -0,0 +1,27 @@
+double f(float);
+
+# ____________________________________________________________
+
+double f(float a) { return a + 0.25f; }
+
+# ____________________________________________________________
+
+static void testfunc_001c__c_f(void *args[], void *result) {
+ *(double *)result = f(*(float *)args[0]);
+}
+
+static double testfunc_001c__d_f(float a0) {
+ return f(a0);
+}
+
+void testfunc_001c(crx_builder_t *cb)
+{
+ crx_type_t *t1, *t2, *a3[1];
+ {
+ t1 = cb->get_float_type(cb, sizeof(double), "double");
+ t2 = cb->get_float_type(cb, sizeof(float), "float");
+ a3[0] = t2;
+ cb->define_func(cb, "f", t1, a3, 1, &testfunc_001c__c_f,
&testfunc_001c__d_f);
+#expect FUNC f: float -> double
+ }
+}
diff --git a/test/codegen/glob-003h.c b/test/codegen/glob-003h.c
new file mode 100644
--- /dev/null
+++ b/test/codegen/glob-003h.c
@@ -0,0 +1,23 @@
+float const ab = 42.0;
+double const abd = 42.0;
+
+# ____________________________________________________________
+
+void testglob_003h(crx_builder_t *cb)
+{
+ crx_type_t *t1, *t2;
+ {
+ crx_num_const_t v;
+ (void)((ab) / 2.0); /* check that 'ab' is a number */
+ t1 = CRX_FLOAT_CONST(cb, ab, &v);
+ cb->define_num_const(cb, "ab", t1, &v);
+#expect NUMCONST ab = float 42.000000
+ }
+ {
+ crx_num_const_t v;
+ (void)((abd) / 2.0); /* check that 'abd' is a number */
+ t2 = CRX_FLOAT_CONST(cb, abd, &v);
+ cb->define_num_const(cb, "abd", t2, &v);
+#expect NUMCONST abd = double 42.000000
+ }
+}
diff --git a/test/codegen/glob-003i.c b/test/codegen/glob-003i.c
new file mode 100644
--- /dev/null
+++ b/test/codegen/glob-003i.c
@@ -0,0 +1,15 @@
+long double const abl = 42.0;
+
+# ____________________________________________________________
+
+void testglob_003i(crx_builder_t *cb)
+{
+ crx_type_t *t1;
+ {
+ crx_num_const_t v;
+ (void)((abl) / 2.0); /* check that 'abl' is a number */
+ t1 = CRX_FLOAT_CONST(cb, abl, &v);
+ cb->define_num_const(cb, "abl", t1, &v);
+#expect NUMCONST abl = long double 42.000000
+ }
+}
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit