Fix tests

This commit is contained in:
konsoletyper 2015-02-15 19:40:49 +04:00
parent e8803390d2
commit b4c3bc47f0
2 changed files with 14 additions and 1 deletions

View File

@ -438,7 +438,7 @@ public class TeaVM implements TeaVMHost, ServiceRepository {
sourceWriter.append("var ").append(entry.getKey()).ws().append("=").ws();
boolean wrapAsync = !asyncMethods.contains(entry.getValue().reference) && entry.getValue().isAsync();
if (wrapAsync) {
sourceWriter.append("$rt_asyncAdapter(");
sourceWriter.append("$rt_staticAsyncAdapter(");
}
sourceWriter.appendMethodBody(entry.getValue().reference);
if (wrapAsync) {

View File

@ -459,6 +459,19 @@ function $rt_asyncError(e) {
throw e;
}
}
function $rt_staticAsyncAdapter(f) {
return function() {
var result;
var args = Array.prototype.slice.apply(arguments);
var $return = args.pop();
try {
result = f.apply(this, args);
} catch (e) {
return $return($rt_asyncError(e));
}
return $return($rt_asyncResult(result));
}
}
function $rt_asyncAdapter(f) {
return function() {
var result;