Mercurial > hg > rhino-tests
changeset 351:48afda73ee6e draft
Two new tests added into JavaScriptsTest.
author | Pavel Tisnovsky <ptisnovs@redhat.com> |
---|---|
date | Wed, 09 Apr 2014 13:30:07 +0200 |
parents | 2376dfe0bccd |
children | 9b40969f01e3 |
files | ChangeLog src/org/RhinoTests/JavaScriptSnippets.java src/org/RhinoTests/JavaScriptsTest.java |
diffstat | 3 files changed, 46 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- a/ChangeLog Tue Apr 08 09:57:54 2014 +0200 +++ b/ChangeLog Wed Apr 09 13:30:07 2014 +0200 @@ -1,3 +1,9 @@ +2014-04-09 Pavel Tisnovsky <ptisnovs@redhat.com> + + * src/org/RhinoTests/JavaScriptSnippets.java: + * src/org/RhinoTests/JavaScriptsTest.java: + Two new tests added into JavaScriptsTest. + 2014-04-08 Pavel Tisnovsky <ptisnovs@redhat.com> * src/org/RhinoTests/SimpleScriptContextClassTest.java:
--- a/src/org/RhinoTests/JavaScriptSnippets.java Tue Apr 08 09:57:54 2014 +0200 +++ b/src/org/RhinoTests/JavaScriptSnippets.java Wed Apr 09 13:30:07 2014 +0200 @@ -1,7 +1,7 @@ /* Rhino test framework - Copyright (C) 2012, 2013 Red Hat + Copyright (C) 2012, 2013, 2014 Red Hat This file is part of IcedTea. @@ -213,7 +213,17 @@ protected static final String HELLO_WORLD_3 = "println('\tHello' + ' ' + 'world!')"; /** + * Slightly modified hello world program. + */ + protected static final String HELLO_WORLD_4 = "println('\tHello' + '\t' + 'world!')"; + + /** * Statement containing unknown function. */ protected static final String UNKNOWN_FUNCTION = "_unknown_function_('\tHello world!')"; + + /** + * Statement containing unknown function. + */ + protected static final String UNKNOWN_FUNCTION_2 = "_()"; }
--- a/src/org/RhinoTests/JavaScriptsTest.java Tue Apr 08 09:57:54 2014 +0200 +++ b/src/org/RhinoTests/JavaScriptsTest.java Wed Apr 09 13:30:07 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. @@ -111,6 +111,16 @@ } /** + * Test if it is possible to run script from a string. + * + * @throws ScriptException + * this exception is thrown when this test case failed. + */ + protected void testRunSimpleScriptStoredInString4() throws ScriptException { + this.scriptEngine.eval(JavaScriptSnippets.HELLO_WORLD_4); + } + + /** * Test if exception is thrown when string contains script with unknown * function. * @@ -129,6 +139,24 @@ } /** + * Test if exception is thrown when string contains script with unknown + * function. + * + * @throws Exception + * this exception is thrown when this test case failed. + */ + protected void testRunScriptContainingUnknownFunction2StoredInString() throws Exception { + try { + this.scriptEngine.eval(JavaScriptSnippets.UNKNOWN_FUNCTION_2); + } + 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 bad * parameters. *