aboutsummaryrefslogtreecommitdiffstats
path: root/src/junit/com/jogamp/gluegen/test
diff options
context:
space:
mode:
authorSven Gothel <[email protected]>2015-03-25 12:45:41 +0100
committerSven Gothel <[email protected]>2015-03-25 12:45:41 +0100
commitd30a3ea54e26978d6ff199cba0fd79c5c0cef483 (patch)
treee772b1e8acf627e2e7ad4bec56148f75dd5e7d7b /src/junit/com/jogamp/gluegen/test
parent6058af19f2929a39deb0dbcc48040a4bb53bb559 (diff)
Bug 1149: Fix parsing of hexadecimal w/ binary exponent floats in regexp-constant and java-parser. (Due to PCPP -> JCPP)
Lack of parsing binary exponent floats is exposed due to using JCPP and correct constant-definitions. - JavaParser.g: - Add support for hexadecimal w/ binary exponent floats - TAB -> 4 spaces - ConstantDefinition.java: - Add RegExp 'fpRegexp', patternDecimalNumber: decimal number w/ support for hexadecimal w/ binary exponent floats. - isDecimalNumber(..): Use patternDecimalNumber instead of try-and-error (NumberFormatException) - patternCPPOperand: exclude patternDecimalNumber! - JavaEmitter.java: - Respect explicit suffix [dD] for double type. - Drop floating point suffixes [fF] - Test: Added tests for hexadecimal w/ binary exponent floats
Diffstat (limited to 'src/junit/com/jogamp/gluegen/test')
-rw-r--r--src/junit/com/jogamp/gluegen/test/junit/generation/BaseClass.java34
-rw-r--r--src/junit/com/jogamp/gluegen/test/junit/generation/test1.h16
2 files changed, 48 insertions, 2 deletions
diff --git a/src/junit/com/jogamp/gluegen/test/junit/generation/BaseClass.java b/src/junit/com/jogamp/gluegen/test/junit/generation/BaseClass.java
index 32ec496..b5f4f2c 100644
--- a/src/junit/com/jogamp/gluegen/test/junit/generation/BaseClass.java
+++ b/src/junit/com/jogamp/gluegen/test/junit/generation/BaseClass.java
@@ -73,6 +73,8 @@ public class BaseClass extends SingletonJunitCase {
(obj instanceof com.jogamp.gluegen.test.junit.generation.Bindingtest1));
}
+ public static final float EPSILON = 1.1920929E-7f; // Float.MIN_VALUE == 1.4e-45f ; double EPSILON 2.220446049250313E-16d
+
/**
* Verifies if all generated method signatures are completed,
* ie a compilation only coverage test without functional tests.
@@ -122,6 +124,36 @@ public class BaseClass extends SingletonJunitCase {
Assert.assertEquals( 8, Bindingtest1.NUMBER_EIGHT);
Assert.assertEquals( 9, Bindingtest1.NUMBER_NINE);
Assert.assertEquals( 10, Bindingtest1.NUMBER_TEN);
+
+
+ // Floating point hexadecimals
+ final float CL_FLT_A0 = Bindingtest1.CL_FLT_A0;
+ final float CL_FLT_A1 = Bindingtest1.CL_FLT_A1;
+ final float CL_FLT_A2 = Bindingtest1.CL_FLT_A2;
+ Assert.assertEquals( 0x1.p127f, CL_FLT_A0, EPSILON);
+ Assert.assertEquals( 0x1.p+127F, CL_FLT_A1, EPSILON);
+ Assert.assertEquals( 0x1.p-127f, CL_FLT_A2, EPSILON);
+
+ final float CL_FLT_EPSILON = Bindingtest1.CL_FLT_EPSILON;
+ final double CL_FLT_MAX= Bindingtest1.CL_FLT_MAX;
+ final double CL_FLT_MIN = Bindingtest1.CL_FLT_MIN;
+ Assert.assertEquals( 0x1.0p-23f, CL_FLT_EPSILON, EPSILON);
+ Assert.assertEquals( 0x1.fffffep127f, CL_FLT_MAX, EPSILON);
+ Assert.assertEquals( 0x1.0p-126f, CL_FLT_MIN, EPSILON);
+
+ final double CL_DBL_B0 = Bindingtest1.CL_DBL_B0;
+ final double CL_DBL_B1 = Bindingtest1.CL_DBL_B1;
+ final double CL_DBL_B2 = Bindingtest1.CL_DBL_B2;
+ Assert.assertEquals( 0x1.p127d, CL_DBL_B0, EPSILON);
+ Assert.assertEquals( 0x1.p+127D, CL_DBL_B1, EPSILON);
+ Assert.assertEquals( 0x1.p-127d, CL_DBL_B2, EPSILON);
+
+ final float CL_DBL_EPSILON = Bindingtest1.CL_DBL_EPSILON;
+ final double CL_DBL_MAX= Bindingtest1.CL_DBL_MAX;
+ final double CL_DBL_MIN = Bindingtest1.CL_DBL_MIN;
+ Assert.assertEquals( 0x1.0p-52f, CL_DBL_EPSILON, EPSILON);
+ Assert.assertEquals( 0x1.fffffffffffffp1023, CL_DBL_MAX, EPSILON);
+ Assert.assertEquals( 0x1.0p-1022, CL_DBL_MIN, EPSILON);
}
{
l = binding.testXID(l);
@@ -1233,8 +1265,6 @@ public class BaseClass extends SingletonJunitCase {
}
}
- public static final float EPSILON = 1.1920929E-7f; // Float.MIN_VALUE == 1.4e-45f ; double EPSILON 2.220446049250313E-16d
-
/** Test array and pointer bindings of structs */
public void chapter12TestStructArrayModelConst(final Bindingtest1 binding) throws Exception {
final TK_ModelConst model = binding.createModelConst();
diff --git a/src/junit/com/jogamp/gluegen/test/junit/generation/test1.h b/src/junit/com/jogamp/gluegen/test/junit/generation/test1.h
index fa876c6..4e60114 100644
--- a/src/junit/com/jogamp/gluegen/test/junit/generation/test1.h
+++ b/src/junit/com/jogamp/gluegen/test/junit/generation/test1.h
@@ -39,6 +39,22 @@ typedef void * AnonBuffer; // Non Opaque
// typedef XID XID_2; // Duplicate w/ compatible type (ignored) - OpenSolaris: Native gcc error
// typedef int XID_2; // Duplicate w/ incompatible type ERROR
+#define CL_FLT_A0 0x1p127
+#define CL_FLT_A1 0x1p+127F
+#define CL_FLT_A2 0x1p-127f
+
+#define CL_DBL_B0 0x1.p127d
+#define CL_DBL_B1 0x1.p+127D
+#define CL_DBL_B2 0x1.p-127d
+
+#define CL_FLT_MAX 0x1.fffffep127f
+#define CL_FLT_MIN 0x1.0p-126f
+#define CL_FLT_EPSILON 0x1.0p-23f
+
+#define CL_DBL_MAX 0x1.fffffffffffffp1023
+#define CL_DBL_MIN 0x1.0p-1022
+#define CL_DBL_EPSILON 0x1.0p-52
+
#define DEFINE_01 1234
#define DEFINE_01 1234 // Duplicate w/ same value (ignored)
// #define DEFINE_01 1235 // Duplicate w/ diff value ERROR