/hg/rhino-tests: Added new test into ScriptExceptionClassTest: t...

ptisnovs at icedtea.classpath.org ptisnovs at icedtea.classpath.org
Tue Feb 26 00:37:48 PST 2013


changeset e37cbf8fe30a in /hg/rhino-tests
details: http://icedtea.classpath.org/hg/rhino-tests?cmd=changeset;node=e37cbf8fe30a
author: Pavel Tisnovsky <ptisnovs at redhat.com>
date: Tue Feb 26 09:40:55 2013 +0100

	Added new test into ScriptExceptionClassTest: testGetDeclaredField(),
	fixed typos in other tests.


diffstat:

 ChangeLog                                        |   6 +
 src/org/RhinoTests/ScriptExceptionClassTest.java |  88 +++++++++++++++++++----
 2 files changed, 77 insertions(+), 17 deletions(-)

diffs (193 lines):

diff -r 03ffeaf6d1c4 -r e37cbf8fe30a ChangeLog
--- a/ChangeLog	Mon Feb 25 10:22:01 2013 +0100
+++ b/ChangeLog	Tue Feb 26 09:40:55 2013 +0100
@@ -1,3 +1,9 @@
+2013-02-26  Pavel Tisnovsky  <ptisnovs at redhat.com>
+
+	* src/org/RhinoTests/ScriptExceptionClassTest.java:
+	Added new test into ScriptExceptionClassTest: testGetDeclaredField(),
+	fixed typos in other tests.
+
 2013-02-25  Pavel Tisnovsky  <ptisnovs at redhat.com>
 
 	* src/org/RhinoTests/ScriptExceptionClassTest.java:
diff -r 03ffeaf6d1c4 -r e37cbf8fe30a src/org/RhinoTests/ScriptExceptionClassTest.java
--- a/src/org/RhinoTests/ScriptExceptionClassTest.java	Mon Feb 25 10:22:01 2013 +0100
+++ b/src/org/RhinoTests/ScriptExceptionClassTest.java	Tue Feb 26 09:40:55 2013 +0100
@@ -435,8 +435,14 @@
      */
     protected void testGetFields() {
         // following fields should exists
-        final String[] fieldsThatShouldExists = {
+        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.scriptExceptionClass.getFields();
         // and transform the array into a list of field names
@@ -445,7 +451,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");
         }
@@ -455,12 +461,22 @@
      * Test for method javax.script.ScriptException.getClass().getDeclaredFields()
      */
     protected void testGetDeclaredFields() {
-        // following fields should be declared
-        final String[] fieldsThatShouldExists = {
+        // following declared fields should exists
+        final String[] declaredFieldsThatShouldExist_jdk6 = {
             "private java.lang.String javax.script.ScriptException.fileName",
             "private int javax.script.ScriptException.lineNumber",
             "private int javax.script.ScriptException.columnNumber",
         };
+        final String[] declaredFieldsThatShouldExist_jdk7 = {
+            "private java.lang.String javax.script.ScriptException.fileName",
+            "private int javax.script.ScriptException.lineNumber",
+            "private int javax.script.ScriptException.columnNumber",
+        };
+
+        // 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.scriptExceptionClass.getDeclaredFields();
         // and transform the array into a list of field names
@@ -469,9 +485,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");
         }
     }
 
@@ -480,10 +496,15 @@
      */
     protected void testGetField() {
         // following fields should exists
-        final String[] fieldsThatShouldExists = {
+        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.scriptExceptionClass.getField(fieldThatShouldExists);
                 String fieldName = field.getName();
@@ -498,11 +519,44 @@
     }
 
     /**
+     * Test for method javax.script.ScriptException.getClass().getDeclaredField()
+     */
+    protected void testGetDeclaredField() {
+        // following declared fields should exists
+        final String[] declaredFieldsThatShouldExist_jdk6 = {
+            "fileName",
+            "lineNumber",
+            "columnNumber",
+        };
+        final String[] declaredFieldsThatShouldExist_jdk7 = {
+            "fileName",
+            "lineNumber",
+            "columnNumber",
+        };
+
+        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.scriptExceptionClass.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.ScriptException.getClass().getMethods()
      */
     protected void testGetMethods() {
         // following methods should be inherited
-        final String[] methodsThatShouldExists_jdk6 = {
+        final String[] methodsThatShouldExist_jdk6 = {
             "public boolean java.lang.Object.equals(java.lang.Object)",
             "public final native java.lang.Class java.lang.Object.getClass()",
             "public final native void java.lang.Object.notify()",
@@ -527,7 +581,7 @@
             "public void java.lang.Throwable.setStackTrace(java.lang.StackTraceElement[])",
         };
 
-        final String[] methodsThatShouldExists_jdk7 = {
+        final String[] methodsThatShouldExist_jdk7 = {
             "public boolean java.lang.Object.equals(java.lang.Object)",
             "public final native java.lang.Class java.lang.Object.getClass()",
             "public final native void java.lang.Object.notify()",
@@ -561,9 +615,9 @@
         for (Method method : methods) {
             methodsAsString.add(method.toString());
         }
-        String[] methodsThatShouldExists = getJavaVersion() < 7 ? methodsThatShouldExists_jdk6 : methodsThatShouldExists_jdk7;
+        String[] methodsThatShouldExist = getJavaVersion() < 7 ? methodsThatShouldExist_jdk6 : methodsThatShouldExist_jdk7;
         // check if all required methods really exists
-        for (String methodThatShouldExists : methodsThatShouldExists) {
+        for (String methodThatShouldExists : methodsThatShouldExist) {
             assertTrue(methodsAsString.contains(methodThatShouldExists),
                     "method " + methodThatShouldExists + " not found");
         }
@@ -574,14 +628,14 @@
      */
     protected void testGetDeclaredMethods() {
         // following methods should be declared
-        final String[] declaredMethodsThatShouldExists_jdk6 = {
+        final String[] declaredMethodsThatShouldExist_jdk6 = {
             "public int javax.script.ScriptException.getColumnNumber()",
             "public int javax.script.ScriptException.getLineNumber()",
             "public java.lang.String javax.script.ScriptException.getFileName()",
             "public java.lang.String javax.script.ScriptException.getMessage()",
         };
 
-        final String[] declaredMethodsThatShouldExists_jdk7 = {
+        final String[] declaredMethodsThatShouldExist_jdk7 = {
             "public int javax.script.ScriptException.getColumnNumber()",
             "public int javax.script.ScriptException.getLineNumber()",
             "public java.lang.String javax.script.ScriptException.getFileName()",
@@ -595,9 +649,9 @@
         for (Method method : declaredMethods) {
             methodsAsString.add(method.toString());
         }
-        String[] declaredMethodsThatShouldExists = getJavaVersion() < 7 ? declaredMethodsThatShouldExists_jdk6 : declaredMethodsThatShouldExists_jdk7;
+        String[] declaredMethodsThatShouldExist = getJavaVersion() < 7 ? declaredMethodsThatShouldExist_jdk6 : declaredMethodsThatShouldExist_jdk7;
         // check if all required methods really exists
-        for (String methodThatShouldExists : declaredMethodsThatShouldExists) {
+        for (String methodThatShouldExists : declaredMethodsThatShouldExist) {
             assertTrue(methodsAsString.contains(methodThatShouldExists),
                     "declared method " + methodThatShouldExists + " not found");
         }



More information about the distro-pkg-dev mailing list