-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathParserStateTests.fs
31 lines (26 loc) · 1000 Bytes
/
ParserStateTests.fs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
namespace PidginFsharp.Test
open PidginFsharp
open System
open Xunit
module ParserStateTests =
[<Fact>]
let ``peek returns the first character`` () =
let actual = ParserState.createStringParserState "abc" |> ParserState.peek
let expected = Some 'a'
Assert.Equal<char option>(expected, actual)
[<Fact>]
let ``advance moves one character further`` () =
let state = ParserState.createStringParserState "abc"
state |> ParserState.advance
let actual = state |> ParserState.peek
let expected = Some 'b'
Assert.Equal<char option>(expected, actual)
[<Fact>]
let ``after advancing after the end peek returns None`` () =
let state = ParserState.createStringParserState "abc"
state |> ParserState.advance
state |> ParserState.advance
state |> ParserState.advance
let actual = ParserState.peek state
let expected = None
Assert.Equal<char option>(expected, actual)