Skip to content

Commit

Permalink
test: new test match function
Browse files Browse the repository at this point in the history
  • Loading branch information
Demali-876 committed Nov 6, 2024
1 parent b754e3d commit 469bceb
Showing 1 changed file with 14 additions and 7 deletions.
21 changes: 14 additions & 7 deletions src/test/lib.test.mo
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import Result "mo:base/Result";
import Extensions "../Extensions";
import Types "../Types";
import Debug "mo:base/Debug";
import Regex "../lib"

actor {
type Token = Types.Token;
Expand Down Expand Up @@ -38,30 +39,36 @@ actor {
case (#err(error)) {
#err((error))
};

case (#ok(tokens)) {
let parser = Parser.Parser(tokens);

switch (parser.parse()) {
case (#err(error)) {
#err((error))
};

case (#ok(ast)) {
let compiler = Compiler.Compiler();

switch (compiler.compile(ast)) {
case (#err(error)) {
#err((error))
};

case (#ok(compiledRegex)) {
#ok(compiledRegex)
};
}
};
}
};
}
}
};
};
public query func testMatch(): async Result.Result<Types.Match, Types.RegexError> {
let regex = Regex.Regex("abc", null);
switch(regex.match("abcdef")) {
case (#ok(result)) {
#ok(result)
};
case (#err(e)) {
#err(e)
};
};
};
};

0 comments on commit 469bceb

Please sign in to comment.