diff --git a/.travis.yml b/.travis.yml index 5340e01..87fc838 100644 --- a/.travis.yml +++ b/.travis.yml @@ -3,4 +3,4 @@ language: csharp sudo: false # use the new container-based Travis infrastructure script: - - ./build.sh All + - ./build.sh RunTests diff --git a/appveyor.yml b/appveyor.yml index 0198468..c4ac2bc 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -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: diff --git a/src/Toml.FSharp/Parsers.fs b/src/Toml.FSharp/Parsers.fs index a76636b..090effe 100644 --- a/src/Toml.FSharp/Parsers.fs +++ b/src/Toml.FSharp/Parsers.fs @@ -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 diff --git a/tests/Toml.FSharp.Tests/ParserTests.fs b/tests/Toml.FSharp.Tests/ParserTests.fs index 9c4ded0..bf3488f 100644 --- a/tests/Toml.FSharp.Tests/ParserTests.fs +++ b/tests/Toml.FSharp.Tests/ParserTests.fs @@ -113,6 +113,30 @@ let [] ``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 [] ``parses arrays of size 0`` () = + let test = """[package] + + b = [ ] + """ + runArray0Or1 test + +let [] ``parses arrays of size 1`` () = + let test = """[package] + + b = [ 10 ] + """ + runArray0Or1 test + #if INTERACTIVE // Test Switches