Skip to content
This repository has been archived by the owner on Jun 13, 2024. It is now read-only.

API tuning: two minor changes for usability. #29

Merged
merged 2 commits into from
Aug 8, 2017
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Use global.napa in tests
  • Loading branch information
daiyip committed Aug 7, 2017
commit c386a69aad73b34e0d4bd30c19ebadc6a3fdcf21
8 changes: 3 additions & 5 deletions test/napa-zone/test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
import * as assert from 'assert';
import * as path from "path";
import * as napa from '../../lib/index';
let napaDir: string = path.resolve(__dirname, '../..');

export function bar(input: any) {
return input;
Expand Down Expand Up @@ -95,12 +94,11 @@ export function executeTestFunctionWithTimeout(id: string, waitTimeInMS: number,
export function executeWithTransportableArgs(id: string): Promise<any> {
let zone = napa.zone.get(id);
return new Promise((resolve, reject) => {
zone.execute((allocator: napa.memory.Allocator, napaDir: string) => {
zone.execute((allocator: napa.memory.Allocator) => {
var assert = require("assert");
var napa = require(napaDir);
assert.deepEqual(allocator.handle, napa.memory.crtAllocator.handle);
assert.deepEqual(allocator.handle, (<any>global).napa.memory.crtAllocator.handle);
return 1;
}, [napa.memory.crtAllocator, napaDir])
}, [napa.memory.crtAllocator])
.then ((result: napa.zone.Result) => resolve(result.value))
.catch((error: any) => reject(error));
});
Expand Down
15 changes: 6 additions & 9 deletions test/zone-test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
import * as assert from "assert";
import * as path from "path";
import * as napa from "../lib/index";
let napaDir: string = path.resolve(__dirname, '..');

type Zone = napa.zone.Zone;

Expand Down Expand Up @@ -460,19 +459,17 @@ describe('napajs/zone', function () {
});

it('@node: -> node zone with transportable args', () => {
return napa.zone.current.execute((allocator: napa.memory.Allocator, napaDir: string) => {
return napa.zone.current.execute((allocator: napa.memory.Allocator) => {
var assert = require("assert");
var napa = require(napaDir);
assert.deepEqual(allocator.handle, napa.memory.crtAllocator.handle);
}, [napa.memory.crtAllocator, napaDir]);
assert.deepEqual(allocator.handle, (<any>global).napa.memory.crtAllocator.handle);
}, [napa.memory.crtAllocator]);
});

it('@node: -> napa zone with transportable args', () => {
return napaZone1.execute((allocator: napa.memory.Allocator, napaDir: string) => {
return napaZone1.execute((allocator: napa.memory.Allocator) => {
var assert = require("assert");
var napa = require(napaDir);
assert.deepEqual(allocator.handle, napa.memory.crtAllocator.handle);
}, [napa.memory.crtAllocator, napaDir]);
assert.deepEqual(allocator.handle, (<any>global).napa.memory.crtAllocator.handle);
}, [napa.memory.crtAllocator]);
});

it('@napa: -> napa zone with transportable args', () => {
Expand Down