Skip to content

Commit

Permalink
simple test cases
Browse files Browse the repository at this point in the history
  • Loading branch information
robertluo committed Jul 24, 2019
1 parent 2cb2b1e commit f98e7c8
Show file tree
Hide file tree
Showing 11 changed files with 137 additions and 91 deletions.
7 changes: 7 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": []
}
17 changes: 17 additions & 0 deletions Edn.Net.sln
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{CE2115A8-CB3
EndProject
Project("{F2A71F9B-5D33-465A-A702-920D77279786}") = "Edn.Net", "src\Edn.Net\Edn.Net.fsproj", "{801C9BEE-B3C0-4316-9DD9-918B3C0BB2C7}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "test", "test", "{412558C6-F141-40B2-B08A-8BE09CBF255B}"
EndProject
Project("{F2A71F9B-5D33-465A-A702-920D77279786}") = "Edn.Net.Test", "test\Edn.Net.Test\Edn.Net.Test.fsproj", "{6CA2C52D-D3FC-427E-9608-19D34BC3B74E}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand All @@ -32,8 +36,21 @@ Global
{801C9BEE-B3C0-4316-9DD9-918B3C0BB2C7}.Release|x64.Build.0 = Release|Any CPU
{801C9BEE-B3C0-4316-9DD9-918B3C0BB2C7}.Release|x86.ActiveCfg = Release|Any CPU
{801C9BEE-B3C0-4316-9DD9-918B3C0BB2C7}.Release|x86.Build.0 = Release|Any CPU
{6CA2C52D-D3FC-427E-9608-19D34BC3B74E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{6CA2C52D-D3FC-427E-9608-19D34BC3B74E}.Debug|Any CPU.Build.0 = Debug|Any CPU
{6CA2C52D-D3FC-427E-9608-19D34BC3B74E}.Debug|x64.ActiveCfg = Debug|Any CPU
{6CA2C52D-D3FC-427E-9608-19D34BC3B74E}.Debug|x64.Build.0 = Debug|Any CPU
{6CA2C52D-D3FC-427E-9608-19D34BC3B74E}.Debug|x86.ActiveCfg = Debug|Any CPU
{6CA2C52D-D3FC-427E-9608-19D34BC3B74E}.Debug|x86.Build.0 = Debug|Any CPU
{6CA2C52D-D3FC-427E-9608-19D34BC3B74E}.Release|Any CPU.ActiveCfg = Release|Any CPU
{6CA2C52D-D3FC-427E-9608-19D34BC3B74E}.Release|Any CPU.Build.0 = Release|Any CPU
{6CA2C52D-D3FC-427E-9608-19D34BC3B74E}.Release|x64.ActiveCfg = Release|Any CPU
{6CA2C52D-D3FC-427E-9608-19D34BC3B74E}.Release|x64.Build.0 = Release|Any CPU
{6CA2C52D-D3FC-427E-9608-19D34BC3B74E}.Release|x86.ActiveCfg = Release|Any CPU
{6CA2C52D-D3FC-427E-9608-19D34BC3B74E}.Release|x86.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(NestedProjects) = preSolution
{801C9BEE-B3C0-4316-9DD9-918B3C0BB2C7} = {CE2115A8-CB37-4BC5-BCDC-40CFE0E63AF4}
{6CA2C52D-D3FC-427E-9608-19D34BC3B74E} = {412558C6-F141-40B2-B08A-8BE09CBF255B}
EndGlobalSection
EndGlobal
9 changes: 9 additions & 0 deletions build.cmd
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
@echo off
cls

.paket\paket.exe restore
if errorlevel 1 (
exit /b %errorlevel%
)

packages\build\FAKE\tools\FAKE.exe build.fsx %*
21 changes: 21 additions & 0 deletions build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#!/bin/bash
if test "$OS" = "Windows_NT"
then
# use .Net

.paket/paket.exe restore
exit_code=$?
if [ $exit_code -ne 0 ]; then
exit $exit_code
fi

packages/build/FAKE/tools/FAKE.exe $@ --fsiargs build.fsx
else
# use mono
mono .paket/paket.exe restore
exit_code=$?
if [ $exit_code -ne 0 ]; then
exit $exit_code
fi
mono packages/build/FAKE/tools/FAKE.exe $@ --fsiargs -d:MONO build.fsx
fi
1 change: 1 addition & 0 deletions paket.dependencies
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
source https://www.nuget.org/api/v2
nuget Expecto
nuget FParseC 1.0.4-RC3 RC
129 changes: 38 additions & 91 deletions paket.lock

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions src/Edn.Net/Library.fs
Original file line number Diff line number Diff line change
Expand Up @@ -88,3 +88,5 @@ module Edn =
eset
ekeyword
estring]

let Parse = run evalue
16 changes: 16 additions & 0 deletions test/Edn.Net.Test/Edn.Net.Test.fsproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>netcoreapp2.1</TargetFramework>
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="../../src/Edn.Net/Edn.Net.fsproj">
<Name>Edn.Net.fsproj</Name>
</ProjectReference>
</ItemGroup>
<ItemGroup>
<Compile Include="Tests.fs" />
<Compile Include="Main.fs" />
</ItemGroup>
<Import Project="..\..\.paket\Paket.Restore.targets" />
</Project>
7 changes: 7 additions & 0 deletions test/Edn.Net.Test/Main.fs
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
module Edn.Net.Test

open Expecto

[<EntryPoint>]
let main argv =
Tests.runTestsInAssembly defaultConfig argv
17 changes: 17 additions & 0 deletions test/Edn.Net.Test/Tests.fs
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
module Tests

open Expecto
open Robertluo.Edn
open FParsec

[<Tests>]
let tests =
testList "samples" [
testCase "parse overall" <| fun _ ->
match Parse "[3.0 :foo/bar]" with
| Success (v, _, _) -> Expect.equal v (EVector [
(EFloat 3.0);
(EKeyword {ns = Some "foo"; symbol = "bar"})])
"should equal"
| _ -> failwith "unable to match"
]
2 changes: 2 additions & 0 deletions test/Edn.Net.Test/paket.references
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
FSharp.Core
Expecto

0 comments on commit f98e7c8

Please sign in to comment.