Mercurial > hg > rhino-tests
changeset 66:cfb582c14406 draft
Added five new tests into src/org/RhinoTests/CompilableTest.java.
Added new code snippets into src/org/RhinoTests/JavaScriptSnippets.java.
author | Pavel Tisnovsky <ptisnovs@redhat.com> |
---|---|
date | Wed, 21 Nov 2012 13:25:06 +0100 |
parents | 94369d709381 |
children | 24686f9e632a |
files | ChangeLog src/org/RhinoTests/CompilableTest.java src/org/RhinoTests/JavaScriptSnippets.java |
diffstat | 3 files changed, 109 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/ChangeLog Tue Nov 20 10:23:57 2012 +0100 +++ b/ChangeLog Wed Nov 21 13:25:06 2012 +0100 @@ -1,3 +1,11 @@ +2012-11-21 Pavel Tisnovsky <ptisnovs@redhat.com> + + * src/org/RhinoTests/CompilableTest.java: + Added five new tests. + + * src/org/RhinoTests/JavaScriptSnippets.java: + Added new code snippets. + 2012-11-20 Pavel Tisnovsky <ptisnovs@redhat.com> * src/org/RhinoTests/JavaScriptSnippets.java:
--- a/src/org/RhinoTests/CompilableTest.java Tue Nov 20 10:23:57 2012 +0100 +++ b/src/org/RhinoTests/CompilableTest.java Wed Nov 21 13:25:06 2012 +0100 @@ -123,7 +123,7 @@ * @throws ScriptException * this exception is thrown when this test case failed. */ - protected void testCompileScriptStoredInString1() throws ScriptException { + protected void testCompileEmptyScriptStoredInString1() throws ScriptException { Compilable compilingEngine = (Compilable)this.scriptEngine; assertNotNull(compilingEngine, "cannot get compiling engine"); if (compilingEngine != null) { @@ -133,6 +133,81 @@ } /** + * Test if it is possible to compile script from a string. + * + * @throws ScriptException + * this exception is thrown when this test case failed. + */ + protected void testCompileEmptyScriptStoredInString2() throws ScriptException { + Compilable compilingEngine = (Compilable)this.scriptEngine; + assertNotNull(compilingEngine, "cannot get compiling engine"); + if (compilingEngine != null) { + CompiledScript script = compilingEngine.compile(JavaScriptSnippets.EMPTY_SCRIPT_2); + assertNotNull(script, "cannot compile script"); + } + } + + /** + * Test if it is possible to compile script from a string. + * + * @throws ScriptException + * this exception is thrown when this test case failed. + */ + protected void testCompileEmptyScriptStoredInString3() throws ScriptException { + Compilable compilingEngine = (Compilable)this.scriptEngine; + assertNotNull(compilingEngine, "cannot get compiling engine"); + if (compilingEngine != null) { + CompiledScript script = compilingEngine.compile(JavaScriptSnippets.EMPTY_SCRIPT_3); + assertNotNull(script, "cannot compile script"); + } + } + + /** + * Test if it is possible to compile script from a string. + * + * @throws ScriptException + * this exception is thrown when this test case failed. + */ + protected void testCompileEmptyScriptStoredInString4() throws ScriptException { + Compilable compilingEngine = (Compilable)this.scriptEngine; + assertNotNull(compilingEngine, "cannot get compiling engine"); + if (compilingEngine != null) { + CompiledScript script = compilingEngine.compile(JavaScriptSnippets.EMPTY_SCRIPT_4); + assertNotNull(script, "cannot compile script"); + } + } + + /** + * Test if it is possible to compile script from a string. + * + * @throws ScriptException + * this exception is thrown when this test case failed. + */ + protected void testCompileEmptyScriptStoredInString5() throws ScriptException { + Compilable compilingEngine = (Compilable)this.scriptEngine; + assertNotNull(compilingEngine, "cannot get compiling engine"); + if (compilingEngine != null) { + CompiledScript script = compilingEngine.compile(JavaScriptSnippets.EMPTY_SCRIPT_5); + assertNotNull(script, "cannot compile script"); + } + } + + /** + * Test if it is possible to compile script from a string. + * + * @throws ScriptException + * this exception is thrown when this test case failed. + */ + protected void testCompileEmptyScriptStoredInString6() throws ScriptException { + Compilable compilingEngine = (Compilable)this.scriptEngine; + assertNotNull(compilingEngine, "cannot get compiling engine"); + if (compilingEngine != null) { + CompiledScript script = compilingEngine.compile(JavaScriptSnippets.EMPTY_SCRIPT_6); + assertNotNull(script, "cannot compile script"); + } + } + + /** * Test if it is possible to compile and then run script from a string. * * @throws ScriptException
--- a/src/org/RhinoTests/JavaScriptSnippets.java Tue Nov 20 10:23:57 2012 +0100 +++ b/src/org/RhinoTests/JavaScriptSnippets.java Wed Nov 21 13:25:06 2012 +0100 @@ -53,6 +53,31 @@ protected static final String EMPTY_SCRIPT_1 = ""; /** + * Almost empty, but still valid script. + */ + protected static final String EMPTY_SCRIPT_2 = " "; + + /** + * Almost empty, but still valid script. + */ + protected static final String EMPTY_SCRIPT_3 = "\t"; + + /** + * Almost empty, but still valid script. + */ + protected static final String EMPTY_SCRIPT_4 = " \t"; + + /** + * Almost empty, but still valid script. + */ + protected static final String EMPTY_SCRIPT_5 = " \t "; + + /** + * Almost empty, but still valid script. + */ + protected static final String EMPTY_SCRIPT_6 = " \t \t "; + + /** * Numeric expression. */ protected static final String NUMERIC_EXPRESSION_1 = "1+2*3";