Skip to content

Commit

Permalink
[corlib] Fix a test. It was broken in so many ways, but hidden behind…
Browse files Browse the repository at this point in the history
… a check that disabled it everywhere. :(
  • Loading branch information
kumpera committed Sep 3, 2015
1 parent 1840c4a commit 8b33f3a
Showing 1 changed file with 6 additions and 8 deletions.
14 changes: 6 additions & 8 deletions mcs/class/corlib/Test/System.Globalization/CultureInfoTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -625,7 +625,7 @@ public void ChineseSimplifiedDontEqual ()

#if NET_4_5
CountdownEvent barrier = new CountdownEvent (3);
AutoResetEvent[] evt = new AutoResetEvent [] { new AutoResetEvent (false), new AutoResetEvent (false), new AutoResetEvent (false)};
AutoResetEvent[] evt = new AutoResetEvent [] { new AutoResetEvent (false), new AutoResetEvent (false), new AutoResetEvent (false), new AutoResetEvent (false)};

CultureInfo[] initial_culture = new CultureInfo[4];
CultureInfo[] changed_culture = new CultureInfo[4];
Expand Down Expand Up @@ -668,13 +668,10 @@ void ThreadPoolWithoutChange () {

[Test]
public void DefaultThreadCurrentCulture () {
Console.WriteLine ("HELLO");
var orig_culture = CultureInfo.CurrentCulture;
var new_culture = new CultureInfo("fr-FR");

// The test doesn't work if the current culture is already set
if (orig_culture != CultureInfo.InvariantCulture)
Assert.Ignore ("The test doesn't work if the current culture is already set.");

/* Phase 0 - warm up */
new Thread (ThreadWithoutChange).Start ();
new Thread (ThreadWithChange).Start ();
Expand All @@ -688,19 +685,20 @@ public void DefaultThreadCurrentCulture () {

/* Phase 2 - change the default culture*/
CultureInfo.DefaultThreadCurrentCulture = new_culture;
evt [0].Set ();
evt [1].Set ();
evt [2].Set ();
evt [3].Set ();

/* Phase 3 - let everyone witness the new value */
changed_culture [0] = CultureInfo.CurrentCulture;
barrier.Wait ();
barrier.Reset ();

/* Phase 4 - revert the default culture back to null */
CultureInfo.DefaultThreadCurrentCulture = null;
evt [0].Set ();
evt [1].Set ();
evt [2].Set ();
evt [3].Set ();

/* Phase 5 - let everyone witness the new value */
changed_culture2 [0] = CultureInfo.CurrentCulture;
Expand All @@ -719,7 +717,7 @@ public void DefaultThreadCurrentCulture () {
Assert.AreEqual (alternative_culture, changed_culture [2], "#7");
Assert.AreEqual (new_culture, changed_culture [3], "#8");

Assert.AreEqual (orig_culture, changed_culture [0], "#9");
Assert.AreEqual (orig_culture, changed_culture2 [0], "#9");
Assert.AreEqual (orig_culture, changed_culture2 [1], "#10");
Assert.AreEqual (alternative_culture, changed_culture2 [2], "#11");
Assert.AreEqual (orig_culture, changed_culture2 [3], "#12");
Expand Down

2 comments on commit 8b33f3a

@vargaz
Copy link
Contributor

@vargaz vargaz commented on 8b33f3a Sep 4, 2015

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@kumpera
Copy link
Contributor Author

@kumpera kumpera commented on 8b33f3a Sep 4, 2015

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Damn, it worked for me earlier.

Please sign in to comment.