-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathtest.js
64 lines (51 loc) · 1.22 KB
/
test.js
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
/*
* pioasm-wasm test code
*/
import assert from 'assert';
import { PIOAssembler } from './pioasm.js';
const testInput = `
.program blink
pull block
out y, 32
`;
const expectedOutput = `# -------------------------------------------------- #
# This file is autogenerated by pioasm; do not edit! #
# -------------------------------------------------- #
import rp2
from machine import Pin
# ----- #
# blink #
# ----- #
@rp2.asm_pio()
def blink():
wrap_target()
pull(block) # 0
out(y, 32) # 1
wrap()
`;
const badProgram = `
.program bad
jmp unknown
`;
async function main() {
const pioasm = new PIOAssembler();
assert.deepStrictEqual(await pioasm.assemble(testInput, 'python'), {
output: expectedOutput,
exitCode: 0,
});
assert.deepStrictEqual(await pioasm.assemble(testInput, 'hex'), {
output: '80a0\n6040',
exitCode: 0,
});
assert.deepStrictEqual(await pioasm.assemble(badProgram, 'c-sdk'), {
output: `input.pio:3.7-13: undefined symbol 'unknown'
3 | jmp unknown
| ^~~~~~~`,
exitCode: 1,
});
console.log('Test passed successfully!');
}
main().catch((err) => {
console.error(err);
process.exit(1);
});