diff --git a/src/main.cpp b/src/main.cpp index 29a68ea7..0d2484e2 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -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; diff --git a/tests/10-await b/tests/10-await new file mode 100644 index 00000000..a6cd986d --- /dev/null +++ b/tests/10-await @@ -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