Skip to content

Commit 115d824

Browse files
committed
feature: @putout/test: add ability to override ext
1 parent 53379f8 commit 115d824

File tree

21 files changed

+472
-74
lines changed

21 files changed

+472
-74
lines changed

packages/processor-wasm/lib/lint.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import {parse} from '@webassemblyjs/wast-parser';
44
import {print} from '@webassemblyjs/wast-printer';
55
import {rules} from './rules/index.js';
66

7-
export const lint = (source, {fix} = {}) => {
7+
export const lint = (source, {fix = true} = {}) => {
88
const [error, ast] = tryCatch(parse, source);
99

1010
if (error)
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
(module
2+
;; this is simple function that adds a couple of parameters
3+
4+
(func (param $a i32) (param $b i32)
5+
(local.get $a)
6+
(local.get $b)
7+
(i32.add)
8+
)
9+
(func (param $a i32) (param $b i32)
10+
(i32.add (local.get $a) (local.get $b))
11+
)
12+
;; this statement exports the function to the host environment
13+
14+
(export "add" (func $add))
15+
)
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
(module
2+
;; this is simple function that adds a couple of parameters
3+
(func (param $a i32) (param $b i32)
4+
(get_local $a)
5+
(get_local $b)
6+
(i32.add)
7+
)
8+
9+
(func (param $a i32) (param $b i32)
10+
(i32.add (get_local $a)(get_local $b))
11+
12+
)
13+
14+
;; this statement exports the function to the host environment
15+
(export "add" (func $add))
16+
)

packages/processor-wasm/lib/rules/convert-get-local-to-local-get.js renamed to packages/processor-wasm/lib/rules/convert-get-local-to-local-get/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
export const report = () => `Use 'local.get' instead of get_local`;
1+
export const report = () => `Use 'local.get' instead of 'get_local'`;
22

33
export const fix = (path) => {
44
path.node.id = 'get';
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
import {createTest} from '#test';
2+
import * as plugin from './index.js';
3+
4+
const test = createTest(import.meta.url, {
5+
plugins: [
6+
['convert-get-local-t-local-get', plugin],
7+
],
8+
});
9+
10+
test('putout: processor-wasm: convert-get-local-to-local-get: report', (t) => {
11+
t.report('convert-get-local-to-local-get', `Use 'local.get' instead of 'get_local'`);
12+
t.end();
13+
});
14+
15+
test('putout: processor-wasm: convert-get-local-to-local-get: transform', (t) => {
16+
t.transform('convert-get-local-to-local-get');
17+
t.end();
18+
});
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
(module
2+
;; this is simple function that adds a couple of parameters
3+
4+
(func $add (param $a i32) (param $b i32) (result i32)
5+
(local.set $a)
6+
(local.set $b)
7+
(i32.add)
8+
)
9+
;; this statement exports the function to the host environment
10+
11+
(export "add" (func $add))
12+
)
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
(module
2+
3+
;; this is simple function that adds a couple of parameters
4+
(func $add (param $a i32) (param $b i32) (result i32)
5+
(set_local $a)
6+
(set_local $b)
7+
(i32.add)
8+
)
9+
10+
;; this statement exports the function to the host environment
11+
(export "add" (func $add))
12+
)

packages/processor-wasm/lib/rules/convert-set-local-to-local-set.js renamed to packages/processor-wasm/lib/rules/convert-set-local-to-local-set/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
export const report = () => `Use 'local.set' instead of set_local`;
1+
export const report = () => `Use 'local.set' instead of 'set_local'`;
22

33
export const fix = (path) => {
44
path.node.id = 'set';
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
import {createTest} from '#test';
2+
import * as plugin from './index.js';
3+
4+
const test = createTest(import.meta.url, {
5+
plugins: [
6+
['convert-set-local-t-local-set', plugin],
7+
],
8+
});
9+
10+
test('putout: processor-wasm: convert-set-local-to-local-set: report', (t) => {
11+
t.report('convert-set-local-to-local-set', `Use 'local.set' instead of 'set_local'`);
12+
t.end();
13+
});
14+
15+
test('putout: processor-wasm: convert-set-local-to-local-set: transform', (t) => {
16+
t.transform('convert-set-local-to-local-set');
17+
t.end();
18+
});

packages/processor-wasm/lib/rules/index.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import * as convertGetLocalToLocalGet from './convert-get-local-to-local-get.js';
2-
import * as convertSetLocalToLocalSet from './convert-set-local-to-local-set.js';
1+
import * as convertGetLocalToLocalGet from './convert-get-local-to-local-get/index.js';
2+
import * as convertSetLocalToLocalSet from './convert-set-local-to-local-set/index.js';
33

44
export const rules = [
55
['convert-get-local-to-local-get', convertGetLocalToLocalGet],

0 commit comments

Comments
 (0)