-
Notifications
You must be signed in to change notification settings - Fork 65
Fix Async.Promise tests for test stabiligy even with MacVim #713
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
2f68967
1f84c67
1d77b74
4609809
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,17 @@ | ||
function! s:wait_has_key(obj, name) abort | ||
return s:wait_has_key_with_timeout(a:obj, a:name, 5) | ||
endfunction | ||
|
||
function! s:wait_has_key_with_timeout(obj, name, timeout_sec) abort | ||
let i = 0 | ||
while i < 500 | ||
while i < a:timeout_sec * 100 | ||
sleep 10m | ||
if has_key(a:obj, a:name) | ||
return | ||
endif | ||
let i += 1 | ||
endwhile | ||
throw printf("s:wait_has_key(): After 5000ms, the given object does not have key '%s': %s", a:name, a:obj) | ||
throw printf("s:wait_has_key(): After %ds, the given object does not have key '%s': %s", a:timeout_sec, a:name, a:obj) | ||
endfunction | ||
|
||
function! s:resolver(resolve, reject) abort | ||
|
@@ -606,10 +610,10 @@ Describe Async.Promise | |
\ P.resolve(P.resolve(P.resolve(P.resolve(42)))), | ||
\ P.resolve(Wait(10).then({-> 42})) | ||
\ ] | ||
Assert Equals(p._state, FULFILLED) | ||
let l = l: | ||
call p.then({x -> extend(l, {'result' : x})}) | ||
call s:wait_has_key(l, 'result') | ||
Assert Equals(p._state, FULFILLED) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 📚
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise/resolve Thus Nice catch 🎉 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yay! |
||
Assert Equals(result, 42) | ||
unlet result | ||
endfor | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
may
I feel it's better to remove
s:wait_has_key_with_timeout
and make a single functions:wait_has_key
becauses:wait_has_key()
so it's a bit confusingThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Makes sense, thanks! How's this? #714