Skip to content

Commit 3bf5f07

Browse files
robertsipkayichoi
authored andcommitted
Record all error events in JerryProtocolHandler test suites
IoT.js-VSCode-DCO-1.0-Signed-off-by: Robert Sipka [email protected]
1 parent 21f8a83 commit 3bf5f07

File tree

1 file changed

+22
-3
lines changed

1 file changed

+22
-3
lines changed

src/test/JerryProtocolHandler.test.ts

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,7 @@ suite('JerryProtocolHandler', () => {
8484
suite('onByteCodeCP', () => {
8585
const delegate = {
8686
onScriptParsed: sinon.spy(),
87+
onError: sinon.spy()
8788
};
8889
let handler: JerryDebugProtocolHandler;
8990

@@ -92,12 +93,14 @@ suite('JerryProtocolHandler', () => {
9293
handler = new JerryDebugProtocolHandler(delegate);
9394
const array = Uint8Array.from([SP.SERVER.JERRY_DEBUGGER_BYTE_CODE_CP]);
9495
assert.throws(() => handler.onByteCodeCP(array));
96+
assert(delegate.onError.notCalled);
9597
});
9698
});
9799

98100
suite('onSourceCode', () => {
99101
const delegate = {
100102
onScriptParsed: sinon.spy(),
103+
onError: sinon.spy()
101104
};
102105
let handler: JerryDebugProtocolHandler;
103106

@@ -108,6 +111,7 @@ suite('JerryProtocolHandler', () => {
108111
// code = 'abc'
109112
handler.onSourceCode(array);
110113
assert(delegate.onScriptParsed.notCalled);
114+
assert(delegate.onError.notCalled);
111115
});
112116

113117
test('immediately calls scriptParsed from END message', () => {
@@ -123,6 +127,7 @@ suite('JerryProtocolHandler', () => {
123127
assert.strictEqual(data.lineCount, 1);
124128
assert.strictEqual(data.name, '');
125129
assert.strictEqual(handler.getSource(1), 'abc');
130+
assert(delegate.onError.notCalled);
126131
});
127132

128133
test('concatenates multiple SOURCE messages with END message', () => {
@@ -140,12 +145,14 @@ suite('JerryProtocolHandler', () => {
140145
assert(delegate.onScriptParsed.calledOnce);
141146
// 'abcabcabc' + 'abc' = 'abcabcabcabc'
142147
assert.strictEqual(handler.getSource(1), 'abcabcabcabc');
148+
assert(delegate.onError.notCalled);
143149
});
144150
});
145151

146152
suite('onSourceCodeName', () => {
147153
const delegate = {
148154
onScriptParsed: sinon.spy(),
155+
onError: sinon.spy()
149156
};
150157
let handler: JerryDebugProtocolHandler;
151158

@@ -161,6 +168,7 @@ suite('JerryProtocolHandler', () => {
161168
assert(delegate.onScriptParsed.calledOnce);
162169
const data = delegate.onScriptParsed.args[0][0];
163170
assert.strictEqual(data.name, 'foo');
171+
assert(delegate.onError.notCalled);
164172
});
165173

166174
test('concatenates multiple NAME messages with END message', () => {
@@ -179,6 +187,7 @@ suite('JerryProtocolHandler', () => {
179187
const data = delegate.onScriptParsed.args[0][0];
180188
// 'foo' + 'foo' = 'foofoo'
181189
assert.strictEqual(data.name, 'foofoo');
190+
assert(delegate.onError.notCalled);
182191
});
183192
});
184193

@@ -210,10 +219,11 @@ suite('JerryProtocolHandler', () => {
210219
test('calls delegate function if available', () => {
211220
const delegate = {
212221
onBreakpointHit: sinon.spy(),
222+
onError: sinon.spy()
213223
};
214224
const handler = new JerryDebugProtocolHandler(delegate);
215225

216-
let array = Uint8Array.from([0, 128, 2, 1, 1]);
226+
let array = Uint8Array.from([0, 128, 2, 1, SP.JERRY_DEBUGGER_VERSION]);
217227
handler.onConfiguration(array);
218228
array = encodeArray(SP.SERVER.JERRY_DEBUGGER_SOURCE_CODE_END, 'code');
219229
handler.onSourceCode(array);
@@ -227,18 +237,20 @@ suite('JerryProtocolHandler', () => {
227237
assert(delegate.onBreakpointHit.notCalled);
228238
handler.onBreakpointHit(array);
229239
assert(delegate.onBreakpointHit.calledOnce);
240+
assert(delegate.onError.notCalled);
230241
});
231242
});
232243

233244
suite('onBacktrace', () => {
234245
const delegate = {
235246
onBacktrace: sinon.spy(),
247+
onError: sinon.spy()
236248
};
237249
const handler = new JerryDebugProtocolHandler(delegate);
238250

239251
test('calls delegate function immediately on END event', () => {
240252
delegate.onBacktrace.resetHistory();
241-
let array = Uint8Array.from([0, 128, 2, 1, 1]);
253+
let array = Uint8Array.from([0, 128, 2, 1, SP.JERRY_DEBUGGER_VERSION]);
242254
handler.onConfiguration(array);
243255
array = encodeArray(SP.SERVER.JERRY_DEBUGGER_SOURCE_CODE_END, 'code');
244256
handler.onSourceCode(array);
@@ -257,11 +269,13 @@ suite('JerryProtocolHandler', () => {
257269
assert(delegate.onBacktrace.notCalled);
258270
handler.onBacktrace(array);
259271
assert(delegate.onBacktrace.calledOnce);
272+
assert(delegate.onError.notCalled);
273+
260274
});
261275

262276
test('calls delegate function only on END event', () => {
263277
delegate.onBacktrace.resetHistory();
264-
let array = Uint8Array.from([0, 128, 2, 1, 1]);
278+
let array = Uint8Array.from([0, 128, 2, 1, SP.JERRY_DEBUGGER_VERSION]);
265279
handler.onConfiguration(array);
266280
array = encodeArray(SP.SERVER.JERRY_DEBUGGER_SOURCE_CODE_END, 'code');
267281
handler.onSourceCode(array);
@@ -282,13 +296,15 @@ suite('JerryProtocolHandler', () => {
282296
assert(delegate.onBacktrace.notCalled);
283297
handler.onBacktrace(array);
284298
assert(delegate.onBacktrace.calledOnce);
299+
assert(delegate.onError.notCalled);
285300
});
286301
});
287302

288303
suite('onEvalResult', () => {
289304
test('handles a single END packet', () => {
290305
const delegate = {
291306
onEvalResult: sinon.spy(),
307+
onError: sinon.spy()
292308
};
293309
const handler = new JerryDebugProtocolHandler(delegate);
294310
(handler as any).evalResultData = undefined;
@@ -300,11 +316,13 @@ suite('JerryProtocolHandler', () => {
300316
assert.strictEqual(delegate.onEvalResult.args[0][1], 'ab');
301317
assert.strictEqual((handler as any).evalResultData, undefined);
302318
assert.strictEqual((handler as any).evalsPending, 0);
319+
assert(delegate.onError.notCalled);
303320
});
304321

305322
test('handles a partial packet plus an END packet', () => {
306323
const delegate = {
307324
onEvalResult: sinon.spy(),
325+
onError: sinon.spy()
308326
};
309327
const handler = new JerryDebugProtocolHandler(delegate);
310328
(handler as any).evalResultData = undefined;
@@ -318,6 +336,7 @@ suite('JerryProtocolHandler', () => {
318336
assert.strictEqual(delegate.onEvalResult.args[0][1], 'abab');
319337
assert.strictEqual((handler as any).evalResultData, undefined);
320338
assert.strictEqual((handler as any).evalsPending, 0);
339+
assert(delegate.onError.notCalled);
321340
});
322341
});
323342

0 commit comments

Comments
 (0)