diff --git a/__test__/satysrc/generic.saty b/__test__/satysrc/generic.saty index 5e44b62..7cc6809 100644 --- a/__test__/satysrc/generic.saty +++ b/__test__/satysrc/generic.saty @@ -52,49 +52,6 @@ let print-result r = let char-a = char (Char.make `a`) in let char-b = char (Char.make `b`) in let char-c = char (Char.make `c`) in -% (a+)(b+) -let () = test (seq (group (many1 char-a)) (group (many1 char-b))) `aabbb` |> String.of-bool |> Debug.log in % true -let () = `aabbb` |> test (alt char-a char-b) |> String.of-bool |> Debug.log in % true -% (a+|(c))(b+) -let re1 = seq (group (alt (many1 char-a) (group char-c))) (group (many1 char-b)) in -let ss = exec re1 `aabbb` |> print-result in -let re3 = many (many char-a) in -let () = `aaaaa` |> test re3 |> String.of-bool |> Debug.log in -let re4 = seq (group (seq any (char (Char.make `e`)))) eof in -let () = `the apple` |> exec re4 |> print-result in -let re6 = sequence [bol; string `apple`; eol] in -let () = `the apple -apple -leapple` |> exec re6 |> print-result in -let () = exec spaces #` asdf`# |> print-result in -let () = `aaabb` |> test (RegExp.of-string `(a+|(c))(b+)`) |> String.of-bool |> Debug.log in -let _ = RegExp.of-string `^\s\d$` in -% let _ = RegExp.of-string `[]` in -let _ = RegExp.of-string `[a-z]` in -let _ = `0X` |> test (RegExp.of-string `0[xX]`) |> String.of-bool |> Debug.log in -let _ = `0x1f2e3d` |> test (RegExp.of-string `0[xX][A-Fa-f0-9]+`) |> String.of-bool |> Debug.log in -let _ = `0a` |> test (RegExp.of-string `0[xX]`) |> String.of-bool |> Debug.log in -let _ = `0xaZb` |> test (RegExp.of-string `^0[xX][A-Fa-f0-9]+$`) |> String.of-bool |> Debug.log in -let _ = `][][` |> test (RegExp.of-string `[][]+`) |> String.of-bool |> Debug.log in -let _ = `][]-[` |> test (RegExp.of-string `[][-]+`) |> String.of-bool |> Debug.log in -let input = ` I do not know why but it seems code2 is slow if it contains a long line. -wakegawakaranaiyo wakegawakaranaiyo wakegawakaranaiyo wakegawakaranaiyo -wakegawakaranaiyo wakegawakaranaiyo wakegawakaranaiyo wakegawakaranaiyo -wakegawakaranaiyo wakegawakaranaiyo wakegawakaranaiyo wakegawakaranaiyo -wakegawakaranaiyo wakegawakaranaiyo wakegawakaranaiyo wakegawakaranaiyo -wakegawakaranaiyo wakegawakaranaiyo wakegawakaranaiyo wakegawakaranaiyo -wakegawakaranaiyo wakegawakaranaiyo wakegawakaranaiyo wakegawakaranaiyo -wakegawakaranaiyo wakegawakaranaiyo wakegawakaranaiyo wakegawakaranaiyo -wakegawakaranaiyo wakegawakaranaiyo wakegawakaranaiyo wakegawakaranaiyo -wakegawakaranaiyo wakegawakaranaiyo wakegawakaranaiyo wakegawakaranaiyo -wakegawakaranaiyo wakegawakaranaiyo wakegawakaranaiyo wakegawakaranaiyo -wakegawakaranaiyo wakegawakaranaiyo wakegawakaranaiyo wakegawakaranaiyo -wakegawakaranaiyo wakegawakaranaiyo wakegawakaranaiyo wakegawakaranaiyo -wakegawakaranaiyo wakegawakaranaiyo wakegawakaranaiyo wakegawakaranaiyo -wakegawakaranaiyo wakegawakaranaiyo wakegawakaranaiyo wakegawakaranaiyo` in -let pat = `wk` in -let () = Debug.print `testing long input` in -let () = Debug.print (String.of-bool (RegExp.test (RegExp.of-string pat) input)) in let () = Debug.log `==== Parser ====` in let () = @@ -142,6 +99,7 @@ let rules = [ let (Some tokens) = Lexer.lex rules `abc defg hijklMNL op123 ` in let () = tokens |> List.iter (fun tk -> (Debug.log (`(| kind = `# ^ tk#kind ^ `, data = "`# ^ tk#data ^ `" |)`))) in + let () = Debug.log `==== Map ====` in let m = Map.of-list [(1, `a`); (2, `b`); (3, `c`)] in let option-force (Some v) = v in diff --git a/test/regex.test.satyg b/test/regex.test.satyg index 1463ac6..42f56dc 100644 --- a/test/regex.test.satyg +++ b/test/regex.test.satyg @@ -15,10 +15,12 @@ let regex-test-cases = open Test in % let () = exec (compile (seq (many1 char-a) (many1 char-b))) `aabbb` |> String.of-bool |> Debug.log in % let () = exec re-example1 `aabbb` |> String.of-bool |> Debug.log in it `test "(a+)(b+)"` (fun () -> ( - let re1 = (seq (group (many1 char-a)) (group (many1 char-b))) in - let re2 = (alt char-a char-b) in - test re1 `aabbb` - && test re2 `aabbb` + test (seq (group (many1 char-a)) (group (many1 char-b))) `aabbb` + |> Expect.is-true + )); + % TODO GH-142: Is this right description? + it `test "a|b"` (fun () -> ( + test (alt char-a char-b) `aabbb` |> Expect.is-true )); it `exec "(a+|(c))(b+)"` (fun () -> ( @@ -33,8 +35,7 @@ let regex-test-cases = open Test in )); % TODO GH-142: Is this right description? it `test "a**"` (fun () -> ( - let re = many (many char-a) in - test re `aaaaa` + test (many (many char-a)) `aaaaa` |> Expect.is-true )); % TODO GH-142: Is this right description? @@ -65,12 +66,19 @@ leapple` in `aaabb` |> test (RegExp.of-string `(a+|(c))(b+)`) |> Expect.is-true )); - % let _ = RegExp.of-string `^\s\d$` in TODO GH-142: What do we wanna test? - % % let _ = RegExp.of-string `[]` in TODO GH-142: Do we wanna keep this? - % let _ = RegExp.of-string `[a-z]` in TODO GH-142: What do we wanna test? + it `compile "^\s\d" successfully` (fun () -> ( + let _ = RegExp.of-string `^\s\d$` in + Expect.always-pass + )); + % fails to compile "[]" + it `compile "[a-z]" successfully` (fun () -> ( + let _ = RegExp.of-string `[a-z]` in + Expect.always-pass + )); it `match prefix of header of hexadecimal literal` (fun () -> ( let re = (RegExp.of-string `0[xX]`) in test re `0x` + && test re `0X` && not test re `0a` |> Expect.is-true )); @@ -90,7 +98,7 @@ leapple` in |> test (RegExp.of-string `[][-]+`) |> Expect.is-true )); - it `test against long input` (fun () -> ( + it `failing test with long input won't take that long` (fun () -> ( % NOTE GH-142: Do we want to set timelimit? let input = ` I do not know why but it seems code2 is slow if it contains a long line. wakegawakaranaiyo wakegawakaranaiyo wakegawakaranaiyo wakegawakaranaiyo