I wondering how to deal with programatically created promises (`jerry_promise()`) and `jerry_run_jobs()` call or (calls !)
I try to implement a setTimeout native function that returns a promise.

script:
```
  new Promise(function(resolve) {
    resolve('Hello, World!');
  })
  .then(function(x) {
    print(x);
    return setTimeout(1000);
  })
  .then(function(x) {
    print('timeout Ok');
  })
```

pseudo main.c (partially from [API-REFERENCE](https://github.com/jerryscript-project/jerryscript/blob/master/docs/02.API-REFERENCE.md#jerry_run_jobs))
```
  run the script
  while (true)
    ret = jerry_run_jobs()
    if ret is not an exception
      break;
```

output:
```
Hello, World!
```
... I also expect to see "timeout Ok"


- should I assume that the running script still have pending promises even if `jerry_run_jobs()` returns `undefined` ?
  - if so, how to detect that my running script has no more pending promise (and then I can gracefully exit) ?
- should I use `jerry_promise_on_event` to count my promises, and exit if it reach 0 ?





using jerry_promise() and  jerry_run_jobs() call(s)
This is a GitHub Issue
repo:jerryscript
owner:jerryscript-project
Title : using jerry_promise() and  jerry_run_jobs() call(s)
Issue date:

--- start body ---
I wondering how to deal with programatically created promises (`jerry_promise()`) and `jerry_run_jobs()` call or (calls !)
I try to implement a setTimeout native function that returns a promise.

script:
```
  new Promise(function(resolve) {
    resolve('Hello, World!');
  })
  .then(function(x) {
    print(x);
    return setTimeout(1000);
  })
  .then(function(x) {
    print('timeout Ok');
  })
```

pseudo main.c (partially from [API-REFERENCE](https://github.com/jerryscript-project/jerryscript/blob/master/docs/02.API-REFERENCE.md#jerry_run_jobs))
```
  run the script
  while (true)
    ret = jerry_run_jobs()
    if ret is not an exception
      break;
```

output:
```
Hello, World!
```
... I also expect to see "timeout Ok"


- should I assume that the running script still have pending promises even if `jerry_run_jobs()` returns `undefined` ?
  - if so, how to detect that my running script has no more pending promise (and then I can gracefully exit) ?
- should I use `jerry_promise_on_event` to count my promises, and exit if it reach 0 ?





--- end body ---

None