projects
/
mono.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Merge pull request #1051 from josedonizetti/bug11916-DataContractSerializer
[mono.git]
/
mono
/
tests
/
synchronized.cs
diff --git
a/mono/tests/synchronized.cs
b/mono/tests/synchronized.cs
index 58eda9a209ef36fe813fce6392778fefb2db047b..86ea9a8f02ca45379eba52cd523dbf8c7ce8cf3c 100644
(file)
--- a/
mono/tests/synchronized.cs
+++ b/
mono/tests/synchronized.cs
@@
-8,19
+8,20
@@
using System;
using System.Threading;
using System.Runtime.CompilerServices;
using System.Threading;
using System.Runtime.CompilerServices;
-class Test {
+class Tests {
+
+ // We use Monitor.Pulse to test that the object is synchronized
[MethodImplAttribute(MethodImplOptions.Synchronized)]
public int test () {
[MethodImplAttribute(MethodImplOptions.Synchronized)]
public int test () {
- Monitor.
Exit
(this);
- Monitor.Enter (this);
+ Monitor.
Pulse
(this);
+
//
Monitor.Enter (this);
return 2 + 2;
}
[MethodImplAttribute(MethodImplOptions.Synchronized)]
public static int test_static () {
return 2 + 2;
}
[MethodImplAttribute(MethodImplOptions.Synchronized)]
public static int test_static () {
- Monitor.Exit (typeof (Test));
- Monitor.Enter (typeof (Test));
+ Monitor.Pulse (typeof (Tests));
return 2 + 2;
}
return 2 + 2;
}
@@
-32,21
+33,36
@@
class Test {
[MethodImplAttribute(MethodImplOptions.Synchronized)]
public virtual int test_virtual () {
[MethodImplAttribute(MethodImplOptions.Synchronized)]
public virtual int test_virtual () {
- Monitor.Exit (this);
- Monitor.Enter (this);
+ Monitor.Pulse (this);
return 2 + 2;
}
return 2 + 2;
}
+ public static bool is_synchronized (object o) {
+ try {
+ Monitor.Pulse (o);
+ }
+ catch (SynchronizationLockException ex) {
+ return false;
+ }
+ return true;
+ }
+
public delegate int Delegate1 ();
static public int Main (String[] args) {
public delegate int Delegate1 ();
static public int Main (String[] args) {
- Test
b = new Test
();
- int res;
+ Test
s b = new Tests
();
+ int res
, err
;
Console.WriteLine ("Test1...");
b.test ();
Console.WriteLine ("Test1...");
b.test ();
+ if (is_synchronized (b))
+ return 1;
+
Console.WriteLine ("Test2...");
test_static ();
Console.WriteLine ("Test2...");
test_static ();
+ if (is_synchronized (typeof (Tests)))
+ return 1;
+
Console.WriteLine ("Test3...");
try {
b.test_exception ();
Console.WriteLine ("Test3...");
try {
b.test_exception ();
@@
-57,21
+73,31
@@
class Test {
catch (Exception ex) {
// OK
}
catch (Exception ex) {
// OK
}
+ if (is_synchronized (b))
+ return 1;
Console.WriteLine ("Test4...");
b.test_virtual ();
Console.WriteLine ("Test4...");
b.test_virtual ();
+ if (is_synchronized (b))
+ return 1;
Console.WriteLine ("Test5...");
Delegate1 d = new Delegate1 (b.test);
res = d ();
Console.WriteLine ("Test5...");
Delegate1 d = new Delegate1 (b.test);
res = d ();
+ if (is_synchronized (b))
+ return 1;
Console.WriteLine ("Test6...");
d = new Delegate1 (test_static);
res = d ();
Console.WriteLine ("Test6...");
d = new Delegate1 (test_static);
res = d ();
+ if (is_synchronized (typeof (Tests)))
+ return 1;
Console.WriteLine ("Test7...");
d = new Delegate1 (b.test_virtual);
res = d ();
Console.WriteLine ("Test7...");
d = new Delegate1 (b.test_virtual);
res = d ();
+ if (is_synchronized (b))
+ return 1;
Console.WriteLine ("Test8...");
d = new Delegate1 (b.test_exception);
Console.WriteLine ("Test8...");
d = new Delegate1 (b.test_exception);
@@
-84,6
+110,8
@@
class Test {
catch (Exception ex) {
// OK
}
catch (Exception ex) {
// OK
}
+ if (is_synchronized (b))
+ return 1;
return 0;
}
return 0;
}