Skip to content

Commit

Permalink
Fix compiled OneOrMany (#54)
Browse files Browse the repository at this point in the history
  • Loading branch information
sebastienros authored Nov 27, 2021
1 parent 15fbf00 commit b306212
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 25 deletions.
15 changes: 5 additions & 10 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,18 +25,13 @@ jobs:
- name: Checkout source code
uses: actions/checkout@v2

- name: Setup dotnet 2.1
- name: Setup .NET
uses: actions/setup-dotnet@v1
with:
dotnet-version: 2.1.*
- name: Setup dotnet 3.1
uses: actions/setup-dotnet@v1
with:
dotnet-version: 3.1.*
- name: Setup dotnet 5.0
uses: actions/setup-dotnet@v1
with:
dotnet-version: 5.0.*
dotnet-version: |
3.1.x
5.0.x
6.0.x
- name: Test
run: dotnet test --configuration Release
17 changes: 5 additions & 12 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,20 +17,13 @@ jobs:
- name: Checkout source code
uses: actions/checkout@v2

- name: Setup dotnet 2.1
- name: Setup .NET
uses: actions/setup-dotnet@v1
with:
dotnet-version: 2.1.*

- name: Setup dotnet 3.1
uses: actions/setup-dotnet@v1
with:
dotnet-version: 3.1.*

- name: Setup dotnet 5.0
uses: actions/setup-dotnet@v1
with:
dotnet-version: 5.0.*
dotnet-version: |
3.1.x
5.0.x
6.0.x
- name: Test
run: dotnet test --configuration Release
Expand Down
2 changes: 1 addition & 1 deletion src/Parlot/Fluent/OneOrMany.cs
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public CompilationResult Compile(CompilationContext context)
var result = new CompilationResult();

var success = context.DeclareSuccessVariable(result, false);
var value = context.DeclareValueVariable(result, Expression.Default(typeof(List<T>)));
var value = context.DeclareValueVariable(result, Expression.New(typeof(List<T>)));

// value = new List<T>();
//
Expand Down
2 changes: 1 addition & 1 deletion src/Parlot/Parlot.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="1.0.0" PrivateAssets="all" />
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="1.1.1" PrivateAssets="all" />
</ItemGroup>

<PropertyGroup Condition="'$(TargetFramework)' == 'netstandard2.1' ">
Expand Down
10 changes: 10 additions & 0 deletions test/Parlot.Tests/CompileTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,16 @@ public void ShouldCompileZeroOrManys()
Assert.Equal(new[] { "hello", "world", "hello" }, result);
}

[Fact]
public void ShouldCompileOneOrManys()
{
var parser = OneOrMany(Terms.Text("hello").Or(Terms.Text("world"))).Compile();

var result = parser.Parse(" hello world hello");

Assert.Equal(new[] { "hello", "world", "hello" }, result);
}

[Fact]
public void ShouldCompileZeroOrOne()
{
Expand Down
2 changes: 1 addition & 1 deletion test/Parlot.Tests/Parlot.Tests.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>netcoreapp2.1;net5.0;netcoreapp3.1</TargetFrameworks>
<TargetFrameworks>net5.0;netcoreapp3.1;net6.0</TargetFrameworks>
<IsPackable>false</IsPackable>
<LangVersion>9.0</LangVersion>
</PropertyGroup>
Expand Down

0 comments on commit b306212

Please sign in to comment.