Skip to content

Commit b503325

Browse files
committed
Recharacterize switch/select tests and fix TestFileRewriter path for Linux
- Remove blank lines before `default:` and post-switch `return` that the converter doesn't actually emit - Fix TestFileRewriter path separator (backslash → forward slash, add missing level) so recharacterization works on Linux
1 parent 196f901 commit b503325

File tree

3 files changed

+3
-15
lines changed

3 files changed

+3
-15
lines changed

Tests/CSharp/ExpressionTests/ExpressionTests.cs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2086,7 +2086,6 @@ public void OnLoad(UserInterface? ui)
20862086
case UserInterface.Wisdom:
20872087
activity = 3;
20882088
break;
2089-
20902089
default:
20912090
activity = 4;
20922091
break;
@@ -2301,7 +2300,6 @@ public int OnLoad()
23012300
}
23022301
23032302
break;
2304-
23052303
default:
23062304
if (true)
23072305
{
@@ -2363,7 +2361,6 @@ public void S()
23632361
case var case3 when Operators.ConditionalCompareObjectGreater(case3, 4, false):
23642362
j = 4;
23652363
break;
2366-
23672364
default:
23682365
j = -1;
23692366
break;

Tests/CSharp/StatementTests/MethodStatementTests.cs

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
using System.Threading.Tasks;
1+
using System.Threading.Tasks;
22
using ICSharpCode.CodeConverter.Tests.TestRunners;
33
using Xunit;
44

@@ -1051,7 +1051,6 @@ private void TestMethod(int number)
10511051
case 5:
10521052
Console.Write(""section 5"");
10531053
break;
1054-
10551054
default:
10561055
Console.Write(""default section"");
10571056
break;
@@ -1089,7 +1088,6 @@ public static string TimeAgo(int daysAgo)
10891088
return ""this week"";
10901089
case var case4 when case4 > 0:
10911090
return daysAgo / 7 + "" weeks ago"";
1092-
10931091
default:
10941092
return ""in the future"";
10951093
}
@@ -1131,9 +1129,7 @@ public static bool IsPrivileged(UserLevel level)
11311129
switch (level)
11321130
{
11331131
case var @case when (int)UserLevel.City_Staff <= (int)@case && (int)@case <= (int)UserLevel.Fixity_ROOT:
1134-
{
1135-
return true;
1136-
}
1132+
return true;
11371133
}
11381134
return false;
11391135
}
@@ -1173,7 +1169,6 @@ public static string TimeAgo(string x)
11731169
return ""c"";
11741170
case ""d"":
11751171
return ""d"";
1176-
11771172
default:
11781173
return ""e"";
11791174
}
@@ -1226,7 +1221,6 @@ public bool CanDoWork(object Something)
12261221
case object _ when Something is int:
12271222
// Do something with the Integer
12281223
return true;
1229-
12301224
default:
12311225
// Do something else
12321226
return false;
@@ -1270,7 +1264,6 @@ public void DoesNotThrow()
12701264
break;
12711265
case var case1 when case1 > 4:
12721266
break;
1273-
12741267
default:
12751268
throw new Exception();
12761269
}
@@ -1551,7 +1544,6 @@ private static double d1mach(int i)
15511544
case 2:
15521545
return double.MaxValue; // the largest magnitude.
15531546
}
1554-
15551547
return 0d;
15561548
}
15571549
}");
@@ -1586,7 +1578,6 @@ private static string Describe(int i)
15861578
case 2:
15871579
return ""two"";
15881580
}
1589-
15901581
return null;
15911582
}
15921583
}");

Tests/TestRunners/TestFileRewriter.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ private static Dictionary<string, string> GetTestFileContents()
2020
private static string GetTestSourceDirectoryPath()
2121
{
2222
string assemblyDir = Path.GetDirectoryName(new Uri(Assembly.GetExecutingAssembly().Location).AbsolutePath);
23-
string testSourceDirectoryPath = Path.Combine(assemblyDir, @"..\..\");
23+
string testSourceDirectoryPath = Path.Combine(assemblyDir, "..", "..", "..");
2424
return testSourceDirectoryPath;
2525
}
2626

0 commit comments

Comments
 (0)