From cca505ff01357ef8a48fa395d5acce6969aa5601 Mon Sep 17 00:00:00 2001 From: Cory McWilliams Date: Sun, 24 Jul 2016 17:02:45 +0000 Subject: [PATCH] Oh snap. Start using async+await. git-svn-id: https://www.unprompted.com/svn/projects/tildefriends/trunk@3285 ed5197a5-7fde-0310-b194-c3ffbd925b24 --- src/main.cpp | 4 ++++ tests/10-await | 23 +++++++++++++++++++++++ 2 files changed, 27 insertions(+) create mode 100644 tests/10-await 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