summaryrefslogtreecommitdiff
path: root/combinator_test.go
diff options
context:
space:
mode:
authorAdam Scarr <adam@vektah.net>2017-08-13 22:11:27 +1000
committerAdam Scarr <adam@vektah.net>2017-08-13 22:11:27 +1000
commitddb61bdfc034a683f755dec6ddc80627d2d43522 (patch)
tree5d3192d70c5d2a4c62a2be8b8d11de2b0455546b /combinator_test.go
parent139e7606f4ab68b469438956c378745f51f7b65b (diff)
Add an Until function
Diffstat (limited to 'combinator_test.go')
-rw-r--r--combinator_test.go14
1 files changed, 14 insertions, 0 deletions
diff --git a/combinator_test.go b/combinator_test.go
index c1eedb3..e792c47 100644
--- a/combinator_test.go
+++ b/combinator_test.go
@@ -181,6 +181,20 @@ func TestMap(t *testing.T) {
})
}
+func TestUntil(t *testing.T) {
+ parser := Until("world", ".")
+
+ t.Run("success", func(t *testing.T) {
+ result, _ := runParser("this is the end of the world", parser)
+ require.Equal(t, "this is the end of the ", result.Token)
+ })
+
+ t.Run("eof", func(t *testing.T) {
+ result, _ := runParser("this is the end of it all", parser)
+ require.Equal(t, "this is the end of it all", result.Token)
+ })
+}
+
func TestBind(t *testing.T) {
parser := Bind("true", true)