-
Notifications
You must be signed in to change notification settings - Fork 115
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix early-onset bitrot, add a couple regression tests.
- Loading branch information
Showing
2 changed files
with
30 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
(import | ||
:std/error | ||
(only-in :std/parser/base parse-error?) | ||
:std/sugar | ||
:std/test | ||
:std/text/basic-parsers) | ||
|
||
(export basic-parsers-test) | ||
|
||
(defrule (check-parse parser string result) | ||
(begin | ||
(check-equal? (parse-string parser string) result) | ||
(check-equal? (call-with-input-string string (cut parse-port parser <>)) result))) | ||
(defrule (check-parse-error parser string) | ||
(begin | ||
(check-exception (parse-string parser string) parse-error?) | ||
(check-exception (call-with-input-string string (cut parse-port parser <>)) parse-error?))) | ||
|
||
(def basic-parsers-test | ||
(test-suite "test suite for std/misc/basic-parsers" | ||
(test-case "1" | ||
(check-parse parse-natural "1" 1) | ||
(check-parse parse-natural "010" 10) ;; ain't no octal | ||
(check-parse (cut parse-natural <> 8) "10" 8) ;; octal this time. | ||
(check-parse-error parse-natural " 1") ;; no space allowed in front unless you ask | ||
(check-parse-error parse-natural "1 no junk allowed")) | ||
(test-case "parse-integer" | ||
(check-equal? 1 1)))) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters