forked from fsprojects/FSharp.Data
-
Notifications
You must be signed in to change notification settings - Fork 5
/
Test.fsx
109 lines (95 loc) · 3.56 KB
/
Test.fsx
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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
#if INTERACTIVE
#load "SetupTesting.fsx"
SetupTesting.generateSetupScript __SOURCE_DIRECTORY__ "FSharp.Data.DesignTime"
#load "__setup__FSharp.Data.DesignTime__.fsx"
#else
module internal Test
#endif
open System
open System.Globalization
open System.IO
open ProviderImplementation
open FSharp.Data
open FSharp.Data.Runtime
let (++) a b = Path.Combine(a, b)
let resolutionFolder = __SOURCE_DIRECTORY__ ++ ".." ++ "tests" ++ "FSharp.Data.Tests" ++ "Data"
let outputFolder = __SOURCE_DIRECTORY__ ++ ".." ++ "tests" ++ "FSharp.Data.DesignTime.Tests" ++ "expected"
let assemblyName = "FSharp.Data.dll"
let dump signatureOnly ignoreOutput platform saveToFileSystem (inst:TypeProviderInstantiation) =
let runtimeAssembly =
match platform with
| Net40 -> __SOURCE_DIRECTORY__ ++ ".." ++ "bin" ++ assemblyName
| Portable7 -> __SOURCE_DIRECTORY__ ++ ".." ++ "bin" ++ "portable7" ++ assemblyName
| Portable47 -> __SOURCE_DIRECTORY__ ++ ".." ++ "bin" ++ "portable47" ++ assemblyName
| Portable259 -> __SOURCE_DIRECTORY__ ++ ".." ++ "bin" ++ "portable259" ++ assemblyName
let runtimeAssemblyRefs = TypeProviderInstantiation.GetRuntimeAssemblyRefs platform
inst.Dump(resolutionFolder, (if saveToFileSystem then outputFolder else ""), runtimeAssembly, runtimeAssemblyRefs, signatureOnly, ignoreOutput)
|> Console.WriteLine
let dumpAll inst =
dump false false Net40 false inst
// dump false false Portable7 false inst
// dump false false Portable47 false inst
// dump false false Portable259 false inst
let parameters : HtmlInference.Parameters =
{ MissingValues = TextConversions.DefaultMissingValues
CultureInfo = CultureInfo.InvariantCulture
UnitsOfMeasureProvider = StructuralInference.defaultUnitsOfMeasureProvider
PreferOptionals = false }
let includeLayout = false
let printTable tableName (url:string) =
url
|> HtmlDocument.Load
|> HtmlRuntime.getTables (Some parameters) includeLayout
|> List.filter (fun table -> table.Name = tableName)
|> List.iter (printfn "+++++++++++++++++++++++++++++++++++++\n%O")
printTable "Overview" "https://en.wikipedia.org/wiki/List_of_Doctor_Who_serials"
Html { Sample = "doctor_who3.html"
PreferOptionals = false
IncludeLayoutTables = false
MissingValues = "NaN,NA,N/A,#N/A,:,-,TBA,TBD"
Culture = ""
Encoding = ""
ResolutionFolder = ""
EmbeddedResource = "" }
|> dumpAll
Json { Sample = "optionals.json"
SampleIsList = false
RootName = ""
Culture = ""
Encoding = ""
ResolutionFolder = ""
EmbeddedResource = ""
InferTypesFromValues = true }
|> dumpAll
Xml { Sample = "JsonInXml.xml"
SampleIsList = true
Global = false
Culture = ""
Encoding = ""
ResolutionFolder = ""
EmbeddedResource = ""
InferTypesFromValues = true }
|> dumpAll
Csv { Sample = "AirQuality.csv"
Separators = ";"
InferRows = Int32.MaxValue
Schema = ""
HasHeaders = true
IgnoreErrors = false
SkipRows = 0
AssumeMissingValues = false
PreferOptionals = false
Quote = '"'
MissingValues = "NaN,NA,N/A,#N/A,:,-,TBA,TBD"
CacheRows = true
Culture = ""
Encoding = ""
ResolutionFolder = ""
EmbeddedResource = "" }
|> dumpAll
let testCases =
__SOURCE_DIRECTORY__ ++ ".." ++ "tests" ++ "FSharp.Data.DesignTime.Tests" ++ "SignatureTestCases.config"
|> File.ReadAllLines
|> Array.map (TypeProviderInstantiation.Parse >> snd)
for testCase in testCases do
dump false false Net40 true testCase