/hg/rhino-tests: Updated ScriptEngineClassTest to work correctly...

ptisnovs at icedtea.classpath.org ptisnovs at icedtea.classpath.org
Thu Feb 28 02:09:15 PST 2013


changeset 90ac8a0ff3c4 in /hg/rhino-tests
details: http://icedtea.classpath.org/hg/rhino-tests?cmd=changeset;node=90ac8a0ff3c4
author: Pavel Tisnovsky <ptisnovs at redhat.com>
date: Thu Feb 28 11:12:22 2013 +0100

	Updated ScriptEngineClassTest to work correctly with JDK6 and JDK7 too.


diffstat:

 ChangeLog                                     |   5 ++
 src/org/RhinoTests/ScriptEngineClassTest.java |  57 ++++++++++++++++++++++----
 2 files changed, 53 insertions(+), 9 deletions(-)

diffs (129 lines):

diff -r 80c161c5a145 -r 90ac8a0ff3c4 ChangeLog
--- a/ChangeLog	Wed Feb 27 09:52:42 2013 +0100
+++ b/ChangeLog	Thu Feb 28 11:12:22 2013 +0100
@@ -1,3 +1,8 @@
+2013-02-28  Pavel Tisnovsky  <ptisnovs at redhat.com>
+
+	* src/org/RhinoTests/ScriptEngineClassTest.java:
+	Updated to work correctly with JDK6 and JDK7 too.
+
 2013-02-27  Pavel Tisnovsky  <ptisnovs at redhat.com>
 
 	* src/org/RhinoTests/CompilableClassTest.java:
diff -r 80c161c5a145 -r 90ac8a0ff3c4 src/org/RhinoTests/ScriptEngineClassTest.java
--- a/src/org/RhinoTests/ScriptEngineClassTest.java	Wed Feb 27 09:52:42 2013 +0100
+++ b/src/org/RhinoTests/ScriptEngineClassTest.java	Thu Feb 28 11:12:22 2013 +0100
@@ -388,7 +388,7 @@
      */
     protected void testGetFields() {
         // following fields should exists
-        final String[] fieldsThatShouldExists = {
+        final String[] fieldsThatShouldExist_jdk6 = {
             "public static final java.lang.String javax.script.ScriptEngine.ARGV",
             "public static final java.lang.String javax.script.ScriptEngine.FILENAME",
             "public static final java.lang.String javax.script.ScriptEngine.ENGINE",
@@ -397,6 +397,19 @@
             "public static final java.lang.String javax.script.ScriptEngine.LANGUAGE",
             "public static final java.lang.String javax.script.ScriptEngine.LANGUAGE_VERSION",
         };
+        final String[] fieldsThatShouldExist_jdk7 = {
+            "public static final java.lang.String javax.script.ScriptEngine.ARGV",
+            "public static final java.lang.String javax.script.ScriptEngine.FILENAME",
+            "public static final java.lang.String javax.script.ScriptEngine.ENGINE",
+            "public static final java.lang.String javax.script.ScriptEngine.ENGINE_VERSION",
+            "public static final java.lang.String javax.script.ScriptEngine.NAME",
+            "public static final java.lang.String javax.script.ScriptEngine.LANGUAGE",
+            "public static final java.lang.String javax.script.ScriptEngine.LANGUAGE_VERSION",
+        };
+
+        // get the right array of field signatures
+        final String[] fieldsThatShouldExist = getJavaVersion() < 7 ? fieldsThatShouldExist_jdk6 : fieldsThatShouldExist_jdk7;
+
         // get all fields
         Field[] fields = this.scriptEngineClass.getFields();
         // and transform the array into a list of field names
@@ -405,7 +418,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");
         }
@@ -415,8 +428,8 @@
      * Test for method javax.script.ScriptEngine.getClass().getDeclaredFields()
      */
     protected void testGetDeclaredFields() {
-        // following fields should be declared
-        final String[] fieldsThatShouldExists = {
+        // following declared fields should exists
+        final String[] declaredFieldsThatShouldExist_jdk6 = {
             "public static final java.lang.String javax.script.ScriptEngine.ARGV",
             "public static final java.lang.String javax.script.ScriptEngine.FILENAME",
             "public static final java.lang.String javax.script.ScriptEngine.ENGINE",
@@ -425,6 +438,20 @@
             "public static final java.lang.String javax.script.ScriptEngine.LANGUAGE",
             "public static final java.lang.String javax.script.ScriptEngine.LANGUAGE_VERSION",
         };
+        final String[] declaredFieldsThatShouldExist_jdk7 = {
+            "public static final java.lang.String javax.script.ScriptEngine.ARGV",
+            "public static final java.lang.String javax.script.ScriptEngine.FILENAME",
+            "public static final java.lang.String javax.script.ScriptEngine.ENGINE",
+            "public static final java.lang.String javax.script.ScriptEngine.ENGINE_VERSION",
+            "public static final java.lang.String javax.script.ScriptEngine.NAME",
+            "public static final java.lang.String javax.script.ScriptEngine.LANGUAGE",
+            "public static final java.lang.String javax.script.ScriptEngine.LANGUAGE_VERSION",
+        };
+
+        // get the right array of field signatures
+        // following fields should be declared
+        final String[] declaredFieldsThatShouldExist = getJavaVersion() < 7 ? declaredFieldsThatShouldExist_jdk6 : declaredFieldsThatShouldExist_jdk7;
+
         // get all declared fields
         Field[] declaredFields = this.scriptEngineClass.getDeclaredFields();
         // and transform the array into a list of field names
@@ -433,9 +460,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");
         }
     }
 
@@ -444,7 +471,7 @@
      */
     protected void testGetField() {
         // following fields should exists
-        final String[] fieldsThatShouldExists = {
+        final String[] fieldsThatShouldExist_jdk6 = {
             "ARGV",
             "FILENAME",
             "ENGINE",
@@ -453,8 +480,20 @@
             "LANGUAGE",
             "LANGUAGE_VERSION",
         };
+        final String[] fieldsThatShouldExist_jdk7 = {
+            "ARGV",
+            "FILENAME",
+            "ENGINE",
+            "ENGINE_VERSION",
+            "NAME",
+            "LANGUAGE",
+            "LANGUAGE_VERSION",
+        };
+
+        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.scriptEngineClass.getField(fieldThatShouldExists);
                 String fieldName = field.getName();



More information about the distro-pkg-dev mailing list