-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
issue #8 - rhino support refinements
- Loading branch information
1 parent
d5c5a31
commit 63bfebc
Showing
8 changed files
with
161 additions
and
14 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,5 +6,3 @@ | |
* TYPESCRIPT EXPORTED DECLARATIONS | ||
* | ||
*/ | ||
|
||
|
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
// | ||
// STARTUP | ||
// | ||
|
||
load('classpath:jvm-npm.js'); | ||
|
||
require.paths = [ | ||
"src/main/ts", | ||
"target/ts/src/main/ts", | ||
"target/ts/target" | ||
]; | ||
|
||
java.lang.System.setProperty( "jvm-npm.debug", "false"); | ||
|
||
|
||
// PLOYFILL | ||
//The $ENV variable provides the shell environment variables. | ||
//The $ARG variable is an array of the program command-line arguments. | ||
print( "args", $ARG.length ); | ||
|
||
var process = { argv:$ARG, env:{TERM:'color'} } ; | ||
|
||
var exports = {}; | ||
load('target/ts/src/main/ts/main.rhino.js'); |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
import { | ||
CompletableFuture, | ||
Executor, | ||
Optional, | ||
RuntimeException | ||
} from "ts/jdk8-types"; | ||
|
||
function doSometing() { | ||
return CompletableFuture.completedFuture("DONE!"); | ||
} | ||
|
||
function error(msg:string) { | ||
throw msg; | ||
} | ||
|
||
export function test() { | ||
print(` | ||
======================================== | ||
CompletableFuture TEST | ||
======================================== | ||
`); | ||
|
||
const currentThreadExecutor = new Executor( { execute: runnable => runnable.run() } ); | ||
|
||
let future = CompletableFuture.supplyAsync( { get: () => { | ||
|
||
//throw "ERROR0" | ||
return "complete"; | ||
|
||
}}, currentThreadExecutor ); | ||
|
||
|
||
future | ||
//.thenApply( result => {throw "ERROR1"} ) | ||
.thenAccept( { accept: result => print(result) } ) | ||
.exceptionally( { apply: (err) => print( "ERROR:", err ) } ) | ||
; | ||
|
||
let future1 = CompletableFuture.supplyAsync( { get: () => { | ||
|
||
Optional.ofNullable( null ).orElseThrow( { get: () => new RuntimeException("RTE") } ) | ||
|
||
return "complete1"; | ||
|
||
}}, currentThreadExecutor); | ||
|
||
|
||
future1 | ||
.thenApply( { apply: result => error("ERROR1") } ) | ||
.exceptionally( { apply: err => print( "ERROR 1:", err ) } ) | ||
.thenAccept( { accept: result => error("ERROR2") } ) | ||
.exceptionally( { apply: (err) => print( "ERROR 2:", err ) } ) | ||
; | ||
|
||
let future2 = doSometing().thenAccept( { accept: result => print(result) } ); | ||
|
||
} |
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,37 @@ | ||
|
||
import {test as future_test} from "./future.test.rhino"; | ||
|
||
import { | ||
URI, | ||
Optional, | ||
MemoryType, | ||
} from "ts/jdk8-types"; | ||
|
||
|
||
const u1 = "http://localhost:8000/site/"; | ||
const u2 = "/spaces/flyingpdf/pdfpageexport.action?pageId=100532618"; | ||
const u3 = "http://localhost:8000/spaces/flyingpdf/pdfpageexport.action?pageId=100532618"; | ||
|
||
let uri = URI.create( u1 ); | ||
|
||
print( uri.resolve( u2 ).toString() ); | ||
print( URI.create( u1 + u2 ).normalize().toString() ); | ||
print( uri.resolve( u3 ).toString() ); | ||
|
||
print( Optional.empty().map( { apply:e => "element: " + e } ).orElse("nil") ); | ||
print( Optional.of("HELLO").map( { apply:e => "element: " + e } ).orElse("nil") ); | ||
|
||
|
||
// TEST ENUM | ||
|
||
print(MemoryType.HEAP); | ||
print(MemoryType.HEAP.name()); | ||
print(MemoryType.HEAP.ordinal()); | ||
|
||
/* | ||
color_test(); | ||
mustache_test(); | ||
validator_test(); | ||
stream_test(); | ||
*/ | ||
future_test(); |