Skip to content

Commit

Permalink
Enable skipped tests and fix them (#21335)
Browse files Browse the repository at this point in the history
  • Loading branch information
jcouv committed Aug 8, 2017
1 parent 412c248 commit 6a2133c
Show file tree
Hide file tree
Showing 5 changed files with 119 additions and 77 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2900,7 +2900,7 @@ public void M()
);
}

[Fact(Skip = "https://github.com/dotnet/roslyn/issues/21079")]
[Fact]
[WorkItem(16947, "https://github.com/dotnet/roslyn/issues/16947")]
public void Dynamic003()
{
Expand Down Expand Up @@ -2930,13 +2930,12 @@ public void M()
";

CreateCompilationWithMscorlib45AndCSruntime(source).VerifyEmitDiagnostics(
// (14,28): error CS8156: An expression cannot be used in this context because it may not be returned by reference
// (14,26): error CS8156: An expression cannot be used in this context because it may not be returned by reference
// return ref G(ref d.Length);
Diagnostic(ErrorCode.ERR_RefReturnLvalueExpected, "d.Length").WithLocation(14, 28),
Diagnostic(ErrorCode.ERR_RefReturnLvalueExpected, "d.Length").WithLocation(14, 26),
// (14,20): error CS8164: Cannot return by reference a result of 'C.G(ref dynamic)' because the argument passed to parameter 'd' cannot be returned by reference
// return ref G(ref d.Length);
Diagnostic(ErrorCode.ERR_RefReturnCall, "G(ref d.Length)").WithArguments("C.G(ref dynamic)", "d").WithLocation(14, 20)

);
}

Expand Down
129 changes: 87 additions & 42 deletions src/Compilers/CSharp/Test/Emit/CodeGen/CodeGenThrowTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ .maxstack 1
");
}

[Fact(Skip = "https://github.com/dotnet/roslyn/issues/21079")]
[Fact]
public void TestRethrowImplicit()
{
var source = @"
Expand All @@ -91,6 +91,7 @@ static void Main()
{
try
{
System.Console.WriteLine();
}
catch
{
Expand All @@ -101,28 +102,24 @@ static void Main()
var compilation = CompileAndVerify(source);

compilation.VerifyIL("C.Main", @"{
// Code size 11 (0xb)
// Code size 11 (0xb)
.maxstack 1
IL_0000: nop
.try
{
IL_0001: nop
IL_0002: nop
IL_0003: leave.s IL_0009
} // end .try
catch [mscorlib]System.Object
IL_0000: call ""void System.Console.WriteLine()""
IL_0005: leave.s IL_000a
}
catch object
{
IL_0005: pop
IL_0006: nop
IL_0007: rethrow
} // end handler
IL_0009: nop
IL_000a: ret
IL_0007: pop
IL_0008: rethrow
}
IL_000a: ret
}
");
}

[Fact(Skip = "https://github.com/dotnet/roslyn/issues/21079")]
[Fact]
public void TestRethrowTyped()
{
var source = @"
Expand All @@ -142,28 +139,52 @@ static void Main()
var compilation = CompileAndVerify(source);

compilation.VerifyIL("C.Main", @"{
// Code size 11 (0xb)
// Code size 1 (0x1)
.maxstack 0
IL_0000: ret
}
");
}

[Fact]
public void TestRethrowTyped2()
{
var source = @"
class C
{
static void Main()
{
try
{
System.Console.WriteLine();
}
catch (System.Exception)
{
throw;
}
}
}";
var compilation = CompileAndVerify(source);

compilation.VerifyIL("C.Main", @"{
// Code size 11 (0xb)
.maxstack 1
IL_0000: nop
.try
{
IL_0001: nop
IL_0002: nop
IL_0003: leave.s IL_0009
} // end .try
catch [mscorlib]System.Exception
IL_0000: call ""void System.Console.WriteLine()""
IL_0005: leave.s IL_000a
}
catch System.Exception
{
IL_0005: pop
IL_0006: nop
IL_0007: rethrow
} // end handler
IL_0009: nop
IL_000a: ret
IL_0007: pop
IL_0008: rethrow
}
IL_000a: ret
}
");
}

[Fact(Skip = "https://github.com/dotnet/roslyn/issues/21079")]
[Fact]
public void TestRethrowNamed()
{
var source = @"
Expand All @@ -183,23 +204,47 @@ static void Main()
var compilation = CompileAndVerify(source);

compilation.VerifyIL("C.Main", @"{
// Code size 11 (0xb)
// Code size 1 (0x1)
.maxstack 0
IL_0000: ret
}
");
}

[Fact]
public void TestRethrowNamed2()
{
var source = @"
class C
{
static void Main()
{
try
{
System.Console.WriteLine();
}
catch (System.Exception e)
{
throw;
}
}
}";
var compilation = CompileAndVerify(source);

compilation.VerifyIL("C.Main", @"{
// Code size 11 (0xb)
.maxstack 1
IL_0000: nop
.try
{
IL_0001: nop
IL_0002: nop
IL_0003: leave.s IL_0009
} // end .try
catch [mscorlib]System.Exception
IL_0000: call ""void System.Console.WriteLine()""
IL_0005: leave.s IL_000a
}
catch System.Exception
{
IL_0005: stloc.0
IL_0006: nop
IL_0007: rethrow
} // end handler
IL_0009: nop
IL_000a: ret
IL_0007: pop
IL_0008: rethrow
}
IL_000a: ret
}
");
}
Expand Down
42 changes: 21 additions & 21 deletions src/Compilers/CSharp/Test/Emit/PDB/PDBTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6795,32 +6795,32 @@ static void M()

#region Patterns

[Fact(Skip = "https://github.com/dotnet/roslyn/issues/21079")]
[Fact]
public void SyntaxOffset_Pattern()
{
var source = @"class C { bool F(object o) => o is int i && o is 3 && o is bool; }";
var c = CreateCompilationWithMscorlibAndSystemCore(source, options: TestOptions.DebugDll);
c.VerifyPdb("C.F", @"<symbols>
<methods>
<method containingType=""C"" name=""F"" parameterNames=""o"">
<customDebugInfo>
<using>
<namespace usingCount=""0"" />
</using>
<encLocalSlotMap>
<slot kind=""0"" offset=""12"" />
<slot kind=""temp"" />
</encLocalSlotMap>
</customDebugInfo>
<sequencePoints>
<entry offset=""0x0"" startLine=""1"" startColumn=""31"" endLine=""1"" endColumn=""64"" />
</sequencePoints>
<scope startOffset=""0x0"" endOffset=""0x38"">
<local name=""i"" il_index=""0"" il_start=""0x0"" il_end=""0x38"" attributes=""0"" />
</scope>
</method>
</methods>
</symbols>");
<methods>
<method containingType=""C"" name=""F"" parameterNames=""o"">
<customDebugInfo>
<using>
<namespace usingCount=""0"" />
</using>
<encLocalSlotMap>
<slot kind=""0"" offset=""12"" />
<slot kind=""temp"" />
</encLocalSlotMap>
</customDebugInfo>
<sequencePoints>
<entry offset=""0x0"" startLine=""1"" startColumn=""31"" endLine=""1"" endColumn=""64"" />
</sequencePoints>
<scope startOffset=""0x0"" endOffset=""0x35"">
<local name=""i"" il_index=""0"" il_start=""0x0"" il_end=""0x35"" attributes=""0"" />
</scope>
</method>
</methods>
</symbols>");
}

#endregion
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ static void M1()
VerifyOperationTreeAndDiagnosticsForTest<InvocationExpressionSyntax>(source, expectedOperationTree, expectedDiagnostics);
}

[Fact(Skip = "https://github.com/dotnet/roslyn/issues/21079")]
[Fact]
public void NamedArgumentInParameterOrderWithDefaultValue()
{
string source = @"
Expand All @@ -157,7 +157,7 @@ static void M1()
IArgument (ArgumentKind.Explicit, Matching Parameter: z) (OperationKind.Argument) (Syntax: '2')
ILiteralExpression (Text: 2) (OperationKind.LiteralExpression, Type: System.Int32, Constant: 2) (Syntax: '2')
IArgument (ArgumentKind.DefaultValue, Matching Parameter: x) (OperationKind.Argument) (Syntax: 'M2(y: 0, z: 2)')
ILiteralExpression (Text: 1) (OperationKind.LiteralExpression, Type: System.Int32, Constant: 1) (Syntax: 'M2(y: 0, z: 2)')
ILiteralExpression (OperationKind.LiteralExpression, Type: System.Int32, Constant: 1) (Syntax: 'M2(y: 0, z: 2)')
";
var expectedDiagnostics = DiagnosticDescription.None;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1852,7 +1852,7 @@ public void TestFromOrderByDescendingSelect()
Assert.Null(qs.Body.Continuation);
}

[Fact(Skip = "https://github.com/dotnet/roslyn/issues/21079")]
[Fact]
public void TestFromGroupBy()
{
var text = "from a in A group b by c";
Expand All @@ -1864,10 +1864,9 @@ public void TestFromGroupBy()
Assert.Equal(0, expr.Errors().Length);

var qs = (QueryExpressionSyntax)expr;
Assert.Equal(1, qs.Body.Clauses.Count);
Assert.Equal(SyntaxKind.FromClause, qs.Body.Clauses[0].Kind());
Assert.Equal(0, qs.Body.Clauses.Count);

var fs = (FromClauseSyntax)qs.Body.Clauses[0];
var fs = qs.FromClause;
Assert.NotNull(fs.FromKeyword);
Assert.False(fs.FromKeyword.IsMissing);
Assert.Null(fs.Type);
Expand All @@ -1892,7 +1891,7 @@ public void TestFromGroupBy()
Assert.Null(qs.Body.Continuation);
}

[Fact(Skip = "https://github.com/dotnet/roslyn/issues/21079")]
[Fact]
public void TestFromGroupByIntoSelect()
{
var text = "from a in A group b by c into d select e";
Expand All @@ -1904,10 +1903,9 @@ public void TestFromGroupByIntoSelect()
Assert.Equal(0, expr.Errors().Length);

var qs = (QueryExpressionSyntax)expr;
Assert.Equal(1, qs.Body.Clauses.Count);
Assert.Equal(SyntaxKind.FromClause, qs.Body.Clauses[0].Kind());
Assert.Equal(0, qs.Body.Clauses.Count);

var fs = (FromClauseSyntax)qs.Body.Clauses[0];
var fs = qs.FromClause;
Assert.NotNull(fs.FromKeyword);
Assert.False(fs.FromKeyword.IsMissing);
Assert.Null(fs.Type);
Expand Down

0 comments on commit 6a2133c

Please sign in to comment.