Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Autocommit Tue Aug 16 09:52:18 AEST 2016
- Loading branch information
mxro
committed
Aug 15, 2016
1 parent
a804508
commit 3b47b6a
Showing
8 changed files
with
225 additions
and
79 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
59 changes: 59 additions & 0 deletions
59
src/test/java/delight/nashornsandbox/tests/TestSwitch.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
package delight.nashornsandbox.tests; | ||
|
||
import delight.nashornsandbox.NashornSandbox; | ||
import delight.nashornsandbox.NashornSandboxes; | ||
import java.util.concurrent.ExecutorService; | ||
import java.util.concurrent.Executors; | ||
import org.eclipse.xtend2.lib.StringConcatenation; | ||
import org.junit.Test; | ||
|
||
@SuppressWarnings("all") | ||
public class TestSwitch { | ||
@Test | ||
public void test() { | ||
final NashornSandbox sandbox = NashornSandboxes.create(); | ||
try { | ||
sandbox.allowPrintFunctions(true); | ||
sandbox.setMaxCPUTime(50); | ||
ExecutorService _newSingleThreadExecutor = Executors.newSingleThreadExecutor(); | ||
sandbox.setExecutor(_newSingleThreadExecutor); | ||
StringConcatenation _builder = new StringConcatenation(); | ||
_builder.append("var expr = \"one\";"); | ||
_builder.newLine(); | ||
_builder.newLine(); | ||
_builder.append("switch (expr) {"); | ||
_builder.newLine(); | ||
_builder.append(" "); | ||
_builder.append("case \"one\":"); | ||
_builder.newLine(); | ||
_builder.append(" "); | ||
_builder.append("// ok"); | ||
_builder.newLine(); | ||
_builder.append(" "); | ||
_builder.append("break;"); | ||
_builder.newLine(); | ||
_builder.append(" "); | ||
_builder.append("case \"two\":"); | ||
_builder.newLine(); | ||
_builder.append(" "); | ||
_builder.append("// ok"); | ||
_builder.newLine(); | ||
_builder.append(" "); | ||
_builder.append("break;"); | ||
_builder.newLine(); | ||
_builder.append(" "); | ||
_builder.append("default:"); | ||
_builder.newLine(); | ||
_builder.append(" "); | ||
_builder.append("print(\"Unknown expression\");"); | ||
_builder.newLine(); | ||
_builder.append("}"); | ||
_builder.newLine(); | ||
_builder.newLine(); | ||
sandbox.eval(_builder.toString()); | ||
} finally { | ||
ExecutorService _executor = sandbox.getExecutor(); | ||
_executor.shutdown(); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.