/hg/rhino-tests: One new test added into BindingsClassTest test ...

ptisnovs at icedtea.classpath.org ptisnovs at icedtea.classpath.org
Mon Jan 28 00:55:22 PST 2013


changeset 5920d0eeed31 in /hg/rhino-tests
details: http://icedtea.classpath.org/hg/rhino-tests?cmd=changeset;node=5920d0eeed31
author: Pavel Tisnovsky <ptisnovs at redhat.com>
date: Mon Jan 28 09:58:25 2013 +0100

	One new test added into BindingsClassTest test suite, updated two
	other tests to be JDK-version independent.


diffstat:

 ChangeLog                                 |   6 ++
 src/org/RhinoTests/BindingsClassTest.java |  66 +++++++++++++++++++++++++-----
 2 files changed, 60 insertions(+), 12 deletions(-)

diffs (128 lines):

diff -r 58a5ce1ad7bd -r 5920d0eeed31 ChangeLog
--- a/ChangeLog	Fri Jan 25 10:36:06 2013 +0100
+++ b/ChangeLog	Mon Jan 28 09:58:25 2013 +0100
@@ -1,3 +1,9 @@
+2013-01-28  Pavel Tisnovsky  <ptisnovs at redhat.com>
+
+	* src/org/RhinoTests/BindingsClassTest.java:
+	One new test added into BindingsClassTest test suite, updated two
+	other tests to be JDK-version independent.
+
 2013-01-25  Pavel Tisnovsky  <ptisnovs at redhat.com>
 
 	* src/org/RhinoTests/CompilableClassTest.java:
diff -r 58a5ce1ad7bd -r 5920d0eeed31 src/org/RhinoTests/BindingsClassTest.java
--- a/src/org/RhinoTests/BindingsClassTest.java	Fri Jan 25 10:36:06 2013 +0100
+++ b/src/org/RhinoTests/BindingsClassTest.java	Mon Jan 28 09:58:25 2013 +0100
@@ -388,9 +388,14 @@
      */
     protected void testGetFields() {
         // following fields should exists
-        final String[] fieldsThatShouldExists = {
-            // this should be really empty
+        final String[] fieldsThatShouldExist_jdk6 = {
         };
+        final String[] fieldsThatShouldExist_jdk7 = {
+        };
+
+        // get the right array of field signatures
+        final String[] fieldsThatShouldExist = getJavaVersion() < 7 ? fieldsThatShouldExist_jdk6 : fieldsThatShouldExist_jdk7;
+
         // get all fields
         Field[] fields = this.bindingsClass.getFields();
         // and transform the array into a list of field names
@@ -399,7 +404,7 @@
             fieldsAsString.add(field.toString());
         }
         // check if all required fields really exists
-        for (String fieldThatShouldExists : fieldsThatShouldExists) {
+        for (String fieldThatShouldExists : fieldsThatShouldExist) {
             assertTrue(fieldsAsString.contains(fieldThatShouldExists),
                     "field " + fieldThatShouldExists + " not found");
         }
@@ -409,10 +414,16 @@
      * Test for method javax.script.Bindings.getClass().getDeclaredFields()
      */
     protected void testGetDeclaredFields() {
+        // following declared fields should exists
+        final String[] declaredFieldsThatShouldExist_jdk6 = {
+        };
+        final String[] declaredFieldsThatShouldExist_jdk7 = {
+        };
+
+        // get the right array of field signatures
         // following fields should be declared
-        final String[] fieldsThatShouldExists = {
-            // this should be really empty
-        };
+        final String[] declaredFieldsThatShouldExist = getJavaVersion() < 7 ? declaredFieldsThatShouldExist_jdk6 : declaredFieldsThatShouldExist_jdk7;
+
         // get all declared fields
         Field[] declaredFields = this.bindingsClass.getDeclaredFields();
         // and transform the array into a list of field names
@@ -421,9 +432,9 @@
             declaredFieldsAsString.add(field.toString());
         }
         // check if all required fields really exists
-        for (String fieldThatShouldExists : fieldsThatShouldExists) {
-            assertTrue(declaredFieldsAsString.contains(fieldThatShouldExists),
-                    "field " + fieldThatShouldExists + " not found");
+        for (String declaredFieldThatShouldExists : declaredFieldsThatShouldExist) {
+            assertTrue(declaredFieldsAsString.contains(declaredFieldThatShouldExists),
+                    "field " + declaredFieldThatShouldExists + " not found");
         }
     }
 
@@ -432,11 +443,15 @@
      */
     protected void testGetField() {
         // following fields should exists
-        final String[] fieldsThatShouldExists = {
-            // this should be really empty
+        final String[] fieldsThatShouldExist_jdk6 = {
         };
+        final String[] fieldsThatShouldExist_jdk7 = {
+        };
+
+        final String[] fieldsThatShouldExist = getJavaVersion() < 7 ? fieldsThatShouldExist_jdk6 : fieldsThatShouldExist_jdk7;
+
         // check if all required fields really exists
-        for (String fieldThatShouldExists : fieldsThatShouldExists) {
+        for (String fieldThatShouldExists : fieldsThatShouldExist) {
             try {
                 Field field = this.bindingsClass.getField(fieldThatShouldExists);
                 String fieldName = field.getName();
@@ -451,6 +466,33 @@
     }
 
     /**
+     * Test for method javax.script.Bindings.getClass().getDeclaredField()
+     */
+    protected void testGetDeclaredField() {
+        // following declared fields should exists
+        final String[] declaredFieldsThatShouldExist_jdk6 = {
+        };
+        final String[] declaredFieldsThatShouldExist_jdk7 = {
+        };
+
+        final String[] declaredFieldsThatShouldExist = getJavaVersion() < 7 ? declaredFieldsThatShouldExist_jdk6 : declaredFieldsThatShouldExist_jdk7;
+
+        // check if all required declared fields really exists
+        for (String declaredFieldThatShouldExists : declaredFieldsThatShouldExist) {
+            try {
+                Field field = this.bindingsClass.getDeclaredField(declaredFieldThatShouldExists);
+                String fieldName = field.getName();
+                assertTrue(fieldName.equals(declaredFieldThatShouldExists),
+                        "field " + declaredFieldThatShouldExists + " not found");
+            }
+            catch (Exception e) {
+                e.printStackTrace();
+                throw new AssertionError(e.getMessage());
+            }
+        }
+    }
+
+    /**
      * Test for method javax.script.Bindings.getClass().getMethods()
      */
     protected void testGetMethods() {



More information about the distro-pkg-dev mailing list