Skip to content
This repository was archived by the owner on Jan 23, 2023. It is now read-only.

Commit 8c32027

Browse files
committed
Fix System.Reflection.Emit.ILGeneration tests to use non-static RNG
1 parent 5a9af69 commit 8c32027

File tree

7 files changed

+98
-315
lines changed

7 files changed

+98
-315
lines changed

src/System.Reflection.Emit.ILGeneration/tests/CustomAttributeBuilder/CustomAttributeBuilderCtor1.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ namespace System.Reflection.Emit.ILGeneration.Tests
1111
{
1212
public class CustomAttributeBuilderCtor1
1313
{
14+
private readonly RandomDataGenerator _generator = new RandomDataGenerator();
15+
1416
[Fact]
1517
public void PosTest1()
1618
{
@@ -39,7 +41,7 @@ public void PosTest2()
3941
public void PosTest3()
4042
{
4143
string str = "PosTest3";
42-
bool b = TestLibrary.Generator.GetByte() > byte.MaxValue / 2;
44+
bool b = _generator.GetByte() > byte.MaxValue / 2;
4345

4446
Type[] ctorParams = new Type[] { typeof(string), typeof(bool) };
4547
object[] paramValues = new object[] { str, b };

src/System.Reflection.Emit.ILGeneration/tests/CustomAttributeBuilder/CustomAttributeBuilderCtor2.cs

Lines changed: 28 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,7 @@ public class CustomAttributeBuilderCtor2
8282
private const string FieldGetOnlyIntName = "GetInt";
8383
private const string DefaultNotExistFieldName = "DOESNOTEXIST";
8484
private const BindingFlags FieldBindingFlag = BindingFlags.Public | BindingFlags.Instance | BindingFlags.NonPublic;
85+
private readonly RandomDataGenerator _generator = new RandomDataGenerator();
8586

8687
[Fact]
8788
public void PosTest1()
@@ -91,8 +92,8 @@ public void PosTest1()
9192
int testInt2 = 0;
9293

9394
str1 = "PosTest1_Arg";
94-
testInt1 = TestLibrary.Generator.GetInt32();
95-
testInt2 = TestLibrary.Generator.GetInt32();
95+
testInt1 = _generator.GetInt32();
96+
testInt2 = _generator.GetInt32();
9697

9798
Type CustomAttributeBuilderTestType = typeof(CustomAttributeBuilderTest);
9899

@@ -148,8 +149,8 @@ public void PosTest2()
148149
int testInt2 = 0;
149150

150151
str1 = "PosTest2_STR1";
151-
testInt1 = TestLibrary.Generator.GetInt32();
152-
testInt2 = TestLibrary.Generator.GetInt32();
152+
testInt1 = _generator.GetInt32();
153+
testInt2 = _generator.GetInt32();
153154

154155
Type CustomAttributeBuilderTestType = typeof(CustomAttributeBuilderTest);
155156

@@ -245,7 +246,7 @@ public void PosTest4()
245246
int testInt = 0;
246247

247248
Type CustomAttributeBuilderTestType = typeof(CustomAttributeBuilderTest);
248-
testInt = TestLibrary.Generator.GetInt32();
249+
testInt = _generator.GetInt32();
249250

250251
Type[] ctorParams = new Type[]
251252
{
@@ -296,7 +297,7 @@ public void PosTest5()
296297
string testString = null;
297298

298299
Type CustomAttributeBuilderTestType = typeof(CustomAttributeBuilderTest);
299-
testInt = TestLibrary.Generator.GetInt32();
300+
testInt = _generator.GetInt32();
300301
testString = "PosTest5_TestString";
301302

302303
Type[] ctorParams = new Type[]
@@ -351,8 +352,8 @@ public void PosTest6()
351352

352353
testString1 = "PosTest6_TestString1";
353354
testString2 = "PostTest6_TestString2";
354-
testInt1 = TestLibrary.Generator.GetInt32();
355-
testInt2 = TestLibrary.Generator.GetInt32();
355+
testInt1 = _generator.GetInt32();
356+
testInt2 = _generator.GetInt32();
356357

357358
Type CustomAttributeBuilderTestType = typeof(CustomAttributeBuilderTest);
358359

@@ -487,8 +488,8 @@ public void NegTest2()
487488
Type CustomAttributeBuilderTestType = typeof(CustomAttributeBuilderTest);
488489

489490
testString =
490-
TestLibrary.Generator.GetString(false, MinStringLength, MaxStringLength);
491-
testInt = TestLibrary.Generator.GetInt32();
491+
_generator.GetString(false, MinStringLength, MaxStringLength);
492+
testInt = _generator.GetInt32();
492493

493494
Type[] ctorParams = new Type[]
494495
{
@@ -566,8 +567,8 @@ public void NegTest5()
566567
int testInt1 = 0;
567568

568569
testString1 =
569-
TestLibrary.Generator.GetString(false, MinStringLength, MaxStringLength);
570-
testInt1 = TestLibrary.Generator.GetInt32();
570+
_generator.GetString(false, MinStringLength, MaxStringLength);
571+
testInt1 = _generator.GetInt32();
571572

572573
Type CustomAttributeBuilderTestType = typeof(CustomAttributeBuilderTest);
573574

@@ -606,8 +607,8 @@ public void NegTest6()
606607
string testString1 = null;
607608
int testInt1 = 0;
608609
testString1 =
609-
TestLibrary.Generator.GetString(false, MinStringLength, MaxStringLength);
610-
testInt1 = TestLibrary.Generator.GetInt32();
610+
_generator.GetString(false, MinStringLength, MaxStringLength);
611+
testInt1 = _generator.GetInt32();
611612

612613
Type CustomAttributeBuilderTestType = typeof(CustomAttributeBuilderTest);
613614

@@ -645,8 +646,8 @@ public void NegTest7()
645646
int testInt1 = 0;
646647

647648
testString1 =
648-
TestLibrary.Generator.GetString(false, MinStringLength, MaxStringLength);
649-
testInt1 = TestLibrary.Generator.GetInt32();
649+
_generator.GetString(false, MinStringLength, MaxStringLength);
650+
testInt1 = _generator.GetInt32();
650651

651652
Type CustomAttributeBuilderTestType = typeof(CustomAttributeBuilderTest);
652653

@@ -683,7 +684,7 @@ public void NegTest8()
683684
string testString1 = null;
684685

685686
testString1 =
686-
TestLibrary.Generator.GetString(false, MinStringLength, MaxStringLength);
687+
_generator.GetString(false, MinStringLength, MaxStringLength);
687688

688689
Type CustomAttributeBuilderTestType = typeof(CustomAttributeBuilderTest);
689690

@@ -718,7 +719,7 @@ public void NegTest9()
718719
string testString1 = null;
719720

720721
testString1 =
721-
TestLibrary.Generator.GetString(false, MinStringLength, MaxStringLength);
722+
_generator.GetString(false, MinStringLength, MaxStringLength);
722723

723724
Type CustomAttributeBuilderTestType = typeof(CustomAttributeBuilderTest);
724725

@@ -750,7 +751,7 @@ public void NegTest10()
750751
string testString1 = null;
751752

752753
testString1 =
753-
TestLibrary.Generator.GetString(false, MinStringLength, MaxStringLength);
754+
_generator.GetString(false, MinStringLength, MaxStringLength);
754755

755756
Type CustomAttributeBuilderTestType = typeof(CustomAttributeBuilderTest);
756757

@@ -782,7 +783,7 @@ public void NegTest11()
782783
string testString1 = null;
783784

784785
testString1 =
785-
TestLibrary.Generator.GetString(false, MinStringLength, MaxStringLength);
786+
_generator.GetString(false, MinStringLength, MaxStringLength);
786787

787788
Type CustomAttributeBuilderTestType = typeof(CustomAttributeBuilderTest);
788789

@@ -813,7 +814,7 @@ public void NegTest12()
813814
string testString1 = null;
814815

815816
testString1 =
816-
TestLibrary.Generator.GetString(false, MinStringLength, MaxStringLength);
817+
_generator.GetString(false, MinStringLength, MaxStringLength);
817818

818819
Type CustomAttributeBuilderTestType = typeof(CustomAttributeBuilderTest);
819820

@@ -845,8 +846,8 @@ public void NegTest13()
845846
int testInt = 0;
846847

847848
testString =
848-
TestLibrary.Generator.GetString(false, MinStringLength, MaxStringLength);
849-
testInt = TestLibrary.Generator.GetInt32();
849+
_generator.GetString(false, MinStringLength, MaxStringLength);
850+
testInt = _generator.GetInt32();
850851

851852
Type CustomAttributeBuilderTestType = typeof(CustomAttributeBuilderTest);
852853

@@ -888,8 +889,8 @@ public void NegTest14()
888889
string testString = null;
889890

890891
testString =
891-
TestLibrary.Generator.GetString(false, MinStringLength, MaxStringLength);
892-
testInt = TestLibrary.Generator.GetInt32();
892+
_generator.GetString(false, MinStringLength, MaxStringLength);
893+
testInt = _generator.GetInt32();
893894

894895
Type CustomAttributeBuilderTestType = typeof(CustomAttributeBuilderTest);
895896

@@ -931,8 +932,8 @@ public void NegTest15()
931932
int testInt = 0;
932933

933934
testString =
934-
TestLibrary.Generator.GetString(false, MinStringLength, MaxStringLength);
935-
testInt = TestLibrary.Generator.GetInt32();
935+
_generator.GetString(false, MinStringLength, MaxStringLength);
936+
testInt = _generator.GetInt32();
936937

937938
Type CustomAttributeBuilderTestType = typeof(CustomAttributeBuilderTest);
938939

0 commit comments

Comments
 (0)