Skip to content

Commit

Permalink
Add sourcemap tests
Browse files Browse the repository at this point in the history
  • Loading branch information
tolauwae committed Dec 7, 2024
1 parent 857e7eb commit 4bd0b46
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 6 deletions.
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,8 @@
},
"ava": {
"files": [
"out/tests/unit/util.test.js"
"out/tests/unit/util.test.js",
"out/tests/unit/sourcemap.test.js"
],
"typescript": {
"compile": false,
Expand Down
12 changes: 12 additions & 0 deletions tests/unit/sourcemap.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import test from 'ava';
import {WASM} from '../../src/sourcemap/Wasm';

test('test wasm/leb128', t => {
t.is(WASM.leb128(0), '00');
t.is(WASM.leb128(1), '01');
t.is(WASM.leb128(8), '08');
t.is(WASM.leb128(32), '20');
// t.is(WASM.leb128(64), '40');
t.is(WASM.leb128(128), '8001');
// t.is(WASM.leb128(1202), 'b209');
});
10 changes: 5 additions & 5 deletions tests/unit/util.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,21 @@ import {find, getFileExtension} from '../../src/util/util';
import {indent} from '../../src/util/printing';
import {retry} from '../../src/util/retry';

test('[internal] test util/getFileExtension', t => {
test('test util/getFileExtension', t => {
t.is(getFileExtension('test.wast'), 'wast');
t.is(getFileExtension('util.test.js'), 'js');
t.is(getFileExtension('float_misc.asserts.wast'), 'wast');
t.is(getFileExtension('simd_i16x8_extadd_pairwise_i8x16.wast'), 'wast');
});

test('[internal] test errors in util/getFileExtension', t => {
test('test errors in util/getFileExtension', t => {
const error = t.throws(() => {
getFileExtension('impossible')
}, {instanceOf: Error});
t.is(error.message, 'Could not determine file type');
});

test('[internal] test util/find', t => {
test('test util/find', t => {
t.is(find(/(wast)/, 'test.wast'), 'wast');
t.is(find(/(.wast)/, 'impossible'), '');
t.is(find(/—(.*)—/, 'Jeeves—my man, you know—is really a most extraordinary chap.'), 'my man, you know');
Expand All @@ -26,7 +26,7 @@ test('[internal] test util/find', t => {
t.is(find(/([a-zA-Z]{11,})/, 'The unanimous Declaration of the thirteen united States of America, When in the Course of human events, it becomes necessary for one people to dissolve the political bands which have connected them with another, and to assume among the powers of the earth, the separate and equal station to which the Laws of Nature and of Nature\'s God entitle them, a decent respect to the opinions of mankind requires that they should declare the causes which impel them to the separation.'), 'Declaration');
});

test('[internal] test printing/indent', t => {
test('test printing/indent', t => {
t.is(indent(4), ' ');
t.is(indent(4, 1), ' ');
t.is(indent(1, 4), ' ');
Expand All @@ -43,7 +43,7 @@ const attempt = (count: number, n: number) => retry(async () => {
})
}, n);

test('[internal] test retry/retry', async t => {
test('test retry/retry', async t => {
t.is(await attempt(2, 2), 0);
t.is(await attempt(2, 4), 0);
t.is(await attempt(8, 9), 0);
Expand Down

0 comments on commit 4bd0b46

Please sign in to comment.