Skip to content

Commit 664fc9f

Browse files
committed
more test cases for the engine
1 parent d7fc695 commit 664fc9f

1 file changed

Lines changed: 22 additions & 4 deletions

File tree

test/rexen_test.gleam

Lines changed: 22 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,30 @@
11
import gleeunit
22
import gleeunit/should
3+
import gleam/list
4+
import rexen
5+
import rexen/nfa/machine
36

47
pub fn main() {
58
gleeunit.main()
69
}
710

8-
// gleeunit test functions end in `_test`
9-
pub fn hello_world_test() {
10-
1
11-
|> should.equal(1)
11+
pub fn compute_test() {
12+
//new will not be tested because it is basically a wrapper over the shunt
13+
//function that has already been tested
14+
let assert Ok(nfa) = rexen.new("(a*b*)c(d|e)")
15+
compute_loop(nfa, ["abcd", "abce", "aabbbcd", "aaaabbbbce", "bc", "bceeee"], [])
16+
|> should.equal([True, True, True, True, False, False])
17+
}
18+
19+
fn compute_loop(
20+
nfa: machine.NFA,
21+
input: List(String),
22+
output: List(Bool),
23+
) -> List(Bool) {
24+
case input {
25+
[] -> output
26+
[str, ..rest] -> {
27+
compute_loop(nfa, rest, list.append(output, [rexen.compute(nfa, str)]))
28+
}
29+
}
1230
}

0 commit comments

Comments
 (0)