-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathexample.ts
More file actions
96 lines (83 loc) · 2.98 KB
/
example.ts
File metadata and controls
96 lines (83 loc) · 2.98 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
import {
Description,
EmulatorSpecification,
Expected,
Framework,
Invoker,
Kind,
Message,
Step,
Verbosity,
WASM
} from '../../src/index';
import dump = Message.dump;
import stepOver = Message.stepOver;
const framework = Framework.getImplementation();
const spec = framework.suite('Test Wasm spec'); // must be called first
spec.testee('emulator[:8100]', new EmulatorSpecification(8100));
const steps: Step[] = [];
// ✔ ((invoke "8u_good1" (i32.const 0)) (i32.const 97))
steps.push(new Invoker('8u_good1', [WASM.i32(BigInt(0))], WASM.i32(BigInt(97))));
// ✔ ((invoke "8u_good3" (i32.const 0)) (i32.const 98))
steps.push(new Invoker('8u_good3', [WASM.i32(BigInt(0))], WASM.i32(BigInt(98))));
// ✔ ((invoke "func-unwind-by-br"))
steps.push(new Invoker('func-unwind-by-br', [], undefined));
spec.test({
title: `Test with address_0.wast`,
program: 'tests/examples/address.wast',
dependencies: [],
steps: steps
});
const debug = framework.suite('Test Debugger interface');
debug.testee('emulator[:8150]', new EmulatorSpecification(8150));
debug.test({
title: 'Test STEP OVER',
program: 'tests/examples/call.wast',
steps: [{
title: 'Send DUMP command',
instruction: {kind: Kind.Request, value: dump}
}, {
title: 'Send STEP OVER command',
instruction: {kind: Kind.Request, value: stepOver}
}, {
title: 'CHECK: execution stepped over direct call',
instruction: {kind: Kind.Request, value: dump},
expected: [{'pc': {kind: 'primitive', value: 169} as Expected<number>}]
}, {
title: 'Send STEP OVER command',
instruction: {kind: Kind.Request, value: stepOver}
}, {
title: 'CHECK: execution took one step',
instruction: {kind: Kind.Request, value: dump},
expected: [{'pc': {kind: 'primitive', value: 171} as Expected<number>}]
}, {
title: 'Send STEP OVER command',
instruction: {kind: Kind.Request, value: stepOver}
}, {
title: 'CHECK: execution stepped over indirect call',
instruction: {kind: Kind.Request, value: dump},
expected: [{'pc': {kind: 'primitive', value: 174} as Expected<number>}]
}]
});
const DUMP: Step = {
title: 'Send DUMP command',
instruction: {kind: Kind.Request, value: Message.dump},
expected: [
{'pc': {kind: 'description', value: Description.defined} as Expected<string>},
{
'breakpoints': {
kind: 'comparison', value: (state: Object, value: Array<any>) => {
return value.length === 0;
}, message: 'list of breakpoints should be empty'
} as Expected<Array<any>>
},
{'callstack[0].sp': {kind: 'primitive', value: -1} as Expected<number>},
{'callstack[0].fp': {kind: 'primitive', value: -1} as Expected<number>}]
};
debug.test({
title: 'Test DUMP blink',
program: `tests/examples/blink.wast`,
steps: [DUMP]
});
framework.reporter.verbosity(Verbosity.debug);
framework.analyse([spec, debug]);