mirror of
https://github.com/JernKunpittaya/full_zk_regex.git
synced 2026-01-07 20:43:51 -05:00
add test.js for yarn testfunc
This commit is contained in:
3
.babelrc
Normal file
3
.babelrc
Normal file
@@ -0,0 +1,3 @@
|
||||
{
|
||||
"presets": ["@babel/preset-env", "@babel/preset-react"]
|
||||
}
|
||||
@@ -20,7 +20,8 @@
|
||||
"start": "react-scripts start",
|
||||
"build": "react-scripts build",
|
||||
"test": "react-scripts test",
|
||||
"eject": "react-scripts eject"
|
||||
"eject": "react-scripts eject",
|
||||
"testback": "mocha --require @babel/register 'src/test.js'"
|
||||
},
|
||||
"eslintConfig": {
|
||||
"extends": [
|
||||
@@ -39,5 +40,11 @@
|
||||
"last 1 firefox version",
|
||||
"last 1 safari version"
|
||||
]
|
||||
},
|
||||
"devDependencies": {
|
||||
"@babel/preset-env": "^7.22.5",
|
||||
"@babel/preset-react": "^7.22.5",
|
||||
"@babel/register": "^7.22.5",
|
||||
"mocha": "^10.2.0"
|
||||
}
|
||||
}
|
||||
|
||||
17
src/test.js
Normal file
17
src/test.js
Normal file
@@ -0,0 +1,17 @@
|
||||
import { simplifyGraph, findSubstrings } from "./gen_dfa";
|
||||
function test() {
|
||||
const text =
|
||||
"adsfasd DKI: v=12/; d=22; a=//121; d=1; bh=xUqTs2T2FPGCOB52 sdflj";
|
||||
const regex = "DKI: (([vad]=([12/]+); )+)bh";
|
||||
const simp_graph = simplifyGraph(regex);
|
||||
const matched_dfa = findSubstrings(simp_graph, text);
|
||||
for (const subs of matched_dfa[1]) {
|
||||
var matched = text.slice(subs[0], subs[1] + 1);
|
||||
console.log("matched: ", matched);
|
||||
}
|
||||
}
|
||||
describe("test backend", function () {
|
||||
it("should print correctly", function () {
|
||||
test();
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user