Browse Source

[cs] Starting to add unit tests to net-lib

Cauê Waneck 11 years ago
parent
commit
f4825bc881

+ 3 - 0
.gitignore

@@ -45,6 +45,9 @@
 /tests/unit/native_java/obj
 /tests/unit/native_java/cmd
 /tests/unit/native_java/native.jar
+/tests/unit/native_cs/obj
+/tests/unit/native_cs/cmd
+/tests/unit/native_cs/bin
 /tests/unit/unit.js.map
 /tests/unit/unit.n
 

+ 6 - 0
tests/unit/compile-cs-unsafe.hxml

@@ -1,4 +1,10 @@
+#cs native build
+-cmd "haxelib run hxcs native_cs/hxcs_build.txt"
+
+--next
+
 compile-each.hxml
 -main unit.Test
 -D unsafe
 -cs cs_unsafe
+-net-lib native_cs/bin/native_cs.dll

+ 6 - 0
tests/unit/compile-cs.hxml

@@ -1,3 +1,9 @@
+#cs native build
+-cmd "haxelib run hxcs native_cs/hxcs_build.txt"
+
+--next
+
 compile-each.hxml
 -main unit.Test
 -cs cs
+-net-lib native_cs/bin/native_cs.dll

BIN
tests/unit/native_cs/.hxjava_build.txt.swo


+ 22 - 0
tests/unit/native_cs/hxcs_build.txt

@@ -0,0 +1,22 @@
+./
+begin modules
+M haxe.test.OverloadInterface1
+C haxe.test.OverloadInterface1
+M haxe.test.OverloadInterface2
+C haxe.test.OverloadInterface2
+M haxe.test.MyClass
+C haxe.test.MyClass
+M haxe.test.TEnum
+E haxe.test.TEnum
+M haxe.test.Base
+C haxe.test.Base
+M haxe.test.Generic1
+C haxe.test.Generic1
+M haxe.test.GenericHelper
+C haxe.test.GenericHelper
+M haxe.test.StaticAndInstanceClash
+C haxe.test.StaticAndInstanceClash
+end modules
+begin defines
+dll
+end defines

+ 82 - 0
tests/unit/native_cs/native_cs.csproj

@@ -0,0 +1,82 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+  <PropertyGroup>
+    <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+    <Platform Condition=" '$(Platform)' == '' ">x86</Platform>
+    <OutputType>Dll</OutputType>
+    <AppDesignerFolder>Properties</AppDesignerFolder>
+    <RootNamespace></RootNamespace>
+    <AssemblyName>native_cs</AssemblyName>
+    <TargetFrameworkVersion>v3.5</TargetFrameworkVersion>
+    <TargetFrameworkProfile>Client</TargetFrameworkProfile>
+    <FileAlignment>512</FileAlignment>
+	
+  </PropertyGroup>
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x86' ">
+    <PlatformTarget>x86</PlatformTarget>
+    <DebugSymbols>true</DebugSymbols>
+    <DebugType>full</DebugType>
+    <Optimize>false</Optimize>
+    <OutputPath>bin\Debug\</OutputPath>
+    <DefineConstants>DEBUG;TRACE</DefineConstants>
+    <ErrorReport>prompt</ErrorReport>
+    <WarningLevel>4</WarningLevel>
+  </PropertyGroup>
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|x86' ">
+    <PlatformTarget>x86</PlatformTarget>
+    <DebugType>pdbonly</DebugType>
+    <Optimize>true</Optimize>
+    <OutputPath>bin\Release\</OutputPath>
+    <DefineConstants>TRACE</DefineConstants>
+    <ErrorReport>prompt</ErrorReport>
+    <WarningLevel>4</WarningLevel>
+  </PropertyGroup>
+  <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x64'">
+    <DebugSymbols>true</DebugSymbols>
+    <OutputPath>bin\x64\Debug\</OutputPath>
+    <DefineConstants>DEBUG;TRACE</DefineConstants>
+    <DebugType>full</DebugType>
+    <PlatformTarget>x64</PlatformTarget>
+    <ErrorReport>prompt</ErrorReport>
+  </PropertyGroup>
+  <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x64'">
+    <OutputPath>bin\x64\Release\</OutputPath>
+    <DefineConstants>TRACE</DefineConstants>
+    <Optimize>true</Optimize>
+    <DebugType>pdbonly</DebugType>
+    <PlatformTarget>x64</PlatformTarget>
+    <ErrorReport>prompt</ErrorReport>
+  </PropertyGroup>
+  <ItemGroup>
+  
+  </ItemGroup>
+  <ItemGroup>
+	
+    <Compile Include="src\haxe\test\OverloadInterface1.cs"/>
+	
+    <Compile Include="src\haxe\test\OverloadInterface2.cs"/>
+	
+    <Compile Include="src\haxe\test\MyClass.cs"/>
+	
+    <Compile Include="src\haxe\test\TEnum.cs"/>
+	
+    <Compile Include="src\haxe\test\Base.cs"/>
+	
+    <Compile Include="src\haxe\test\Generic1.cs"/>
+	
+    <Compile Include="src\haxe\test\GenericHelper.cs"/>
+	
+    <Compile Include="src\haxe\test\StaticAndInstanceClash.cs"/>
+	
+  </ItemGroup>
+  
+  <ItemGroup />
+  <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
+  <!-- To modify your build process, add your task inside one of the targets below and uncomment it. 
+       Other similar extension points exist, see Microsoft.Common.targets.
+  <Target Name="BeforeBuild">
+  </Target>
+  <Target Name="AfterBuild">
+  </Target>
+  -->
+</Project>

+ 105 - 0
tests/unit/native_cs/src/haxe/test/Base.cs

@@ -0,0 +1,105 @@
+namespace haxe.test
+{
+
+public class Base
+{
+	//some haxe-specific keywords
+
+	const int inline = 42;
+	public static readonly int callback = 43;
+	public static readonly int cast = 44;
+	public static readonly int untyped = 45;
+
+	//final + static variable = inline var in Haxe
+	const int inlineNumber = 42;
+
+	//cannot be inline
+	public static int notInlineNumber = 42;
+
+	public string someString;
+	private string privateField;
+	protected int protectedField;
+
+	//static + nonstatic clash
+	public static int nameClash(Base t)
+	{
+		return -1;
+	}
+
+	public int nameClash()
+	{
+		return 1;
+	}
+
+	protected int protectedFunction()
+	{
+		return protectedField;
+	}
+
+	public int varNameClash(int b)
+	{
+		return b;
+	}
+
+	public static double varNameClash(double d)
+	{
+		return d;
+	}
+	
+	public static char charTest(char c)
+	{
+		return c;
+	}
+
+	public static byte byteTest(byte b)
+	{
+		return b;
+	}
+
+	public class InnerClass : Base
+	{
+		private int privateField = 42;
+
+		//protected override without explicit override tag
+		protected int protectedFunction()
+		{
+			return privateField;
+		}
+
+		public int nameClash()
+		{
+			return 10;
+		}
+
+		public static int getValue(OverloadInterface2 oiface)
+		{
+			return oiface.someOverloadedMethod(42);
+		}
+
+		public class InnerInnerClass : InnerClass2
+		{
+
+
+			//protected override without explicit override tag
+			protected int protectedFunction()
+			{
+				return 10;
+			}
+		}
+	}
+
+	public class InnerClass2 : InnerClass, OverloadInterface1, OverloadInterface2
+	{
+		public void someOverloadedMethod(string a1)
+		{
+
+		}
+
+		public int someOverloadedMethod(int a1)
+		{
+			return a1;
+		}
+	}
+}
+
+}

+ 39 - 0
tests/unit/native_cs/src/haxe/test/Generic1.cs

@@ -0,0 +1,39 @@
+namespace haxe.test
+{
+
+public class Generic1<T> where T : Base
+{
+	public T value;
+
+	public Generic1()
+	{
+
+	}
+
+	public Generic1(T value)
+	{
+		this.value = value;
+	}
+
+	public void setValue(T v)
+	{
+		this.value = v;
+	}
+
+	public T getValue()
+	{
+		return value;
+	}
+
+	public string getSomeString()
+	{
+		return value.someString;
+	}
+
+	public string complexTypeParameterOfTypeParameter<B2>(B2 b) where B2 : T
+	{
+		return b.someString + value.someString;
+	}
+}
+
+}

+ 14 - 0
tests/unit/native_cs/src/haxe/test/GenericHelper.cs

@@ -0,0 +1,14 @@
+namespace haxe.test
+{
+
+public class GenericHelper
+{
+	public Generic1<Base.InnerClass> typedGeneric;
+
+	public static Generic1<X> staticTypedGeneric<X>(System.Type cl) where X : Base.InnerClass
+	{
+		return new Generic1<X>();
+	}
+}
+
+}

+ 47 - 0
tests/unit/native_cs/src/haxe/test/MyClass.cs

@@ -0,0 +1,47 @@
+namespace haxe.test
+{
+
+public class MyClass
+{
+	public void normalOverload(string a)
+	{
+
+	}
+
+	public void normalOverload(int a)
+	{
+
+	}
+
+	public void normalOverload(bool a)
+	{
+
+	}
+
+	public void normalOverload(object a)
+	{
+
+	}
+
+	public void normalOverload(long a)
+	{
+
+	}
+
+	public void normalOverload(float a)
+	{
+
+	}
+
+	public void normalOverload(double a)
+	{
+
+	}
+
+	public void normalOverload(Base a)
+	{
+		
+	}
+}
+
+}

+ 9 - 0
tests/unit/native_cs/src/haxe/test/OverloadInterface1.cs

@@ -0,0 +1,9 @@
+namespace haxe.test
+{
+
+public interface OverloadInterface1
+{
+	void someOverloadedMethod(string a1);
+}
+
+}

+ 9 - 0
tests/unit/native_cs/src/haxe/test/OverloadInterface2.cs

@@ -0,0 +1,9 @@
+namespace haxe.test
+{
+
+public interface OverloadInterface2
+{
+	int someOverloadedMethod(int a1);
+}
+
+}

+ 35 - 0
tests/unit/native_cs/src/haxe/test/StaticAndInstanceClash.cs

@@ -0,0 +1,35 @@
+namespace haxe.test
+{
+
+public class StaticAndInstanceClash : Base.InnerClass
+{
+	public static string someString;
+
+	public class StaticAndInstanceClashSame : StaticAndInstanceClash
+	{
+		public int someInt;
+	}
+
+	public class StaticAndInstanceAndMethodClash : StaticAndInstanceClashSame
+	{
+
+		private float sfloat = 5;
+		private int sint = 5;
+		public float someFloat()
+		{
+			return sfloat;
+		}
+
+		public float someFloat(float val)
+		{
+			return sfloat = val;
+		}
+
+		public int someInt()
+		{
+			return sint;
+		}
+	}
+}
+
+}

+ 9 - 0
tests/unit/native_cs/src/haxe/test/TEnum.cs

@@ -0,0 +1,9 @@
+namespace haxe.test
+{
+
+public enum TEnum
+{
+	TA,TB,TC
+}
+
+}