import { exec } from "./mod.js"; import { assertEquals } from "https://deno.land/std@0.177.0/testing/asserts.ts"; Deno.test("exec()", async (t) =>{ await t.step("置換コマンドの文法チェック", async (t) => { assertEquals( exec( String.raw`/a/g => b abc` ), String.raw`/a/g => b bbc`, ); await t.step("blank", () => { assertEquals( exec( String.raw`/a/g=> b abc` ), undefined, ); assertEquals( exec( String.raw`/a/g =>b abc` ), undefined, ); assertEquals( exec( String.raw`/a/g=>b abc` ), undefined, ); }); await t.step("2 blank lines", () => { assertEquals( exec( String.raw`/a/g => b abc` ), undefined ); assertEquals( exec( String.raw`abc /a/g => b` ), undefined ); assertEquals( exec( String.raw`abc /a/g => b` ), undefined ); }); }); await t.step("samples", () => { assertEquals( exec( String.raw`/\s/g => fuga hoge hoge hoge` ), String.raw`/\s/g => fuga hogefugahogefugahoge`, ); assertEquals( exec( String.raw`/a|\s/g => b ab a b a aba b a ba bb` ), String.raw`/a|\s/g => b bbbbbbbbbbbbbbbbbbbbbbbb` ); }); });