Mercurial > hg > rhino-tests
changeset 67:24686f9e632a draft
Added new code snippets into src/org/RhinoTests/JavaScriptSnippets.java.
Added new tests to the test suite src/org/RhinoTests/JavaScriptsTest.java.
author | Pavel Tisnovsky <ptisnovs@redhat.com> |
---|---|
date | Thu, 22 Nov 2012 10:38:39 +0100 |
parents | cfb582c14406 |
children | 4876f3e3df53 |
files | ChangeLog src/org/RhinoTests/JavaScriptSnippets.java src/org/RhinoTests/JavaScriptsTest.java |
diffstat | 3 files changed, 50 insertions(+), 3 deletions(-) [+] |
line wrap: on
line diff
--- a/ChangeLog Wed Nov 21 13:25:06 2012 +0100 +++ b/ChangeLog Thu Nov 22 10:38:39 2012 +0100 @@ -1,3 +1,11 @@ +2012-11-22 Pavel Tisnovsky <ptisnovs@redhat.com> + + * src/org/RhinoTests/JavaScriptSnippets.java: + Added new code snippets. + + * src/org/RhinoTests/JavaScriptsTest.java: + Added new tests. + 2012-11-21 Pavel Tisnovsky <ptisnovs@redhat.com> * src/org/RhinoTests/CompilableTest.java:
--- a/src/org/RhinoTests/JavaScriptSnippets.java Wed Nov 21 13:25:06 2012 +0100 +++ b/src/org/RhinoTests/JavaScriptSnippets.java Thu Nov 22 10:38:39 2012 +0100 @@ -82,4 +82,23 @@ */ protected static final String NUMERIC_EXPRESSION_1 = "1+2*3"; + /** + * Classical hello world program. + */ + protected static final String HELLO_WORLD_1 = "println('\tHello world!')"; + + /** + * Slightly modified hello world program. + */ + protected static final String HELLO_WORLD_2 = "println('\tHello' + ' world!')"; + + /** + * Slightly modified hello world program. + */ + protected static final String HELLO_WORLD_3 = "println('\tHello' + ' ' + 'world!')"; + + /** + * Statement containing unknown function. + */ + protected static final String UNKNOWN_FUNCTION = "_unknown_function_('\tHello world!')"; }
--- a/src/org/RhinoTests/JavaScriptsTest.java Wed Nov 21 13:25:06 2012 +0100 +++ b/src/org/RhinoTests/JavaScriptsTest.java Thu Nov 22 10:38:39 2012 +0100 @@ -86,8 +86,28 @@ * @throws ScriptException * this exception is thrown when this test case failed. */ - protected void testRunSimpleScriptStoredInString() throws ScriptException { - this.scriptEngine.eval("println('\tHello world!')"); + protected void testRunSimpleScriptStoredInString1() throws ScriptException { + this.scriptEngine.eval(JavaScriptSnippets.HELLO_WORLD_1); + } + + /** + * Test if it is possible to run script from a string. + * + * @throws ScriptException + * this exception is thrown when this test case failed. + */ + protected void testRunSimpleScriptStoredInString2() throws ScriptException { + this.scriptEngine.eval(JavaScriptSnippets.HELLO_WORLD_2); + } + + /** + * Test if it is possible to run script from a string. + * + * @throws ScriptException + * this exception is thrown when this test case failed. + */ + protected void testRunSimpleScriptStoredInString3() throws ScriptException { + this.scriptEngine.eval(JavaScriptSnippets.HELLO_WORLD_3); } /** @@ -99,7 +119,7 @@ */ protected void testRunScriptContainingUnknownFunctionStoredInString() throws Exception { try { - this.scriptEngine.eval("_unknown_function_('\tHello world!')"); + this.scriptEngine.eval(JavaScriptSnippets.UNKNOWN_FUNCTION); } catch (ScriptException e) { System.out.println("\tException thrown as expected " + e.getMessage());