Add runtime option "--call-on-exit [FUNCNAME]" to main-unix.c (#3518)

With this option you can call a function after the user script and promises have ran, to be able to do assertions that are executed just before the process would exit.

JerryScript-DCO-1.0-Signed-off-by: Daniel Balla dballa@inf.u-szeged.hu
This commit is contained in:
Daniel Balla
2020-01-15 17:10:42 +01:00
committed by Robert Fancsik
parent 4a331b2edc
commit 332e216736
3 changed files with 45 additions and 7 deletions
@@ -13,8 +13,9 @@
// limitations under the License.
Object.defineProperty(Array.prototype, 0, { get : function () { throw $; } });
var asyncPassed = false;
Promise.race([ , this]).then(Error).catch(function(err) { asyncPassed = (err instanceof ReferenceError); });
new Promise(function() {
throw 5;
}).then(Error).catch(function() { assert(asyncPassed); });
var global_err = undefined;
Promise.race([ , this]).then(Error).catch(function(err) { global_err = err; });
function __checkAsync() {
assert(global_err instanceof ReferenceError);
}