Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix compiled OneOrMany #54

Merged
merged 3 commits into from
Nov 27, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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