Skip to content

Commit 58896bb

Browse files
🧪 test: Test some independent implementation.
1 parent 35b5ce0 commit 58896bb

File tree

4 files changed

+15
-2
lines changed

4 files changed

+15
-2
lines changed

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,7 @@
8585
"pinst": "2.1.6",
8686
"power-assert": "1.6.1",
8787
"regenerator-runtime": "0.13.7",
88+
"string-algorithms": "^1.0.31",
8889
"xo": "0.39.1"
8990
},
9091
"ava": {

test/src/_fixtures.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,15 @@ import {map} from '@iterable-iterator/map';
22

33
import {mock, StringSlice} from '../../src/index.js';
44

5+
import {search as _stringAlgorithmsKMP} from 'string-algorithms';
6+
57
export const mockedSingle = (s, si, sj, p, pi, pj) =>
68
map(
79
(hit) => hit.si,
810
mock(new StringSlice(s, si, sj), [new StringSlice(p, pi, pj)]),
911
);
12+
13+
export const stringAlgorithmsKMP = (s, si, sj, p, pi, pj) =>
14+
map((x) => si + x, _stringAlgorithmsKMP(s.slice(si, sj), p.slice(pi, pj)));
15+
16+
export const algorithmsForSinglePattern = [mockedSingle, stringAlgorithmsKMP];

test/src/skip.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@ import test from 'ava';
22

33
import {single, data} from '../../src/index.js';
44

5-
import {mockedSingle} from './_fixtures.js';
5+
import {algorithmsForSinglePattern} from './_fixtures.js';
66

77
single({
88
test,
9-
algorithms: [mockedSingle],
9+
algorithms: algorithmsForSinglePattern,
1010
data,
1111
skipEmptyString: true,
1212
skipEmptyPattern: true,

yarn.lock

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8937,6 +8937,11 @@ stream-http@^2.7.2:
89378937
to-arraybuffer "^1.0.0"
89388938
xtend "^4.0.0"
89398939

8940+
string-algorithms@^1.0.31:
8941+
version "1.0.31"
8942+
resolved "https://registry.yarnpkg.com/string-algorithms/-/string-algorithms-1.0.31.tgz#9021fcbadb40c1781dd250fbc7ef884feda80215"
8943+
integrity sha512-v+gdi7yfXsSGj2RU64AMR8LJyBnwpDSuJLsQxezu9ZgdYZF+g5vEGyuCeN47OoAObrEvt8VFKmj3NYCzXRBbnw==
8944+
89408945
89418946
version "0.3.1"
89428947
resolved "https://registry.yarnpkg.com/string-argv/-/string-argv-0.3.1.tgz#95e2fbec0427ae19184935f816d74aaa4c5c19da"

0 commit comments

Comments
 (0)