Oh snap. Start using async+await.

git-svn-id: https://www.unprompted.com/svn/projects/tildefriends/trunk@3285 ed5197a5-7fde-0310-b194-c3ffbd925b24
This commit is contained in:
Cory McWilliams 2016-07-24 17:02:45 +00:00
parent d1eefc249d
commit cca505ff01
2 changed files with 27 additions and 0 deletions

View File

@ -67,6 +67,10 @@ int main(int argc, char* argv[]) {
gPlatform = v8::platform::CreateDefaultPlatform();
v8::V8::InitializePlatform(gPlatform);
v8::V8::Initialize();
const char* kAsyncAwait = "--harmony-async-await";
v8::V8::SetFlagsFromString(kAsyncAwait, std::strlen(kAsyncAwait));
v8::V8::SetFlagsFromCommandLine(&argc, argv, true);
bool isChild = false;

23
tests/10-await Normal file
View File

@ -0,0 +1,23 @@
#!/bin/bash
cat > test.js << EOF
print("hi");
function foobar() {
return new Promise(function (resolve, reject) {
resolve(10);
});
}
async function huh() {
let v = await foobar();
print("v => " + v);
if (v != 10) {
throw new Error("nope");
}
}
huh();
EOF
$TILDEFRIENDS test.js