(name, formals_and_body, args, handler, continuation)
| 8 | var global_marker = 7; |
| 9 | |
| 10 | function RunTest(name, formals_and_body, args, handler, continuation) { |
| 11 | var handler_called = false; |
| 12 | var exception = null; |
| 13 | |
| 14 | function listener(event, exec_state, event_data, data) { |
| 15 | try { |
| 16 | if (event == Debug.DebugEvent.Break) { |
| 17 | handler_called = true; |
| 18 | handler(exec_state); |
| 19 | } |
| 20 | } catch (e) { |
| 21 | exception = e; |
| 22 | } |
| 23 | } |
| 24 | |
| 25 | function run(thunk) { |
| 26 | handler_called = false; |
| 27 | exception = null; |
| 28 | |
| 29 | var res = thunk(); |
| 30 | if (continuation) |
| 31 | continuation(res); |
| 32 | |
| 33 | assertTrue(handler_called, "listener not called for " + name); |
| 34 | assertNull(exception, name + " / " + exception); |
| 35 | } |
| 36 | |
| 37 | var fun = Function.apply(null, formals_and_body); |
| 38 | var gen = (function*(){}).constructor.apply(null, formals_and_body); |
| 39 | |
| 40 | Debug.setListener(listener); |
| 41 | |
| 42 | run(function () { return fun.apply(null, args) }); |
| 43 | run(function () { return gen.apply(null, args).next().value }); |
| 44 | |
| 45 | Debug.setListener(null); |
| 46 | } |
| 47 | |
| 48 | // Check that two scope are the same. |
| 49 | function assertScopeMirrorEquals(scope1, scope2) { |
no test coverage detected
searching dependent graphs…