Skip to content

Commit e1e23f8

Browse files
committed
Remove some C# tests that were not consistent with the final design of the type name resolver. And a few Format tests that were incorrect with current practice.
1 parent 2f2dc58 commit e1e23f8

File tree

3 files changed

+86
-82
lines changed

3 files changed

+86
-82
lines changed

Clojure/Csharp.Tests/LibTests/PrintfTests.cs

Lines changed: 50 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,11 @@
1212
* Author: David Miller
1313
**/
1414

15-
using System;
16-
17-
using NUnit.Framework;
18-
using static NExpect.Expectations;
1915
using clojure.lang;
2016
using NExpect;
17+
using NUnit.Framework;
18+
using System;
19+
using static NExpect.Expectations;
2120

2221
namespace Clojure.Tests.LibTests
2322
{
@@ -26,7 +25,7 @@ public class PrintfTests
2625
{
2726
void Test(string result, string fmt, params object[] args)
2827
{
29-
Expect(Printf.Format(fmt,args)).To.Equal(result);
28+
Expect(Printf.Format(fmt, args)).To.Equal(result);
3029
}
3130

3231
[SetUp]
@@ -40,19 +39,19 @@ public void SetUpCultureAware()
4039
[Test]
4140
public void WorksOnEmptyString()
4241
{
43-
Test("","");
42+
Test("", "");
4443
}
4544

4645
[Test]
4746
public void WorksOnStringWithNoFormats()
4847
{
49-
Test("abc","abc");
48+
Test("abc", "abc");
5049
}
5150

5251
[Test]
5352
public void WorksOnStringWithPercentSpec()
5453
{
55-
Test("abc%def%","abc%%def%%");
54+
Test("abc%def%", "abc%%def%%");
5655
}
5756

5857
[Test]
@@ -75,7 +74,7 @@ public void FailsOnStringWithOddNumberOfPercents()
7574
[Test]
7675
public void WorksWithBasicArgument()
7776
{
78-
Test("abc12def","abc%ddef",12);
77+
Test("abc12def", "abc%ddef", 12);
7978
}
8079

8180

@@ -113,7 +112,7 @@ public void ArgIndexingWorks()
113112
[Test]
114113
public void SucceedsOnZeroArgIndexThoughIDontKnowWhyJavaDoes()
115114
{
116-
Test("abc12def","abc%0$ddef", 12);
115+
Test("abc12def", "abc%0$ddef", 12);
117116
}
118117

119118
[Test]
@@ -182,44 +181,44 @@ public void GeneralSpecWithBadLeftJustifyWidthFails()
182181
[Test]
183182
public void BooleanSpecPrintsNullOnNull()
184183
{
185-
Test("False", "%b", null); // Spec error: false.ToString() == "False", spec says do this but expects "false"
184+
Test("false", "%b", null); // Spec error: false.ToString() == "False", spec says do this but expects "false"
186185
Test("FALSE", "%B", null);
187186
}
188187

189188
[Test]
190189
public void BooleanSpecPrintsFalseOnFalse()
191190
{
192-
Test("False", "%b", false); // Spec error: false.ToString() == "False", spec says do this but expects "false"
191+
Test("false", "%b", false); // Spec error: false.ToString() == "False", spec says do this but expects "false"
193192
Test("FALSE", "%B", false);
194193
}
195194

196195
[Test]
197196
public void BooleanSpecPrintsTrueOnTrue()
198197
{
199-
Test("True", "%b", true); // Spec error: true.ToString() == "True", spec says do this but expects "true"
198+
Test("true", "%b", true); // Spec error: true.ToString() == "True", spec says do this but expects "true"
200199
Test("TRUE", "%B", true);
201200
}
202201

203202
[Test]
204203
public void BooleanSpecPrintsFalseOnOtherArg()
205204
{
206-
Test("True", "%b", 12); // Spec error: true.ToString() == "True", spec says do this but expects "true"
205+
Test("true", "%b", 12); // Spec error: true.ToString() == "True", spec says do this but expects "true"
207206
Test("TRUE", "%B", 12);
208-
Test("True", "%b", "abc");
207+
Test("true", "%b", "abc");
209208
}
210209

211210
[Test]
212211
public void BooleanSpecPrintUsingWidth()
213212
{
214-
Test(" True", "%9b", 12);
215-
Test(" False", "%9b", false);
213+
Test(" true", "%9b", 12);
214+
Test(" false", "%9b", false);
216215
}
217216

218217
[Test]
219218
public void BooleanSpecPrintUsingLeftJustifyWidth()
220219
{
221-
Test("True ", "%-9b", 12);
222-
Test("False ", "%-9b", false);
220+
Test("true ", "%-9b", 12);
221+
Test("false ", "%-9b", false);
223222
}
224223

225224
[Test]
@@ -232,7 +231,7 @@ public void HashSpecPrintHashCode()
232231
[Test]
233232
public void HashSpecPrintsNullOnNull()
234233
{
235-
Test("null", "%h", null);
234+
Test("null", "%h", null);
236235
Test("NULL", "%H", null);
237236
}
238237

@@ -275,7 +274,7 @@ public void StringSpecPrintsUsingLeftJustify()
275274
Test("abcde ", "%-12s", "abcde");
276275
}
277276

278-
//TODO: For String spec, test other arg types
277+
//TODO: For String spec, test other arg types
279278
// TODO: For String spec, test IFormattable
280279

281280
#endregion
@@ -522,7 +521,7 @@ public void HexIntSpecWIthPlusFlagFails()
522521
[Test]
523522
public void OctIntSpecBasicallyWorks()
524523
{
525-
Test("30071","%o",12345);
524+
Test("30071", "%o", 12345);
526525
Test("37777747707", "%o", -12345);
527526
Test(" 30071", "%15o", 12345);
528527
Test(" 37777747707", "%15o", -12345);
@@ -580,12 +579,12 @@ public void HexIntSpecZeroPadding()
580579
[Test]
581580
public void DecIntSpecWithBigIntegerArgumentsWorks()
582581
{
583-
Test("123456789","%d",BigInteger.Parse("123456789"));
584-
Test("-123456789","%d",BigInteger.Parse("-123456789"));
585-
Test(" 123456789","%15d",BigInteger.Parse("123456789"));
586-
Test(" -123456789","%15d",BigInteger.Parse("-123456789"));
587-
Test("123456789 ","%-15d",BigInteger.Parse("123456789"));
588-
Test("-123456789 ","%-15d",BigInteger.Parse("-123456789"));
582+
Test("123456789", "%d", BigInteger.Parse("123456789"));
583+
Test("-123456789", "%d", BigInteger.Parse("-123456789"));
584+
Test(" 123456789", "%15d", BigInteger.Parse("123456789"));
585+
Test(" -123456789", "%15d", BigInteger.Parse("-123456789"));
586+
Test("123456789 ", "%-15d", BigInteger.Parse("123456789"));
587+
Test("-123456789 ", "%-15d", BigInteger.Parse("-123456789"));
589588

590589
Test(" +123456789", "%+15d", BigInteger.Parse("123456789"));
591590
Test(" -123456789", "%+15d", BigInteger.Parse("-123456789"));
@@ -764,27 +763,27 @@ public void DecFloatPrintsWithFlags()
764763
public void ScientificFloatPrintsBasics()
765764
{
766765
// Do we want to match the e+xx of the Java version?
767-
Test(" 1.2346e+000","%12.4e",1.23456789e0);
768-
Test(" 1.2346e+001","%12.4e",1.23456789e1);
769-
Test(" 1.2346e+002","%12.4e",1.23456789e2);
770-
Test(" 1.2346e+003","%12.4e",1.23456789e3);
771-
Test(" 1.2346e+004","%12.4e",1.23456789e4);
772-
Test(" 1.2346e+005","%12.4e",1.23456789e5);
773-
Test(" 1.2346e+006","%12.4e",1.23456789e6);
774-
Test(" 1.2346e+007","%12.4e",1.23456789e7);
775-
Test(" 1.2346e+008","%12.4e",1.23456789e8);
776-
Test(" 1.2346e+009","%12.4e",1.23456789e9);
777-
Test(" 1.2346e+010","%12.4e",1.23456789e10);
778-
Test(" 1.2346e-001","%12.4e",1.23456789e-1);
779-
Test(" 1.2346e-002","%12.4e",1.23456789e-2);
780-
Test(" 1.2346e-003","%12.4e",1.23456789e-3);
781-
Test(" 1.2346e-004","%12.4e",1.23456789e-4);
782-
Test(" 1.2346e-005","%12.4e",1.23456789e-5);
783-
Test(" 1.2346e-006","%12.4e",1.23456789e-6);
784-
Test(" 1.2346e-007","%12.4e",1.23456789e-7);
785-
Test(" 1.2346e-008","%12.4e",1.23456789e-8);
786-
Test(" 1.2346e-009","%12.4e",1.23456789e-9);
787-
Test(" 1.2346e-010","%12.4e",1.23456789e-10);
766+
Test(" 1.2346e+000", "%12.4e", 1.23456789e0);
767+
Test(" 1.2346e+001", "%12.4e", 1.23456789e1);
768+
Test(" 1.2346e+002", "%12.4e", 1.23456789e2);
769+
Test(" 1.2346e+003", "%12.4e", 1.23456789e3);
770+
Test(" 1.2346e+004", "%12.4e", 1.23456789e4);
771+
Test(" 1.2346e+005", "%12.4e", 1.23456789e5);
772+
Test(" 1.2346e+006", "%12.4e", 1.23456789e6);
773+
Test(" 1.2346e+007", "%12.4e", 1.23456789e7);
774+
Test(" 1.2346e+008", "%12.4e", 1.23456789e8);
775+
Test(" 1.2346e+009", "%12.4e", 1.23456789e9);
776+
Test(" 1.2346e+010", "%12.4e", 1.23456789e10);
777+
Test(" 1.2346e-001", "%12.4e", 1.23456789e-1);
778+
Test(" 1.2346e-002", "%12.4e", 1.23456789e-2);
779+
Test(" 1.2346e-003", "%12.4e", 1.23456789e-3);
780+
Test(" 1.2346e-004", "%12.4e", 1.23456789e-4);
781+
Test(" 1.2346e-005", "%12.4e", 1.23456789e-5);
782+
Test(" 1.2346e-006", "%12.4e", 1.23456789e-6);
783+
Test(" 1.2346e-007", "%12.4e", 1.23456789e-7);
784+
Test(" 1.2346e-008", "%12.4e", 1.23456789e-8);
785+
Test(" 1.2346e-009", "%12.4e", 1.23456789e-9);
786+
Test(" 1.2346e-010", "%12.4e", 1.23456789e-10);
788787

789788
Test("1.2346e+000 ", "%-12.4e", 1.23456789e0);
790789
Test("1.2346e+001 ", "%-12.4e", 1.23456789e1);
@@ -1075,7 +1074,7 @@ public void TextSpecBasics()
10751074
[Test]
10761075
public void DateTimeBasics()
10771076
{
1078-
Test("01","%tH", new DateTime(2009, 7, 1, 1, 10, 20));
1077+
Test("01", "%tH", new DateTime(2009, 7, 1, 1, 10, 20));
10791078
Test("14", "%tH", new DateTime(2009, 7, 1, 14, 10, 20));
10801079
Test("01", "%tI", new DateTime(2009, 7, 1, 1, 10, 20));
10811080
Test("02", "%tI", new DateTime(2009, 7, 1, 14, 10, 20));
@@ -1146,7 +1145,7 @@ public void DateTimeBasics()
11461145
[Test]
11471146
public void DateTimeOffsetBasics()
11481147
{
1149-
Test("-05:12", "%tz", new DateTimeOffset(2009, 7, 1, 1, 10, 20,new TimeSpan(-5,-12,0)));
1148+
Test("-05:12", "%tz", new DateTimeOffset(2009, 7, 1, 1, 10, 20, new TimeSpan(-5, -12, 0)));
11501149
Test("+05:12", "%tz", new DateTimeOffset(2009, 7, 1, 1, 10, 20, new TimeSpan(5, 12, 0)));
11511150
Test("", "%tZ", new DateTimeOffset(2009, 7, 1, 1, 10, 20, new TimeSpan(-5, 12, 0)));
11521151
}

Clojure/Csharp.Tests/TypeNameTests2/TypeNameResolvingTests2.cs

Lines changed: 31 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -122,33 +122,33 @@ public void NamespaceQualifiedClassName_ParsesCorrectly(string typename, Type ex
122122
}
123123

124124

125-
[TestCase("int", typeof(int))]
126-
[TestCase("long", typeof(long))]
127-
[TestCase("float", typeof(float))]
128-
[TestCase("double", typeof(double))]
129-
[TestCase("bool", typeof(bool))]
130-
[TestCase("char", typeof(char))]
131-
[TestCase("byte", typeof(byte))]
132-
[TestCase("uint", typeof(uint))]
133-
[TestCase("ulong", typeof(ulong))]
134-
[TestCase("ushort", typeof(ushort))]
135-
[TestCase("sbyte", typeof(sbyte))]
136-
[TestCase("ints", typeof(int[]))]
137-
[TestCase("longs", typeof(long[]))]
138-
[TestCase("floats", typeof(float[]))]
139-
[TestCase("doubles", typeof(double[]))]
140-
[TestCase("bools", typeof(bool[]))]
141-
[TestCase("chars", typeof(char[]))]
142-
[TestCase("bytes", typeof(byte[]))]
143-
[TestCase("uints", typeof(uint[]))]
144-
[TestCase("ulongs", typeof(ulong[]))]
145-
[TestCase("ushorts", typeof(ushort[]))]
146-
[TestCase("sbytes", typeof(sbyte[]))]
147-
public void ClojureSimplelias_ParsesCorrectly(string typename, Type expectedType)
148-
{
149-
Assert.That(Resolve(typename), Is.EqualTo(expectedType));
150-
151-
}
125+
//[TestCase("int", typeof(int))] -- we no longer allow special type names at the top level
126+
//[TestCase("long", typeof(long))]
127+
//[TestCase("float", typeof(float))]
128+
//[TestCase("double", typeof(double))]
129+
//[TestCase("bool", typeof(bool))]
130+
//[TestCase("char", typeof(char))]
131+
//[TestCase("byte", typeof(byte))]
132+
//[TestCase("uint", typeof(uint))]
133+
//[TestCase("ulong", typeof(ulong))]
134+
//[TestCase("ushort", typeof(ushort))]
135+
//[TestCase("sbyte", typeof(sbyte))]
136+
//[TestCase("ints", typeof(int[]))]
137+
//[TestCase("longs", typeof(long[]))]
138+
//[TestCase("floats", typeof(float[]))]
139+
//[TestCase("doubles", typeof(double[]))]
140+
//[TestCase("bools", typeof(bool[]))]
141+
//[TestCase("chars", typeof(char[]))]
142+
//[TestCase("bytes", typeof(byte[]))]
143+
//[TestCase("uints", typeof(uint[]))]
144+
//[TestCase("ulongs", typeof(ulong[]))]
145+
//[TestCase("ushorts", typeof(ushort[]))]
146+
//[TestCase("sbytes", typeof(sbyte[]))]
147+
//public void ClojureSimplelias_ParsesCorrectly(string typename, Type expectedType)
148+
//{
149+
// Assert.That(Resolve(typename), Is.EqualTo(expectedType));
150+
151+
//}
152152

153153
[TestCase("TSimple", typeof(Simple))]
154154
[TestCase("TOneG", typeof(OneG<>))]
@@ -161,7 +161,7 @@ public void AliasedTypename_ParsesCorrectly(string typename, Type expectedType)
161161
Assert.That(Resolve(typename), Is.EqualTo(expectedType));
162162
}
163163

164-
[TestCase("int[]", typeof(int[]))]
164+
//[TestCase("int[]", typeof(int[]))] -- we no longer allow special type names at the top level
165165
[TestCase("String[]", typeof(string[]))]
166166
[TestCase("TSimple[]", typeof(Simple[]))]
167167
[TestCase("Csharp.Tests.TypeNameTests2.Simple[]", typeof(Simple[]))]
@@ -170,7 +170,7 @@ public void ArrayType_ParsesCorrectly(string typename, Type expectedType)
170170
Assert.That(Resolve(typename), Is.EqualTo(expectedType));
171171
}
172172

173-
[TestCase("int*", typeof(int))]
173+
//[TestCase("int*", typeof(int))] -- we no longer allow special type names at the top level
174174
[TestCase("String*", typeof(String))]
175175
[TestCase("TSimple*", typeof(Simple))]
176176
[TestCase("Csharp.Tests.TypeNameTests2.Simple*", typeof(Simple))]
@@ -180,7 +180,7 @@ public void PointerType_ParsesCorrectly(string typename, Type expectedType)
180180
}
181181

182182

183-
[TestCase("int**", typeof(int))]
183+
// [TestCase("int**", typeof(int))] -- we no longer allow special type names at the top level
184184
[TestCase("String**", typeof(String))]
185185
[TestCase("TSimple**", typeof(Simple))]
186186
[TestCase("Csharp.Tests.TypeNameTests2.Simple**", typeof(Simple))]
@@ -190,7 +190,7 @@ public void DoublePointerType_ParsesCorrectly(string typename, Type expectedType
190190
}
191191

192192

193-
[TestCase("int&", typeof(int))]
193+
// [TestCase("int&", typeof(int))] -- we no longer allow special type names at the top level
194194
[TestCase("String&", typeof(String))]
195195
[TestCase("TSimple&", typeof(Simple))]
196196
[TestCase("Csharp.Tests.TypeNameTests2.Simple&", typeof(Simple))]

Clojure/dotnet-tools.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"version": 1,
3+
"isRoot": true,
4+
"tools": {}
5+
}

0 commit comments

Comments
 (0)