-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
substack
authored and
substack
committed
Mar 1, 2017
1 parent
06a47d1
commit fe8c57b
Showing
3 changed files
with
34 additions
and
1 deletion.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,7 @@ | ||
language: node_js | ||
node_js: | ||
- "5" | ||
- "7" | ||
- "6" | ||
- "4" | ||
- "0.12" | ||
- "0.10" | ||
|
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 @@ | ||
var browserify = require('../'); | ||
var fs = require('fs'); | ||
var vm = require('vm'); | ||
var test = require('tap').test; | ||
|
||
var src = fs.readFileSync(__dirname + '/async/src.js','utf8'); | ||
var canAsync = true; | ||
try { Function(src) } catch (err) { canAsync = false } | ||
|
||
if (!canAsync) console.error('# async/await unsupported in this environment') | ||
else test('async/await', function (t) { | ||
t.plan(2); | ||
var b = browserify(__dirname + '/async/src.js'); | ||
b.bundle(function (err, src) { | ||
t.error(err) | ||
var c = { | ||
console: { log: log }, | ||
setTimeout: setTimeout, | ||
clearTimeout: clearTimeout | ||
} | ||
vm.runInNewContext(src, c); | ||
function log (msg) { t.equal(msg, 60) } | ||
}); | ||
}); |
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,8 @@ | ||
function f (x) { return new Promise(resolve => { | ||
process.nextTick(() => { resolve(x) }) }) } | ||
|
||
async function add (x) { | ||
return x + await f(20) + await f(30) | ||
} | ||
|
||
add(10).then(v => { console.log(v) }) |