/hg/rhino-tests: Several new tests added into InvocableTest.

ptisnovs at icedtea.classpath.org ptisnovs at icedtea.classpath.org
Thu Apr 24 08:00:41 UTC 2014


changeset 6fcf6a73fde4 in /hg/rhino-tests
details: http://icedtea.classpath.org/hg/rhino-tests?cmd=changeset;node=6fcf6a73fde4
author: Pavel Tisnovsky <ptisnovs at redhat.com>
date: Thu Apr 24 10:01:24 2014 +0200

	Several new tests added into InvocableTest.


diffstat:

 ChangeLog                             |   5 ++
 src/org/RhinoTests/InvocableTest.java |  64 ++++++++++++++++++++++++++++++++++-
 2 files changed, 68 insertions(+), 1 deletions(-)

diffs (107 lines):

diff -r 6cb1ff232c39 -r 6fcf6a73fde4 ChangeLog
--- a/ChangeLog	Tue Apr 15 13:19:41 2014 +0200
+++ b/ChangeLog	Thu Apr 24 10:01:24 2014 +0200
@@ -1,3 +1,8 @@
+2014-04-24  Pavel Tisnovsky  <ptisnovs at redhat.com>
+
+	* src/org/RhinoTests/InvocableTest.java:
+	Several new tests added into InvocableTest.
+
 2014-04-15  Pavel Tisnovsky  <ptisnovs at redhat.com>
 
 	* src/org/RhinoTests/BindingsTest.java:
diff -r 6cb1ff232c39 -r 6fcf6a73fde4 src/org/RhinoTests/InvocableTest.java
--- a/src/org/RhinoTests/InvocableTest.java	Tue Apr 15 13:19:41 2014 +0200
+++ b/src/org/RhinoTests/InvocableTest.java	Thu Apr 24 10:01:24 2014 +0200
@@ -1,7 +1,7 @@
 /*
   Rhino test framework
 
-   Copyright (C) 2011  Red Hat
+   Copyright (C) 2011, 2012, 2013, 2014  Red Hat
 
 This file is part of IcedTea.
 
@@ -83,6 +83,36 @@
     protected void testInvokeFunction() throws ScriptException, NoSuchMethodException {
         final String script =
             "function foo() {" +
+            "}";
+        this.scriptEngine.eval(script);
+        this.invocableEngine.invokeFunction("foo");
+    }
+
+    /**
+     * Test the JavaScript method invocation.
+     * 
+     * @throws ScriptException in case there's something wrong in JS engine.
+     * @throws NoSuchMethodException if wrong method is called.
+     */
+    protected void testInvokeFunction2() throws ScriptException, NoSuchMethodException {
+        final String script =
+            "function foo() {" +
+            "    println('\tHello, world!');" +
+            "}";
+        this.scriptEngine.eval(script);
+        this.invocableEngine.invokeFunction("foo");
+    }
+
+    /**
+     * Test the JavaScript method invocation.
+     * 
+     * @throws ScriptException in case there's something wrong in JS engine.
+     * @throws NoSuchMethodException if wrong method is called.
+     */
+    protected void testInvokeFunction3() throws ScriptException, NoSuchMethodException {
+        final String script =
+            "function foo() {" +
+            "    println('\tHello, world!');" +
             "    println('\tHello, world!');" +
             "}";
         this.scriptEngine.eval(script);
@@ -126,6 +156,36 @@
     }
 
     /**
+     * Test invocation of method containing parameters.
+     *
+     * @throws ScriptException in case there's something wrong in JS engine.
+     * @throws NoSuchMethodException if wrong method is called.
+     */
+    protected void testInvokeFunctionWithParameters2() throws ScriptException, NoSuchMethodException {
+        final String script =
+            "function printHello(str1, val2) {" +
+            "    println('\t' + str1 + ' ' + val2);" +
+            "}";
+        this.scriptEngine.eval(script);
+        this.invocableEngine.invokeFunction("printHello", "hello", 42);
+    }
+
+    /**
+     * Test invocation of method containing parameters.
+     *
+     * @throws ScriptException in case there's something wrong in JS engine.
+     * @throws NoSuchMethodException if wrong method is called.
+     */
+    protected void testInvokeFunctionWithParameters3() throws ScriptException, NoSuchMethodException {
+        final String script =
+            "function printHello(val1, str2) {" +
+            "    println('\t' + val1 + ' ' + str2);" +
+            "}";
+        this.scriptEngine.eval(script);
+        this.invocableEngine.invokeFunction("printHello", 42, "world!");
+    }
+
+    /**
      * Prints all properties of Java object.
      * 
      * @throws ScriptException in case there's something wrong in JS engine.
@@ -234,6 +294,8 @@
         assertTrue(result.doubleValue() == 4.6, "function returns incorrect value " + result);
         result = (Double)this.invocableEngine.invokeFunction("plus", Double.valueOf(0), Double.valueOf(1.1));
         assertTrue(result.doubleValue() == 1.1, "function returns incorrect value " + result);
+        result = (Double)this.invocableEngine.invokeFunction("plus", Double.valueOf(1.1), Double.valueOf(0));
+        assertTrue(result.doubleValue() == 1.1, "function returns incorrect value " + result);
         result = (Double)this.invocableEngine.invokeFunction("plus", Double.valueOf(-1.234), Double.valueOf(1.234));
         assertTrue(result.doubleValue() == 0, "function returns incorrect value " + result);
     }


More information about the distro-pkg-dev mailing list