Bug 1185106 - Part 11.2: Add helper functions for async/await test. r=till
authorTooru Fujisawa <arai_a@mac.com>
Mon, 29 Aug 2016 02:06:19 +0900
changeset 320247 61f472bbdbc1d8a095d1375e59423027fd736e70
parent 320246 5ab01476a1ccebc49962acd2737980fa6ec1f69f
child 320248 4bfb6261bdc98c47a4cc3b5d42ee89667e6016df
push id20754
push usercbook@mozilla.com
push dateMon, 31 Oct 2016 15:58:35 +0000
treeherderfx-team@b1b66b1780c2 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerstill
bugs1185106
milestone52.0a1
Bug 1185106 - Part 11.2: Add helper functions for async/await test. r=till MozReview-Commit-ID: B3lwv5ejz5g
js/src/tests/ecma_7/AsyncFunctions/shell.js
--- a/js/src/tests/ecma_7/AsyncFunctions/shell.js
+++ b/js/src/tests/ecma_7/AsyncFunctions/shell.js
@@ -0,0 +1,26 @@
+(function(global) {
+  function getPromiseResult(promise) {
+    var result, error, caught = false;
+    promise.then(r => { result = r; },
+                 e => { caught = true; error = e; });
+    drainJobQueue();
+    if (caught)
+      throw error;
+    return result;
+  }
+
+  function assertEventuallyEq(promise, expected) {
+    assertEq(getPromiseResult(promise), expected);
+  }
+  global.assertEventuallyEq = assertEventuallyEq;
+
+  function assertEventuallyThrows(promise, expectedErrorType) {
+    assertThrowsInstanceOf(() => getPromiseResult(promise), expectedErrorType);
+  };
+  global.assertEventuallyThrows = assertEventuallyThrows;
+
+  function assertEventuallyDeepEq(promise, expected) {
+    assertDeepEq(getPromiseResult(promise), expected);
+  };
+  global.assertEventuallyDeepEq = assertEventuallyDeepEq;
+})(this);