| // Copyright (C) 2018 Leo Balter. All rights reserved. |
| // This code is governed by the BSD license found in the LICENSE file. |
| |
| /*--- |
| desc: Private Async Method |
| template: private-methods |
| features: [async-functions] |
| flags: [async] |
| ---*/ |
| |
| //- setup |
| var ctorPromise; |
| |
| //- element |
| async #m() { return 42; } |
| |
| //- constructor |
| assert.sameValue(this.#m.name, '#m', 'function name inside constructor'); |
| ctorPromise = this.#m().then(value => { |
| assert.sameValue(value, 42, 'already defined in the ctor'); |
| }, $DONE); |
| |
| //- assertions |
| assert.sameValue(c.ref.name, '#m', 'function name is preserved external reference'); |
| ctorPromise.then(() => { |
| // gets the returned promise from #m |
| return c.ref().then(value => { |
| assert.sameValue(value, 42, 'function return'); |
| }); |
| }).then($DONE, $DONE); |