changeset 291:19f1168ca1c0 draft

Added five new tests into JavaScriptsTest.
author Pavel Tisnovsky <ptisnovs@redhat.com>
date Fri, 20 Dec 2013 11:03:41 +0100
parents 381ab825c25b
children 1cf2215e04c1
files ChangeLog src/org/RhinoTests/JavaScriptsTest.java
diffstat 2 files changed, 90 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/ChangeLog	Fri Dec 13 10:01:46 2013 +0100
+++ b/ChangeLog	Fri Dec 20 11:03:41 2013 +0100
@@ -1,3 +1,8 @@
+2013-12-20  Pavel Tisnovsky  <ptisnovs@redhat.com>
+
+	* src/org/RhinoTests/JavaScriptsTest.java:
+	Added five new tests into JavaScriptsTest.
+
 2013-12-13  Pavel Tisnovsky  <ptisnovs@redhat.com>
 
 	* src/org/RhinoTests/SimpleBindingsClassTest.java:
--- a/src/org/RhinoTests/JavaScriptsTest.java	Fri Dec 13 10:01:46 2013 +0100
+++ b/src/org/RhinoTests/JavaScriptsTest.java	Fri Dec 20 11:03:41 2013 +0100
@@ -164,6 +164,91 @@
     }
 
     /**
+     * Test if exception is thrown when string contains script with unknown
+     * command.
+     * 
+     * @throws Exception
+     *             this exception is thrown when this test case failed.
+     */
+    protected void testRunScriptContainingError3StoredInString() throws Exception {
+        try {
+            this.scriptEngine.eval("do");
+        } catch (ScriptException e) {
+        	System.out.println("\tException thrown as expected " + e.getMessage());
+            return; // ok, it's correct if this exception is thrown
+        }
+        throw new Exception("ScriptException not thrown as expected");
+    }
+
+    /**
+     * Test if exception is thrown when string contains script with unknown
+     * command.
+     * 
+     * @throws Exception
+     *             this exception is thrown when this test case failed.
+     */
+    protected void testRunScriptContainingError4StoredInString() throws Exception {
+        try {
+            this.scriptEngine.eval("while");
+        } catch (ScriptException e) {
+        	System.out.println("\tException thrown as expected " + e.getMessage());
+            return; // ok, it's correct if this exception is thrown
+        }
+        throw new Exception("ScriptException not thrown as expected");
+    }
+
+    /**
+     * Test if exception is thrown when string contains script with unknown
+     * command.
+     * 
+     * @throws Exception
+     *             this exception is thrown when this test case failed.
+     */
+    protected void testRunScriptContainingError5StoredInString() throws Exception {
+        try {
+            this.scriptEngine.eval("if");
+        } catch (ScriptException e) {
+        	System.out.println("\tException thrown as expected " + e.getMessage());
+            return; // ok, it's correct if this exception is thrown
+        }
+        throw new Exception("ScriptException not thrown as expected");
+    }
+
+    /**
+     * Test if exception is thrown when string contains script with unknown
+     * command.
+     * 
+     * @throws Exception
+     *             this exception is thrown when this test case failed.
+     */
+    protected void testRunScriptContainingError6StoredInString() throws Exception {
+        try {
+            this.scriptEngine.eval("class");
+        } catch (ScriptException e) {
+        	System.out.println("\tException thrown as expected " + e.getMessage());
+            return; // ok, it's correct if this exception is thrown
+        }
+        throw new Exception("ScriptException not thrown as expected");
+    }
+
+    /**
+     * Test if exception is thrown when string contains script with unknown
+     * command.
+     * 
+     * @throws Exception
+     *             this exception is thrown when this test case failed.
+     */
+    protected void testRunScriptContainingError7StoredInString() throws Exception {
+        try {
+            this.scriptEngine.eval("function");
+        } catch (ScriptException e) {
+        	System.out.println("\tException thrown as expected " + e.getMessage());
+            return; // ok, it's correct if this exception is thrown
+        }
+        throw new Exception("ScriptException not thrown as expected");
+    }
+
+    /**
      * Test empty script.
      * 
      * @throws ScriptException