Skip to content

Commit

Permalink
comment not allowed after http, github or gist dependency
Browse files Browse the repository at this point in the history
  • Loading branch information
theimowski committed May 1, 2015
1 parent cabe055 commit 1bacfe0
Showing 1 changed file with 43 additions and 5 deletions.
48 changes: 43 additions & 5 deletions tests/Paket.Tests/DependenciesFile/PropertyTests.fs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ open System
open FsCheck
open FsCheck.NUnit
open Paket
open TestHelpers

let nl = Environment.NewLine
let linesToString s = String.concat nl s

let source = Gen.constant "source https://nuget.org/api/v2"

Expand All @@ -15,19 +19,53 @@ let gist = Gen.constant "gist Thorium/1972349 timestamp.fs"

let http = Gen.constant "http http://www.fssnip.net/1n decrypt.fs"

let depLine = Gen.oneof [source; nuget; github; gist; http]
let empty = Gen.constant ""

let line = Gen.oneof [source; nuget; github; gist; http; empty]

let slashComment = Gen.constant "//comment"
let lineWComment =
let line = Gen.oneof [source; nuget; empty]
(line, slashComment)
||> Gen.map2 (fun l c -> l + " " + c)

let hashComment = Gen.constant "#comment"
let comment = Gen.oneof [slashComment; hashComment]

let depLine = Gen.frequency [80, line; 10, lineWComment; 10, comment]

let globalOpts =
Gen.elements
[ "references: strict"; "framework: net35, net40"; "content: none"; "import_targets: false"; "copy_local: false" ]
|> Gen.arrayOf
|> Gen.map (Seq.distinct >> Array.ofSeq)

let generator =
(Gen.arrayOf depLine, globalOpts)
||> Gen.map2 (fun lines globalOpts -> Array.append globalOpts lines)
|> Gen.map linesToString

let shrinker s =
let lines = s |> toLines
seq {
for i in [0 .. lines.Length - 1] do
yield seq {
for j in [0 .. lines.Length - 1] do
if i <> j then yield lines.[j] }
|> linesToString}

type DFFileGenerator =
static member StringArray() =
{new Arbitrary<string[]>() with
override x.Generator = Gen.arrayOf depLine
override x.Shrinker t = Seq.empty }
{new Arbitrary<string>() with
override x.Generator = generator
override x.Shrinker t = shrinker t }

let _ = PropertyAttribute(Verbose = true)

[<Property(
Arbitrary = [|typeof<DFFileGenerator>|],
Verbose = true)>]
let ``round trip`` (lines : string[]) =
let ``round trip`` (contents : string) =
let lines = toLines contents
let df = DependenciesFile(DependenciesFileParser.parseDependenciesFile "dummy" lines)
df.ToString() = String.concat Environment.NewLine lines

0 comments on commit 1bacfe0

Please sign in to comment.