<commit_before>﻿#if INTERACTIVE
#r "../../packages/NUnit.2.6.3/lib/nunit.framework.dll"
#r "../../bin/FSharp.Data.Experimental.DesignTime.dll"
#load "../Common/FsUnit.fs"
#else
module FSharp.Data.Tests.Experimental.DesignTime.SignatureTests
#endif

open System
open System.IO
open System.Net
open FsUnit
open NUnit.Framework
open ProviderImplementation

//alow tests that access the network to work when you're behind a proxy
WebRequest.DefaultWebProxy.Credentials <- CredentialCache.DefaultNetworkCredentials

type TypeProviderInstantiation with

    member x.Dump resolutionFolder runtimeAssembly platform signatureOnly ignoreOutput =
        let output = 
            x.GenerateType resolutionFolder runtimeAssembly platform
            |> Debug.prettyPrint signatureOnly ignoreOutput 10 100
        output.Replace("FSharp.Data.Runtime.", "FDR.")
              .Replace(__SOURCE_DIRECTORY__, "<SOURCE_DIRECTORY>")

let (++) a b = Path.Combine(a, b)

let sourceDirectory = __SOURCE_DIRECTORY__

let isMono = Type.GetType("Mono.Runtime") <> null

let testCases = 
    sourceDirectory ++ "SignatureTestCases.config" 
    |> File.ReadAllLines
    |> Array.filter (fun str -> not (str.Contains "themoviedb"))
    |> Array.map TypeProviderInstantiation.Parse

let expectedDirectory = sourceDirectory ++ "expected" 

let getExpectedPath testCase = 
    expectedDirectory ++ (testCase.ToString().Replace("://", "_").Replace("/", "_") + ".expected")

let resolutionFolder = sourceDirectory ++ ".." ++ "FSharp.Data.Tests" ++ "Data"
let assemblyName = "FSharp.Data.Experimental.dll"
let runtimeAssembly = sourceDirectory ++ ".." ++ ".." ++ "bin" ++ assemblyName
let portable47RuntimeAssembly = sourceDirectory ++ ".." ++ ".." ++ "bin" ++ "portable47" ++ assemblyName
let portable7RuntimeAssembly = sourceDirectory ++ ".." ++ ".." ++ "bin" ++ "portable7" ++ assemblyName

let generateAllExpected() =
    if not <| Directory.Exists expectedDirectory then 
        Directory.CreateDirectory expectedDirectory |> ignore
    for testCase in testCases do
        let output = testCase.Dump resolutionFolder runtimeAssembly Platform.Full (*signatureOnly*)false (*ignoreOutput*)false
        File.WriteAllText(getExpectedPath testCase, output)

let normalize (str:string) =
  str.Replace("\r\n", "\n")
     .Replace("\r", "\n")
     .Replace(" \"<SOURCE_DIRECTORY>/../FSharp.Data.Tests/Data", " @\"<SOURCE_DIRECTORY>\..\FSharp.Data.Tests\Data")

[<Test>]<commit_msg>Update SignatureTests.fs<commit_after>﻿#if INTERACTIVE
#r "../../packages/NUnit.2.6.3/lib/nunit.framework.dll"
#r "../../bin/FSharp.Data.Experimental.DesignTime.dll"
#load "../Common/FsUnit.fs"
#else
module FSharp.Data.Tests.Experimental.DesignTime.SignatureTests
#endif

open System
open System.IO
open System.Net
open FsUnit
open NUnit.Framework
open ProviderImplementation

//alow tests that access the network to work when you're behind a proxy
WebRequest.DefaultWebProxy.Credentials <- CredentialCache.DefaultNetworkCredentials

type TypeProviderInstantiation with

    member x.Dump resolutionFolder runtimeAssembly platform signatureOnly ignoreOutput =
        let output = 
            x.GenerateType resolutionFolder runtimeAssembly platform
            |> Debug.prettyPrint signatureOnly ignoreOutput 10 100
        output.Replace("FSharp.Data.Runtime.", "FDR.")
              .Replace(__SOURCE_DIRECTORY__, "<SOURCE_DIRECTORY>")

let (++) a b = Path.Combine(a, b)

let sourceDirectory = __SOURCE_DIRECTORY__

let isMono = Type.GetType("Mono.Runtime") <> null

let testCases = 
    sourceDirectory ++ "SignatureTestCases.config" 
    |> File.ReadAllLines
    // moviedb has problems in mono because of the / escaping problem
    |> Array.filter (fun str -> not (isMono && str.Contains "themoviedb"))
    |> Array.map TypeProviderInstantiation.Parse

let expectedDirectory = sourceDirectory ++ "expected" 

let getExpectedPath testCase = 
    expectedDirectory ++ (testCase.ToString().Replace("://", "_").Replace("/", "_") + ".expected")

let resolutionFolder = sourceDirectory ++ ".." ++ "FSharp.Data.Tests" ++ "Data"
let assemblyName = "FSharp.Data.Experimental.dll"
let runtimeAssembly = sourceDirectory ++ ".." ++ ".." ++ "bin" ++ assemblyName
let portable47RuntimeAssembly = sourceDirectory ++ ".." ++ ".." ++ "bin" ++ "portable47" ++ assemblyName
let portable7RuntimeAssembly = sourceDirectory ++ ".." ++ ".." ++ "bin" ++ "portable7" ++ assemblyName

let generateAllExpected() =
    if not <| Directory.Exists expectedDirectory then 
        Directory.CreateDirectory expectedDirectory |> ignore
    for testCase in testCases do
        let output = testCase.Dump resolutionFolder runtimeAssembly Platform.Full (*signatureOnly*)false (*ignoreOutput*)false
        File.WriteAllText(getExpectedPath testCase, output)

let normalize (str:string) =
  str.Replace("\r\n", "\n")
     .Replace("\r", "\n")
     .Replace(" \"<SOURCE_DIRECTORY>/../FSharp.Data.Tests/Data", " @\"<SOURCE_DIRECTORY>\..\FSharp.Data.Tests\Data")

[<Test>]
{'fraction_non_alphanumeric': 0.1382488479262673, 'fraction_numerical': 0.005610098176718092, 'mean_word_length': 4.104294478527607, 'pattern_counts': {'":': 2, '<': 17, '<?xml version=': 0, '>': 25, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1693821', 'n_tokens_mistral': 1481, 'n_tokens_neox': 1390, 'n_words': 335}