Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ language: csharp
sudo: false # use the new container-based Travis infrastructure

script:
- ./build.sh All
- ./build.sh RunTests
2 changes: 1 addition & 1 deletion appveyor.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
init:
- git config --global core.autocrlf input
build_script:
- cmd: build.cmd
- cmd: build.cmd RunTests
test: off
version: 0.0.1.{build}
artifacts:
Expand Down
14 changes: 13 additions & 1 deletion src/Toml.FSharp/Parsers.fs
Original file line number Diff line number Diff line change
Expand Up @@ -308,8 +308,20 @@ module Parsers =
``[[+``.>>. (sepBy toml_key ``.``) .>>. ``]]+``
|>> fun ((b,ls),e) -> String.concat "" [b; listToKey ls; e]

let ptkeyArr : _ Parser =
``[+``.>>. toml_key .>>. ``.`` .>>. (sepBy1 toml_key ``.``) .>>. ``]+``
|>> fun ((b,ls),e) ->
let ((b,tKey),sep) = b
String.concat "" [ b; tKey; sep |> string; listToKey ls; e]

let paotKeyArr : _ Parser =
``[[+``.>>. toml_key .>>. ``.`` .>>. (sepBy1 toml_key ``.``) .>>. ``]]+``
|>> fun ((b,ls),e) ->
let ((b,tKey),sep) = b
String.concat "" [ b; tKey; sep |> string; listToKey ls; e]

let raw_content_block =
manyCharsTill anyChar (followedByL (paotKey<|>ptkey) "expected a table or array table key"<|>eof)
manyCharsTill anyChar (followedByL (paotKeyArr<|>ptkeyArr) "expected a table or array table key"<|>eof)

let toml_item = (toml_key .>>. (skipEqs >>. toml_value)) .>> skip_tspcs

Expand Down
24 changes: 24 additions & 0 deletions tests/Toml.FSharp.Tests/ParserTests.fs
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,30 @@ let [<Test>] ``parses toml items (key value pairs)`` () =
Check.QuickThrowOnFailure <| Prop.forAll toml_item_arb (valueParser toml_item)


(*|-------------------------|*)
(*| Array Size 0 or 1 Tests |*)
(*|-------------------------|*)
let runArray0Or1 test =
let reply = run section_splitter test
match reply with
| Failure (str,_,_) -> failwith str
| Success (res,_,_) -> ()


let [<Test>] ``parses arrays of size 0`` () =
let test = """[package]

b = [ ]
"""
runArray0Or1 test

let [<Test>] ``parses arrays of size 1`` () =
let test = """[package]

b = [ 10 ]
"""
runArray0Or1 test


#if INTERACTIVE
// Test Switches
Expand Down