Skip to content

Test Fail: MacVim latest (2019 fall) Async.Promise resolve test fails #698

@tsuyoshicho

Description

@tsuyoshicho

MacVim tests fail recently (as of 2019-11) as

Failures:
  1) Async.Promise .resolve() should create resolved Promise with given Promise value
     Error occurred line:
       2:         Assert Equals(p._state, FULFILLED)
     The equivalent values were expected, but it was not the case.
     
         expected: 1
              got: 0

e.g.

https://travis-ci.org/vim-jp/vital.vim/jobs/611141864

I guess I should issue at MacVim if it's MacVim specific. It seems like it's a timing problem since it sometimes succeeds.

These are the targeted tests. Please check these if you have MacVim. I don't have MacVim env locally.

" need vim-jp/vital.vim install

function! s:wait_has_key(obj, name) abort
  let i = 0
  while i < 500
    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)
endfunction

function s:testsuite() abort
  let P = vital#vital#import('Async.Promise')

  " Utilities
  let Wait = {ms -> P.new({res -> timer_start(ms, res)})}
  for p in [
        \   P.resolve(P.resolve(42)),
        \   P.resolve(P.resolve(P.resolve(P.resolve(42)))),
        \   P.resolve(Wait(10).then({-> 42}))
        \ ]
    let l = l:
    call p.then({x -> extend(l, {'result' : x})})
    call s:wait_has_key(l, 'result')
    echo result
    unlet result
  endfor
endfunction

call s:testsuite()

Note that these succeed quickly in my non-MacVim Vim.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions