mirror of
https://github.com/twiglet/cs2j.git
synced 2025-01-18 13:15:17 +01:00
add tests for lock() and accessing parents from parent namespaces
This commit is contained in:
parent
f6e7958041
commit
3528e2223e
22
CSharpTranslator/tests/Tester/Misc/Namespaces/child.cs
Executable file
22
CSharpTranslator/tests/Tester/Misc/Namespaces/child.cs
Executable file
@ -0,0 +1,22 @@
|
|||||||
|
using System;
|
||||||
|
|
||||||
|
// Test translation for lock statements
|
||||||
|
|
||||||
|
namespace Tester.Parent.Child
|
||||||
|
{
|
||||||
|
|
||||||
|
public class ChildClass
|
||||||
|
{
|
||||||
|
|
||||||
|
private ParentClass myp = null;
|
||||||
|
|
||||||
|
|
||||||
|
public ChildClass(int val)
|
||||||
|
{
|
||||||
|
myp = new ParentClass(val);
|
||||||
|
int tmp = myp.GetHashCode();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
41
CSharpTranslator/tests/Tester/Misc/Namespaces/parent.cs
Executable file
41
CSharpTranslator/tests/Tester/Misc/Namespaces/parent.cs
Executable file
@ -0,0 +1,41 @@
|
|||||||
|
using System;
|
||||||
|
|
||||||
|
// Test translation for lock statements
|
||||||
|
|
||||||
|
namespace Tester.Parent
|
||||||
|
{
|
||||||
|
|
||||||
|
public class ParentClass {
|
||||||
|
|
||||||
|
private int loc = 0;
|
||||||
|
|
||||||
|
|
||||||
|
public ParentClass(int val)
|
||||||
|
{
|
||||||
|
loc = val;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int GetLoc()
|
||||||
|
{
|
||||||
|
return loc;
|
||||||
|
}
|
||||||
|
|
||||||
|
public override int GetHashCode(){
|
||||||
|
return 5;
|
||||||
|
}
|
||||||
|
|
||||||
|
private class ChildOne {
|
||||||
|
public int COloc = 0;
|
||||||
|
private class ChildChildOne
|
||||||
|
{
|
||||||
|
public ChildChildOne() { }
|
||||||
|
|
||||||
|
public ChildOne p = new ChildOne();
|
||||||
|
public ParentClass gp = new ParentClass(4);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
31
CSharpTranslator/tests/Tester/Misc/locker.cs
Executable file
31
CSharpTranslator/tests/Tester/Misc/locker.cs
Executable file
@ -0,0 +1,31 @@
|
|||||||
|
using System;
|
||||||
|
|
||||||
|
// Test translation for lock statements
|
||||||
|
|
||||||
|
namespace Tester.Locker
|
||||||
|
{
|
||||||
|
class B {
|
||||||
|
public virtual void foo() {
|
||||||
|
lock(this)
|
||||||
|
Console.WriteLine("summat");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
class D : B {
|
||||||
|
public new void foo() {
|
||||||
|
lock (new String[5])
|
||||||
|
{
|
||||||
|
Console.WriteLine("and");
|
||||||
|
Console.WriteLine("nuttin");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public class Test5 {
|
||||||
|
public static void T5Main(){
|
||||||
|
B b = new D();
|
||||||
|
b.foo();
|
||||||
|
Console.WriteLine("Done");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -1,4 +1,4 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||||
@ -45,6 +45,9 @@
|
|||||||
<Compile Include="Enums\PacketTester.cs" />
|
<Compile Include="Enums\PacketTester.cs" />
|
||||||
<Compile Include="Enums\Consts.cs" />
|
<Compile Include="Enums\Consts.cs" />
|
||||||
<Compile Include="Generics\Generics.cs" />
|
<Compile Include="Generics\Generics.cs" />
|
||||||
|
<Compile Include="Misc\locker.cs" />
|
||||||
|
<Compile Include="Misc\Namespaces\child.cs" />
|
||||||
|
<Compile Include="Misc\Namespaces\parent.cs" />
|
||||||
<Compile Include="Partial\PartialUserTwo.cs" />
|
<Compile Include="Partial\PartialUserTwo.cs" />
|
||||||
<Compile Include="Partial\PartialInner.cs" />
|
<Compile Include="Partial\PartialInner.cs" />
|
||||||
<Compile Include="Partial\PartialOuterPartialInner.cs" />
|
<Compile Include="Partial\PartialOuterPartialInner.cs" />
|
||||||
|
Loading…
x
Reference in New Issue
Block a user