Skip to content

Commit

Permalink
Add test ensuring Length is only called once
Browse files Browse the repository at this point in the history
  • Loading branch information
jbevain committed Mar 7, 2024
1 parent cdd8f75 commit 18b3599
Showing 1 changed file with 36 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -33646,5 +33646,41 @@ static string Invoke(Action a)
IList<T>.RemoveAt(0): System.NotSupportedException
""");
}

[CombinatorialData]
[Theory]
public void CreatingNewListFromLengthWithSideEffects([CombinatorialValues(TargetFramework.Net70, TargetFramework.Net80)], TargetFramework targetFramework)

Check failure on line 33652 in src/Compilers/CSharp/Test/Emit2/Semantics/CollectionExpressionTests.cs

View check run for this annotation

Azure Pipelines / roslyn-CI (Unix_Build Build_Unix_Debug)

src/Compilers/CSharp/Test/Emit2/Semantics/CollectionExpressionTests.cs#L33652

src/Compilers/CSharp/Test/Emit2/Semantics/CollectionExpressionTests.cs(33652,129): error CS1031: (NETCORE_ENGINEERING_TELEMETRY=Build) Type expected

Check failure on line 33652 in src/Compilers/CSharp/Test/Emit2/Semantics/CollectionExpressionTests.cs

View check run for this annotation

Azure Pipelines / roslyn-CI (Unix_Build Build_Unix_Debug)

src/Compilers/CSharp/Test/Emit2/Semantics/CollectionExpressionTests.cs#L33652

src/Compilers/CSharp/Test/Emit2/Semantics/CollectionExpressionTests.cs(33652,129): error CS1001: (NETCORE_ENGINEERING_TELEMETRY=Build) Identifier expected

Check failure on line 33652 in src/Compilers/CSharp/Test/Emit2/Semantics/CollectionExpressionTests.cs

View check run for this annotation

Azure Pipelines / roslyn-CI (Unix_Build Build_Unix_Debug)

src/Compilers/CSharp/Test/Emit2/Semantics/CollectionExpressionTests.cs#L33652

src/Compilers/CSharp/Test/Emit2/Semantics/CollectionExpressionTests.cs(33652,129): error CS1031: (NETCORE_ENGINEERING_TELEMETRY=Build) Type expected

Check failure on line 33652 in src/Compilers/CSharp/Test/Emit2/Semantics/CollectionExpressionTests.cs

View check run for this annotation

Azure Pipelines / roslyn-CI (Unix_Build Build_Unix_Debug)

src/Compilers/CSharp/Test/Emit2/Semantics/CollectionExpressionTests.cs#L33652

src/Compilers/CSharp/Test/Emit2/Semantics/CollectionExpressionTests.cs(33652,129): error CS1001: (NETCORE_ENGINEERING_TELEMETRY=Build) Identifier expected

Check failure on line 33652 in src/Compilers/CSharp/Test/Emit2/Semantics/CollectionExpressionTests.cs

View check run for this annotation

Azure Pipelines / roslyn-CI (Correctness Correctness_Analyzers)

src/Compilers/CSharp/Test/Emit2/Semantics/CollectionExpressionTests.cs#L33652

src/Compilers/CSharp/Test/Emit2/Semantics/CollectionExpressionTests.cs(33652,129): error CS1031: (NETCORE_ENGINEERING_TELEMETRY=Build) Type expected

Check failure on line 33652 in src/Compilers/CSharp/Test/Emit2/Semantics/CollectionExpressionTests.cs

View check run for this annotation

Azure Pipelines / roslyn-CI (Correctness Correctness_Analyzers)

src/Compilers/CSharp/Test/Emit2/Semantics/CollectionExpressionTests.cs#L33652

src/Compilers/CSharp/Test/Emit2/Semantics/CollectionExpressionTests.cs(33652,129): error CS1001: (NETCORE_ENGINEERING_TELEMETRY=Build) Identifier expected

Check failure on line 33652 in src/Compilers/CSharp/Test/Emit2/Semantics/CollectionExpressionTests.cs

View check run for this annotation

Azure Pipelines / roslyn-CI (Correctness Correctness_Analyzers)

src/Compilers/CSharp/Test/Emit2/Semantics/CollectionExpressionTests.cs#L33652

src/Compilers/CSharp/Test/Emit2/Semantics/CollectionExpressionTests.cs(33652,129): error CS1031: (NETCORE_ENGINEERING_TELEMETRY=Build) Type expected

Check failure on line 33652 in src/Compilers/CSharp/Test/Emit2/Semantics/CollectionExpressionTests.cs

View check run for this annotation

Azure Pipelines / roslyn-CI (Correctness Correctness_Analyzers)

src/Compilers/CSharp/Test/Emit2/Semantics/CollectionExpressionTests.cs#L33652

src/Compilers/CSharp/Test/Emit2/Semantics/CollectionExpressionTests.cs(33652,129): error CS1001: (NETCORE_ENGINEERING_TELEMETRY=Build) Identifier expected

Check failure on line 33652 in src/Compilers/CSharp/Test/Emit2/Semantics/CollectionExpressionTests.cs

View check run for this annotation

Azure Pipelines / roslyn-CI

src/Compilers/CSharp/Test/Emit2/Semantics/CollectionExpressionTests.cs#L33652

src/Compilers/CSharp/Test/Emit2/Semantics/CollectionExpressionTests.cs(33652,129): error CS1031: (NETCORE_ENGINEERING_TELEMETRY=Build) Type expected

Check failure on line 33652 in src/Compilers/CSharp/Test/Emit2/Semantics/CollectionExpressionTests.cs

View check run for this annotation

Azure Pipelines / roslyn-CI

src/Compilers/CSharp/Test/Emit2/Semantics/CollectionExpressionTests.cs#L33652

src/Compilers/CSharp/Test/Emit2/Semantics/CollectionExpressionTests.cs(33652,129): error CS1001: (NETCORE_ENGINEERING_TELEMETRY=Build) Identifier expected

Check failure on line 33652 in src/Compilers/CSharp/Test/Emit2/Semantics/CollectionExpressionTests.cs

View check run for this annotation

Azure Pipelines / roslyn-CI

src/Compilers/CSharp/Test/Emit2/Semantics/CollectionExpressionTests.cs#L33652

src/Compilers/CSharp/Test/Emit2/Semantics/CollectionExpressionTests.cs(33652,129): error CS1031: (NETCORE_ENGINEERING_TELEMETRY=Build) Type expected

Check failure on line 33652 in src/Compilers/CSharp/Test/Emit2/Semantics/CollectionExpressionTests.cs

View check run for this annotation

Azure Pipelines / roslyn-CI

src/Compilers/CSharp/Test/Emit2/Semantics/CollectionExpressionTests.cs#L33652

src/Compilers/CSharp/Test/Emit2/Semantics/CollectionExpressionTests.cs(33652,129): error CS1001: (NETCORE_ENGINEERING_TELEMETRY=Build) Identifier expected
{
string source = """
using System;
using System.Collections;
using System.Collections.Generic;
class MyCollection<T> : IEnumerable<T>
{
private List<T> _list = new();
public int Length
{
get { Console.Write("Length: {0}, ", _list.Count); return _list.Count; }
}
public void Add(T t) { _list.Add(t); }
IEnumerator<T> IEnumerable<T>.GetEnumerator() => _list.GetEnumerator();
IEnumerator IEnumerable.GetEnumerator() => _list.GetEnumerator();
}
class Program
{
static void Main()
{
MyCollection<int> x = [1, 2];
MyCollection<object> y = [3];
List<object> z = [..x, ..y];
}
}
""";
CompileAndVerify(
source,
targetFramework: targetFramework,
verify: Verification.Skipped,
expectedOutput: IncludeExpectedOutput("Length: 2, Length: 1, "));
}
}
}

0 comments on commit 18b3599

Please sign in to comment.