Merged PR 275046: changed broadcast to return promise<void>

changed broadcast to return promise<void>
This commit is contained in:
Asi Bross 2017-05-23 21:24:04 +00:00 коммит произвёл Asi Bross
Родитель 5d8958feff
Коммит fb8175f0d1
4 изменённых файлов: 226 добавлений и 397 удалений

Просмотреть файл

@ -55,18 +55,27 @@ export class NapaZone implements zone.Zone {
return { id: this.id, type: "napa" }; return { id: this.id, type: "napa" };
} }
public broadcast(arg1: any, arg2?: any) : Promise<zone.ResponseCode> { public broadcast(arg1: any, arg2?: any) : Promise<void> {
let source: string = this.createBroadcastSource(arg1, arg2); let source: string = this.createBroadcastSource(arg1, arg2);
return new Promise<zone.ResponseCode>(resolve => { return new Promise<void>((resolve, reject) => {
this._nativeZone.broadcast(source, resolve); this._nativeZone.broadcast(source, (responseCode: number) => {
if (responseCode === 0) {
resolve();
} else {
reject("broadcast failed with response code: " + responseCode);
}
});
}); });
} }
public broadcastSync(arg1: any, arg2?: any) : zone.ResponseCode { public broadcastSync(arg1: any, arg2?: any) : void {
let source: string = this.createBroadcastSource(arg1, arg2); let source: string = this.createBroadcastSource(arg1, arg2);
return this._nativeZone.broadcastSync(source); let responseCode: number = this._nativeZone.broadcastSync(source);
if (responseCode !== 0) {
throw new Error("broadcast failed with response code: " + responseCode);
}
} }
public execute(arg1: any, arg2: any, arg3?: any, arg4?: any) : Promise<zone.ExecuteResult> { public execute(arg1: any, arg2: any, arg3?: any, arg4?: any) : Promise<zone.ExecuteResult> {

Просмотреть файл

@ -11,14 +11,13 @@ export class NodeZone implements zone.Zone {
return { id: this.id, type: "node" }; return { id: this.id, type: "node" };
} }
public broadcast(arg1: any, arg2?: any) : Promise<zone.ResponseCode> { public broadcast(arg1: any, arg2?: any) : Promise<void> {
// TODO @asib: add implementation // TODO @asib: add implementation
return undefined; return undefined;
} }
public broadcastSync(arg1: any, arg2?: any) : zone.ResponseCode { public broadcastSync(arg1: any, arg2?: any) : void {
// TODO @asib: add implementation // TODO @asib: add implementation
return undefined;
} }
public execute(arg1: any, arg2: any, arg3?: any, arg4?: any) : Promise<zone.ExecuteResult> { public execute(arg1: any, arg2: any, arg3?: any, arg4?: any) : Promise<zone.ExecuteResult> {

Просмотреть файл

@ -7,9 +7,6 @@ export interface ZoneSettings {
workers?: number; workers?: number;
} }
/// <summary> The type of the response code. </summary>
export type ResponseCode = number;
/// <summary> Represent the result of an execute call. </summary> /// <summary> Represent the result of an execute call. </summary>
export interface ExecuteResult { export interface ExecuteResult {
@ -31,14 +28,14 @@ export interface Zone {
/// <summary> Compiles and run the provided source code on all zone workers. </summary> /// <summary> Compiles and run the provided source code on all zone workers. </summary>
/// <param name="source"> A valid javascript source code. </param> /// <param name="source"> A valid javascript source code. </param>
broadcast(source: string) : Promise<ResponseCode>; broadcast(source: string) : Promise<void>;
broadcastSync(source: string) : ResponseCode; broadcastSync(source: string) : void;
/// <summary> Compiles the function on all workers and runs it with the given arguments. </summary> /// <summary> Compiles the function on all workers and runs it with the given arguments. </summary>
/// <param name="func"> The JS function. </param> /// <param name="func"> The JS function. </param>
/// <param name="args"> The arguments that will pass to the function. </param> /// <param name="args"> The arguments that will pass to the function. </param>
broadcast(func: Function, args: any[]) : Promise<ResponseCode>; broadcast(func: Function, args: any[]) : Promise<void>;
broadcastSync(func: Function, args: any[]) : ResponseCode; broadcastSync(func: Function, args: any[]) : void;
/// <summary> Executes the function on one of the zone workers. </summary> /// <summary> Executes the function on one of the zone workers. </summary>
/// <param name="module"> The module name that contains the function to execute. </param> /// <param name="module"> The module name that contains the function to execute. </param>

Просмотреть файл

@ -4,7 +4,11 @@ import * as path from "path";
napa.setPlatformSettings({ loggingProvider: "nop" }); napa.setPlatformSettings({ loggingProvider: "nop" });
describe('napajs/zone', () => { describe('napajs/zone', function () {
// disable timeouts.
// promise.then is always fired after mocha test timeout.
this.timeout(0);
let napaZone1: napa.Zone = napa.createZone('napa-zone1'); let napaZone1: napa.Zone = napa.createZone('napa-zone1');
let napaZone2: napa.Zone = napa.createZone('napa-zone2'); let napaZone2: napa.Zone = napa.createZone('napa-zone2');
let napaZoneTestModule: string = path.resolve(__dirname, 'napa-zone/test'); let napaZoneTestModule: string = path.resolve(__dirname, 'napa-zone/test');
@ -79,7 +83,6 @@ describe('napajs/zone', () => {
assert.strictEqual(zone.id, 'node'); assert.strictEqual(zone.id, 'node');
}); });
/// Blocked by bug #2
it('@napa', () => { it('@napa', () => {
let result = napaZone1.executeSync('napajs', "getCurrentZone", []); let result = napaZone1.executeSync('napajs', "getCurrentZone", []);
assert.strictEqual(result.value.id, 'napa-zone1'); assert.strictEqual(result.value.id, 'napa-zone1');
@ -88,225 +91,153 @@ describe('napajs/zone', () => {
describe('broadcast', () => { describe('broadcast', () => {
// TODO #1: implement NodeZone. // TODO #1: implement NodeZone.
it.skip('@node: -> node zone with JavaScript code', (done : (error?: any) => void) => { it.skip('@node: -> node zone with JavaScript code', () => {
/// TODO: change broadcast response code to void and convert non-success to exceptions. return napa.getCurrentZone().broadcast("var state = 0;");
napa.getCurrentZone().broadcast("var state = 0;")
.then((code: number) => {
done();
})
.catch((error) => {
done(error);
});
}); });
// TODO #2: change return value to Promise<void> and use exception/reject to replicate error. it('@node: -> napa zone with JavaScript code', () => {
// Bug #3: promise.then is always fired after mocha test timeout. return napaZone1.broadcast("var state = 0;");
it.skip('@node: -> napa zone with JavaScript code', (done : (error?: any) => void) => {
napaZone1.broadcast("var state = 0;")
.then((code: number) => {
done();
})
.catch((error) => {
done(error);
});
}); });
// TODO #3: better support async target function in broadcast/execute. it('@napa: -> napa zone with JavaScript code', () => {
// Bug #4: zone.broadcast in napa zone will hang forever. return napaZone1.execute(napaZoneTestModule, "broadcast", ["napa-zone2", "var state = 0;"]);
});
// Bug #4: zone.broadcast in the same napa zone will hang forever.
it.skip('@napa: -> napa zone with JavaScript code', () => { it.skip('@napa: -> napa zone with JavaScript code', () => {
let succeed = false; return napaZone1.execute(napaZoneTestModule, "broadcast", ["napa-zone1", "var state = 0;"]);
try {
/// TODO: emit exception on executeSync if execution failed.
let result = napaZone1.executeSync(napaZoneTestModule, "broadcast", ["napa-zone1", "var state = 0;"]);
succeed = true;
}
catch (err) {
console.log(err);
}
finally {
assert(succeed, "should succeed");
}
}); });
// Blocked by TODO #1. // Blocked by TODO #1.
it.skip('@napa: -> node zone with JavaScript code', (done : (error?: any) => void) => { it.skip('@napa: -> node zone with JavaScript code', () => {
/// TODO: emit exception on executeSync if execution failed. return napaZone1.execute(napaZoneTestModule, "broadcast", ["node", "var state = 0;"]);
napaZone1.executeSync(napaZoneTestModule, "broadcast", ["node", "var state = 0;"]);
}); });
// Blocked by Bug #3 it('@node: bad JavaScript code', () => {
it.skip('@node: bad JavaScript code', (done : () => void) => { return napaZone1.broadcast("var state() = 0;")
napaZone1.broadcast("var state() = 0;") .then(() => { assert(false, "Should not succeed"); })
.then(() => { .catch((error: any) => {});
assert(false, "Should not succeed");
})
.catch((error: any) => {
done();
});
}); });
// Bug #5: Empty MaybeLocal, scheduler/worker.cpp: 142. it('@napa: bad JavaScript code', () => {
it.skip('@napa: bad JavaScript code', (done : () => void) => { return napaZone1.execute(napaZoneTestModule, "broadcast", ["napa-zone2", "var state() = 0;"])
napaZone1.executeSync(napaZoneTestModule, "broadcast", ["napa-zone2", "var state() = 0;"]); .then(() => { assert(false, "Should not succeed"); })
.catch((error: any) => {});
}); });
// Blocked by TODO #1. // Blocked by TODO #1.
it.skip('@node: -> node zone throw runtime error', (done : (error?: any) => void) => { it.skip('@node: -> node zone throw runtime error', () => {
napa.getCurrentZone().broadcast("throw new Error();") return napa.getCurrentZone().broadcast("throw new Error();")
.then(() => { .then(() => { assert(false, "Should not succeed"); })
done("Should fail"); .catch((error: any) => {});
})
.catch((error: any) => {
done();
});
}); });
// Blocked by Bug #3. it('@node: -> napa zone throw runtime error', () => {
it.skip('@node: -> napa zone throw runtime error', (done : (error?: any) => void) => { return napaZone1.broadcast("throw new Error();")
napaZone1.broadcast("throw new Error();") .then(() => { assert(false, "Should not succeed"); })
.then((code: number) => { .catch((error: any) => {});
console.log("code:" + code);
done("should fail.");
})
.catch((error: any) => {
console.log(error);
done();
});
}); });
// Blocked by Bug #4. it('@napa: -> napa zone throw runtime error', () => {
it.skip('@napa: -> napa zone throw runtime error', () => { return napaZone1.execute(napaZoneTestModule, "broadcast", ["napa-zone2", "throw new Error();"])
napaZone1.executeSync(napaZoneTestModule, "broadcast", ["napa-zone1", "throw new Error();"]); .then(() => { assert(false, "Should not succeed"); })
.catch((error: any) => {});
}); });
// Blocked by TODO #1. // Blocked by TODO #1.
it.skip('@napa: -> node zone throw runtime error', () => { it.skip('@napa: -> node zone throw runtime error', () => {
napaZone1.executeSync(napaZoneTestModule, "broadcast", ["node", "throw new Error();"]); return napaZone1.execute(napaZoneTestModule, "broadcast", ["node", "throw new Error();"])
.then(() => { assert(false, "Should not succeed"); })
.catch((error: any) => {});
}); });
// Blocked by TODO #1. // Blocked by TODO #1.
it.skip('@node: -> node zone with anonymous function', (done : (error?: any) => void) => { it.skip('@node: -> node zone with anonymous function', () => {
napa.getCurrentZone().broadcast((input: string) => { return napa.getCurrentZone().broadcast((input: string) => {
console.log(input); console.log(input);
}, ['hello world']) }, ['hello world']);
.then((code: number) => {
done();
})
.catch(() => {
assert(false, "Should not fail.");
done();
});
}); });
// Blocked by Bug #3. it('@node: -> napa zone with anonymous function', () => {
it.skip('@node: -> napa zone with anonymous function', (done : (error?: any) => void) => { return napaZone1.broadcast((input: string) => {
napaZone1.broadcast((input: string) => { console.log(input);
console.log(input); }, ['hello world']);
}, ['hello world'])
.then((code: number) => {
done();
})
.catch((error: any) => {
done(error);
});
}); });
// Blocked by Bug #4. it('@napa: -> napa zone with anonymous function', () => {
it.skip('@napa: -> napa zone with anonymous function', () => { return napaZone1.execute(napaZoneTestModule, "broadcastTestFunction", ['napa-zone2']);
napaZone1.executeSync(napaZoneTestModule, "broadcastTestFunction", ['napa-zone1']);
}); });
// Blocked by TODO #1. // Blocked by TODO #1.
it.skip('@napa: -> node zone with anonymous function', (done : () => void) => { it.skip('@napa: -> node zone with anonymous function', () => {
napaZone1.executeSync(napaZoneTestModule, "broadcastTestFunction", ['node']); return napaZone1.execute(napaZoneTestModule, "broadcastTestFunction", ['node']);
}); });
// TODO #4: support transportable args in broadcast. // TODO #4: support transportable args in broadcast.
// Also blocked by TODO #1. // Also blocked by TODO #1.
it.skip('@node: -> node zone with transportable args', (done : () => void) => { it.skip('@node: -> node zone with transportable args', () => {
napa.getCurrentZone().broadcast((allocator: any) => { return napa.getCurrentZone().broadcast((allocator: any) => {
console.log(allocator); console.log(allocator);
}, [napa.memory.crtAllocator]) }, [napa.memory.crtAllocator]);
.then((code: number) => {
done();
})
.catch(() => {
assert(false, "Should not fail.");
done();
});
}); });
/// TODO #4: support transportable tags in broadcast. /// TODO #4: support transportable tags in broadcast.
it.skip('@node: -> napa zone with transportable args', (done : () => void) => { it.skip('@node: -> napa zone with transportable args', () => {
napaZone1.broadcast((allocator: any) => { return napaZone1.broadcast((allocator: any) => {
console.log(allocator); console.log(allocator);
}, [napa.memory.crtAllocator]) }, [napa.memory.crtAllocator]);
.then((code: number) => {
done();
})
.catch(() => {
assert(false, "Should not fail.");
done();
});
}); });
// Blocked by TODO #4. // Blocked by TODO #4.
it.skip('@napa: -> napa zone with transportable args', (done : () => void) => { it.skip('@napa: -> napa zone with transportable args', () => {
napaZone1.executeSync(napaZoneTestModule, "broadcastTransportable", []); return napaZone1.execute(napaZoneTestModule, "broadcastTransportable", []);
}); });
// Blocked by TODO #4. // Blocked by TODO #4.
it.skip('@napa: -> node zone with transportable args', (done : () => void) => { // Also blocked by TODO #1.
napaZone1.executeSync(undefined, "broadcastTransportable", []); it.skip('@napa: -> node zone with transportable args', () => {
return napa.getCurrentZone().execute(napaZoneTestModule, "broadcastTransportable", []);
}); });
// Blocked by TODO #1. // Blocked by TODO #1.
it.skip('@node: -> node zone with anonymous function having closure (should fail)', (done : (error?: any) => void) => { it.skip('@node: -> node zone with anonymous function having closure (should fail)', () => {
napa.getCurrentZone().broadcast(() => { return napa.getCurrentZone().broadcast(() => {
console.log(napaZone1.id); console.log(napaZone1.id);
}, []) }, [])
.then((code: number) => { .then(() => { assert(false, "Should not succeed"); })
done("should fail"); .catch((error: any) => {});
})
.catch((error: any) => {
done();
});
}); });
/// Blocked by Bug #3. it('@node: -> napa zone with anonymous function having closure (should fail)', () => {
it.skip('@node: -> napa zone with anonymous function having closure (should fail)', (done : (error?: any) => void) => { return napaZone1.broadcast(() => {
napaZone1.broadcast(() => { console.log(napaZone1.id);
console.log(napaZone1.id); }, [])
}, []) .then(() => { assert(false, "Should not succeed"); })
.then((code: number) => { .catch((error: any) => {});
done("should fail");
})
.catch((error: any) => {
done();
});
}); });
/// Blocked by Bug #4. it('@napa: -> napa zone with anonymous function having closure (should fail)', () => {
it.skip('@napa: -> napa zone with anonymous function having closure (should fail)', (done : () => void) => { return napaZone1.execute(napaZoneTestModule, "broadcastClosure", ['napa-zone2'])
napaZone1.executeSync(napaZoneTestModule, "broadcastClosure", ['napa-zone1']); .then(() => { assert(false, "Should not succeed"); })
.catch((error: any) => {});
}); });
/// Blocked by TODO #1. /// Blocked by TODO #1.
it.skip('@napa: -> node zone with anonymous function having closure (should fail)', (done : () => void) => { it.skip('@napa: -> node zone with anonymous function having closure (should fail)', () => {
napaZone1.executeSync(napaZoneTestModule, "broadcastClosure", ['node']); return napaZone1.execute(napaZoneTestModule, "broadcastClosure", ['node'])
.then(() => { assert(false, "Should not succeed"); })
.catch((error: any) => {});
}); });
}); });
describe("broadcastSync", () => { describe("broadcastSync", () => {
/// Blocked by TODO #1. /// Blocked by TODO #1.
it.skip('@node: -> node zone with JavaScript code', () => { it.skip('@node: -> node zone with JavaScript code', () => {
let code = napa.getCurrentZone().broadcastSync("var state = 0;"); napa.getCurrentZone().broadcastSync("var state = 0;");
assert.strictEqual(code, 0);
}); });
it('@node: -> napa zone with JavaScript code', () => { it('@node: -> napa zone with JavaScript code', () => {
let code = napaZone1.broadcastSync("var state = 0;"); napaZone1.broadcastSync("var state = 0;");
assert.strictEqual(code, 0);
}); });
// Duplicated with async broadcast version for now. // Duplicated with async broadcast version for now.
@ -315,31 +246,23 @@ describe('napajs/zone', () => {
// Blocked by TODO #1. // Blocked by TODO #1.
// Duplicated with async broadcast version for now. // Duplicated with async broadcast version for now.
it.skip('@napa: -> node zone with JavaScript code', () => { it.skip('@napa: -> node zone with JavaScript code', () => {
}); });
// Blocked by TODO #1. // Blocked by TODO #1.
it.skip('@node: -> node zone with anonymous function', () => { it.skip('@node: -> node zone with anonymous function', () => {
let code = napa.getCurrentZone().broadcastSync( napa.getCurrentZone().broadcastSync((input: string) => {
(input: string) => { console.log(input);
console.log(input); }, ['hello world']);
},
['hello world']);
assert.strictEqual(code, 0);
}); });
it('@node: -> napa zone with anonymous function', () => { it('@node: -> napa zone with anonymous function', () => {
let code = napaZone1.broadcastSync( napaZone1.broadcastSync((input: string) => {
(input: string) => { console.log(input);
console.log(input); }, ['hello world']);
},
['hello world']);
assert.strictEqual(code, 0);
}); });
// Duplicated with async broadcast versin for now. // Duplicated with async broadcast version for now.
it.skip('@napa: -> napa zone with anonymous function', () => { it.skip('@napa: -> napa zone with anonymous function', () => {
}); });
@ -350,23 +273,19 @@ describe('napajs/zone', () => {
// Blocked by TODO #1 // Blocked by TODO #1
it.skip('@node: -> node zone with runtime error', () => { it.skip('@node: -> node zone with runtime error', () => {
let code = napa.getCurrentZone().broadcastSync( assert.throws(() => {
() => { napa.getCurrentZone().broadcastSync(() => {
throw new Error(); throw new Error();
}, }, ['hello world']);
['hello world']); });
assert.strictEqual(code, 0);
}); });
it('@node: -> napa zone with runtime error', () => { it('@node: -> napa zone with runtime error', () => {
let code = napaZone1.broadcastSync( assert.throws(() => {
() => { napaZone1.broadcastSync(() => {
throw new Error(); throw new Error();
}, }, ['hello world']);
['hello world']); });
assert.notStrictEqual(code, 0);
}); });
// Duplicated with async broadcast version for now. // Duplicated with async broadcast version for now.
@ -381,275 +300,180 @@ describe('napajs/zone', () => {
describe('execute', () => { describe('execute', () => {
napa.getCurrentZone().broadcastSync('function foo(input) { return input; }'); napa.getCurrentZone().broadcastSync('function foo(input) { return input; }');
napaZone1.broadcastSync('function foo(input) { return input; }'); napaZone1.broadcastSync('function foo(input) { return input; }');
napaZone2.broadcastSync('function foo(input) { return input; }');
// Blocked by TODO #1. // Blocked by TODO #1.
it.skip('@node: -> node zone with global function name', (done: (error?: any) => void) => { it.skip('@node: -> node zone with global function name', () => {
napa.getCurrentZone().execute("", "foo", ['hello world']) return napa.getCurrentZone().execute("", "foo", ['hello world'])
.then((result: napa.ExecuteResult) => { .then((result: napa.ExecuteResult) => {
if (result.value === 'hello world') { assert.equal(result.value, 'hello world');
done();
}
else {
done(`Expected: 'hello world', Actual: #{result.payload}`);
}
})
.catch(() => {
done("Should not throw exception");
}); });
}); });
// Blocked by Bug #3. it('@node: -> napa zone with global function name', () => {
it.skip('@node: -> napa zone with global function name', (done: (error?: any) => void) => { return napaZone1.execute("", "foo", ['hello world'])
napaZone1.execute("", "foo", ['hello world'])
.then((result: napa.ExecuteResult) => { .then((result: napa.ExecuteResult) => {
if (result.value === 'hello world') { assert.equal(result.value, 'hello world');
done();
}
else {
done(`Expected: 'hello world', Actual: #{result.payload}`);
}
})
.catch(() => {
done("Should not throw exception");
}); });
}); });
// Blocked by TODO #3. it('@napa: -> napa zone with global function name', () => {
it.skip('@napa: -> napa zone with global function name', () => { return napaZone1.execute(napaZoneTestModule, 'execute', ["napa-zone2", "", "foo", ['hello world']])
let result = napaZone1.executeSync(napaZoneTestModule, 'execute', ["napa-zone1", "", "foo", ['hello world']]); .then((result: napa.ExecuteResult) => {
assert.strictEqual(result.value, "hello world"); assert.equal(result.value, 'hello world');
});
}); });
// Blocked by TODO #1 and #3, // Blocked by TODO #1.
it.skip('@napa: -> node zone with global function name', () => { it.skip('@napa: -> node zone with global function name', () => {
let result = napaZone1.executeSync(napaZoneTestModule, 'execute', ["node", "", "foo", ['hello world']]); return napaZone1.execute(napaZoneTestModule, 'execute', ["node", "", "foo", ['hello world']])
assert.strictEqual(result.value, "hello world"); .then((result: napa.ExecuteResult) => {
assert.equal(result.value, 'hello world');
});
}); });
// Blocked by TODO #1. // Blocked by TODO #1.
it.skip('@node: -> node zone with global function name not exists', (done: (error?: any) => void) => { it.skip('@node: -> node zone with global function name not exists', () => {
napa.getCurrentZone().execute("", "foo1", ['hello world']) return napa.getCurrentZone().execute("", "foo1", ['hello world'])
.then((result: napa.ExecuteResult) => { .then((result: napa.ExecuteResult) => { assert(false, "Should not succeed"); })
done('should fail') .catch(() => {});
})
.catch(() => {
done();
});
}); });
// Blocked by Bug #3. it('@node: -> napa zone with global function name not exists', () => {
it.skip('@node: -> napa zone with global function name not exists', (done: (error?: any) => void) => { return napaZone1.execute("", "foo1", ['hello world'])
napaZone1.execute("", "foo1", ['hello world']) .then((result: napa.ExecuteResult) => { assert(false, "Should not succeed"); })
.then((result: napa.ExecuteResult) => { .catch(() => {});
done('should fail')
})
.catch(() => {
done();
});
}); });
it('@napa: -> napa zone with global function name not exists', () => { it('@napa: -> napa zone with global function name not exists', () => {
let succeed = false; return napaZone1.execute(napaZoneTestModule, 'execute', ["napa-zone2", "", "foo1", []])
try { .then((result: napa.ExecuteResult) => { assert(false, "Should not succeed"); })
napaZone1.executeSync(napaZoneTestModule, 'execute', ["napa-zone1", "", "foo1", []]); .catch(() => {});
succeed = true;
}
catch (error) {
}
assert(!succeed);
}); });
// Blocked by TODO #1. // Blocked by TODO #1.
it.skip('@napa: -> node zone with global function name not exists', () => { it.skip('@napa: -> node zone with global function name not exists', () => {
let succeed = false; return napaZone1.execute(napaZoneTestModule, 'execute', ["node", "", "foo1", []])
try { .then((result: napa.ExecuteResult) => { assert(false, "Should not succeed"); })
napaZone1.executeSync(napaZoneTestModule, 'execute', ["node", "", "foo1", []]); .catch(() => {});
succeed = true;
}
catch (error) {
}
assert(!succeed);
}); });
// Blocked by TODO #1. // Blocked by TODO #1.
it.skip('@node: -> node zone with module function name', (done: (error?: any) => void) => { it.skip('@node: -> node zone with module function name', () => {
napa.getCurrentZone().execute(napaZoneTestModule, "bar", ['hello world']) return napa.getCurrentZone().execute(napaZoneTestModule, "bar", ['hello world'])
.then((result: napa.ExecuteResult) => { .then((result: napa.ExecuteResult) => {
if (result.value === 'hello world') { assert.equal(result.value, 'hello world');
done();
}
else {
done(`Expected: 'hello world', Actual: #{result.payload}`);
}
})
.catch(() => {
done("should not fail");
}); });
}); });
// Blocked by Bug #3. it('@node: -> napa zone with module function name', () => {
it.skip('@node: -> napa zone with module function name', (done: (error?: any) => void) => { return napaZone1.execute(napaZoneTestModule, "bar", ['hello world'])
napaZone1.execute(napaZoneTestModule, "bar", ['hello world'])
.then((result: napa.ExecuteResult) => { .then((result: napa.ExecuteResult) => {
if (result.value === 'hello world') { assert.equal(result.value, 'hello world');
done();
}
else {
done(`Expected: 'hello world', Actual: #{result.payload}`);
}
})
.catch(() => {
done("should not fail");
}); });
}); });
it('@napa: -> napa zone with module function name', () => { it('@napa: -> napa zone with module function name', () => {
let result = napaZone1.executeSync(napaZoneTestModule, 'execute', ["napa-zone1", napaZoneTestModule, "bar", ['hello world']]); return napaZone1.execute(napaZoneTestModule, 'execute', ["napa-zone2", napaZoneTestModule, "bar", ['hello world']])
assert.strictEqual(result.value, "hello world"); .then((result: napa.ExecuteResult) => {
assert.equal(result.value, 'hello world');
});
}); });
// Blocked by TODO #1. // Blocked by TODO #1.
it.skip('@napa: -> node zone with module function name', () => { it.skip('@napa: -> node zone with module function name', () => {
let result = napaZone1.executeSync(napaZoneTestModule, 'execute', ["node", napaZoneTestModule, "bar", ['hello world']]); return napaZone1.execute(napaZoneTestModule, 'execute', ["node", napaZoneTestModule, "bar", ['hello world']])
assert.strictEqual(result.value, "hello world"); .then((result: napa.ExecuteResult) => {
assert.equal(result.value, 'hello world');
});
}); });
// Blocked by TODO #1. // Blocked by TODO #1.
it.skip('@node: -> node zone with module not exists', (done: (error?: any) => void) => { it.skip('@node: -> node zone with module not exists', () => {
napa.getCurrentZone().execute("abc", "foo1", ['hello world']) return napa.getCurrentZone().execute("abc", "foo1", ['hello world'])
.then((result: napa.ExecuteResult) => { .then((result: napa.ExecuteResult) => { assert(false, "Should not succeed"); })
done('should fail'); .catch(() => {});
})
.catch(() => {
done();
});
}); });
// Blocked by Bug #3. it('@node: -> napa zone with module not exists', () => {
it.skip('@node: -> napa zone with module not exists', (done: (error?: any) => void) => {
napaZone1.execute("abc", "foo1", ['hello world']) napaZone1.execute("abc", "foo1", ['hello world'])
.then((result: napa.ExecuteResult) => { .then((result: napa.ExecuteResult) => { assert(false, "Should not succeed"); })
done('should fail'); .catch(() => {});
})
.catch(() => {
done();
});
}); });
it('@napa: -> napa zone with module not exists', () => { it('@napa: -> napa zone with module not exists', () => {
let succeed = false; return napaZone1.execute(napaZoneTestModule, 'execute', ["napa-zone2", "abc", "foo1", []])
try { .then((result: napa.ExecuteResult) => { assert(false, "Should not succeed"); })
napaZone1.executeSync(napaZoneTestModule, 'execute', ["napa-zone1", "abc", "foo1", []]); .catch(() => {});
succeed = true;
}
catch (error) {
}
assert(!succeed);
}); });
// Blocked by TODO #1. // Blocked by TODO #1.
it.skip('@napa: -> node zone with module not exists', () => { it.skip('@napa: -> node zone with module not exists', () => {
let succeed = false; return napaZone1.execute(napaZoneTestModule, 'execute', ["node", "abc", "foo1", []])
try { .then((result: napa.ExecuteResult) => { assert(false, "Should not succeed"); })
napaZone1.executeSync(napaZoneTestModule, 'execute', ["node", "abc", "foo1", []]); .catch(() => {});
succeed = true;
}
catch (error) {
}
assert(!succeed);
}); });
// Blocked by TODO #1. // Blocked by TODO #1.
it.skip('@node: -> node zone with module function not exists', (done: (error?: any) => void) => { it.skip('@node: -> node zone with module function not exists', () => {
napa.getCurrentZone().execute(napaZoneTestModule, "foo1", ['hello world']) return napa.getCurrentZone().execute(napaZoneTestModule, "foo1", ['hello world'])
.then((result: napa.ExecuteResult) => { .then((result: napa.ExecuteResult) => { assert(false, "Should not succeed"); })
done('should fail'); .catch(() => {});
})
.catch(() => {
done();
});
}); });
// Blocked by Bug #3. it('@node: -> napa zone with module function not exists', () => {
it.skip('@node: -> napa zone with module function not exists', (done: (error?: any) => void) => { return napaZone1.execute(napaZoneTestModule, "foo1", ['hello world'])
napaZone1.execute(napaZoneTestModule, "foo1", ['hello world']) .then((result: napa.ExecuteResult) => { assert(false, "Should not succeed"); })
.then((result: napa.ExecuteResult) => { .catch(() => {});
done('should fail');
})
.catch(() => {
done();
});
}); });
it('@napa: -> napa zone with module function not exists', () => { it('@napa: -> napa zone with module function not exists', () => {
let succeed = false; return napaZone1.execute(napaZoneTestModule, 'execute', ["napa-zone1", napaZoneTestModule, "foo1", []])
try { .then((result: napa.ExecuteResult) => { assert(false, "Should not succeed"); })
napaZone1.executeSync(napaZoneTestModule, 'execute', ["napa-zone1", napaZoneTestModule, "foo1", []]); .catch(() => {});
succeed = true;
}
catch (error) {
}
assert(!succeed);
}); });
// Blocked by TODO #1. // Blocked by TODO #1.
it.skip('@napa: -> node zone with module function not exists', () => { it.skip('@napa: -> node zone with module function not exists', () => {
let succeed = false; return napaZone1.execute(napaZoneTestModule, 'execute', ["node", napaZoneTestModule, "foo1", []])
try { .then((result: napa.ExecuteResult) => { assert(false, "Should not succeed"); })
napaZone1.executeSync(napaZoneTestModule, 'execute', ["node", napaZoneTestModule, "foo1", []]); .catch(() => {});
succeed = true;
}
catch (error) {
}
assert(!succeed);
}); });
// Blocked by TODO #1. // Blocked by TODO #1 and TODO #5.
it.skip('@node: -> node zone with anonymous function', (done: (error?: any) => void) => { it.skip('@node: -> node zone with anonymous function', () => {
napa.getCurrentZone().execute((input: string) => { return napa.getCurrentZone().execute((input: string) => {
return input; return input;
}, ['hello world']) }, ['hello world'])
.then((result: napa.ExecuteResult) => { .then((result: napa.ExecuteResult) => {
if (result.value === "hello world") { assert.equal(result.value, 'hello world');
done();
}
else {
done(`Expected: 'hello world', Actual: #{result.payload}`);
}
})
.catch(() => {
done();
}); });
}); });
// TODO #5: implment anonymous function in execute/executeSync. // TODO #5: implment anonymous function in execute/executeSync.
it.skip('@node: -> napa zone with anonymous function', (done: (error?: any) => void) => { it.skip('@node: -> napa zone with anonymous function', () => {
napaZone1.execute((input: string) => { return napaZone1.execute((input: string) => {
return input; return input;
}, ['hello world']) }, ['hello world'])
.then((result: napa.ExecuteResult) => { .then((result: napa.ExecuteResult) => {
if (result.value === "hello world") { assert.equal(result.value, 'hello world');
done();
}
else {
done(`Expected: 'hello world', Actual: #{result.payload}`);
}
})
.catch(() => {
done();
}); });
}); });
// Blocked by TODO #5. // Blocked by TODO #5.
it.skip('@napa: -> napa zone with anonymous function', () => { it.skip('@napa: -> napa zone with anonymous function', () => {
let result = napaZone1.executeSync(napaZoneTestModule, 'executeTestFunction', ["napa-zone1"]); return napaZone1.execute(napaZoneTestModule, 'executeTestFunction', ["napa-zone2"])
assert.strictEqual(result.value, "hello world"); .then((result: napa.ExecuteResult) => {
assert.equal(result.value, 'hello world');
});
}); });
// Blocked by TODO #1. // Blocked by TODO #1.
it.skip('@napa: -> node zone with anonymous function', () => { it.skip('@napa: -> node zone with anonymous function', () => {
let result = napaZone1.executeSync(napaZoneTestModule, 'executeTestFunction', ["node"]); return napaZone1.execute(napaZoneTestModule, 'executeTestFunction', ["node"])
assert.strictEqual(result.value, "hello world"); .then((result: napa.ExecuteResult) => {
assert.equal(result.value, 'hello world');
});
}); });
// Blocked by TODO #1. // Blocked by TODO #1.
@ -670,10 +494,10 @@ describe('napajs/zone', () => {
it.skip('@node: -> node zone with transportable args', () => { it.skip('@node: -> node zone with transportable args', () => {
}); });
it('@node: -> napa zone with transportable args', () => { it.skip('@node: -> napa zone with transportable args', () => {
}); });
it('@napa: -> napa zone with transportable args', () => { it.skip('@napa: -> napa zone with transportable args', () => {
}); });
// Blocked by TODO #1. // Blocked by TODO #1.
@ -684,10 +508,10 @@ describe('napajs/zone', () => {
it.skip('@node: -> node zone with transportable returns', () => { it.skip('@node: -> node zone with transportable returns', () => {
}); });
it('@node: -> napa zone with transportable returns', () => { it.skip('@node: -> napa zone with transportable returns', () => {
}); });
it('@napa: -> napa zone with transportable returns', () => { it.skip('@napa: -> napa zone with transportable returns', () => {
}); });
// Blocked by TODO #1. // Blocked by TODO #1.
@ -695,29 +519,29 @@ describe('napajs/zone', () => {
}); });
/// Timeout is not available in node zone. /// Timeout is not available in node zone.
it('@node: -> napa zone with timeout and succeed', () => { it.skip('@node: -> napa zone with timeout and succeed', () => {
}); });
it('@napa: -> napa zone with timeout and succeed', () => { it.skip('@napa: -> napa zone with timeout and succeed', () => {
}); });
/// Timeout is not available in node zone. /// Timeout is not available in node zone.
it('@node: -> napa zone with timed out in JavaScript', () => { it.skip('@node: -> napa zone with timed out in JavaScript', () => {
}); });
it('@napa: -> napa zone with timed out in JavaScript', () => { it.skip('@napa: -> napa zone with timed out in JavaScript', () => {
}); });
it('@node: -> napa zone with timed out in add-on', () => { it.skip('@node: -> napa zone with timed out in add-on', () => {
}); });
it('@napa: -> napa zone with timed out in add-on', () => { it.skip('@napa: -> napa zone with timed out in add-on', () => {
}); });
it('@node: -> napa zone with timed out in multiple hops', () => { it.skip('@node: -> napa zone with timed out in multiple hops', () => {
}); });
it('@napa: -> napa zone with timed out in multiple hops', () => { it.skip('@napa: -> napa zone with timed out in multiple hops', () => {
}); });
}); });