1
0
Fork 0
mirror of https://github.com/beefytech/Beef.git synced 2025-06-10 12:32:20 +02:00

Tests for new visibility rules

This commit is contained in:
Brian Fiete 2020-07-01 12:06:51 -07:00
parent 75dd1a4213
commit 46a7e0568d
4 changed files with 124 additions and 0 deletions

View file

@ -3,6 +3,11 @@ using System.Collections;
namespace LibA
{
struct LibAStruct
{
int mA;
}
interface IVal
{
int Val
@ -33,6 +38,25 @@ namespace LibA
{
return lhs == rhs;
}
public static int GetOverload0<T>() where T : var
{
T val = default;
return Overload0(val);
}
}
struct Handler
{
public static int Handle(Object obj)
{
return 0;
}
public static int HandleT<T>(T val) where T : var
{
return Handle(val);
}
}
}
@ -74,4 +98,17 @@ class LibClassB
{
return LibClassA.GetVal3(val);
}
}
static
{
public static int Overload0(Object a)
{
return 0;
}
public static int Overload0(int8 a)
{
return 1;
}
}

View file

@ -1,7 +1,14 @@
using System;
namespace LibB
{
class LibB0
{
public static int GetOverload0<T>() where T : var
{
T val = default;
return Overload0(val);
}
}
}
@ -26,3 +33,11 @@ extension LibClassA
return mB;
}
}
static
{
public static int Overload0(int16 a)
{
return 2;
}
}

View file

@ -2,6 +2,11 @@ namespace LibC
{
class LibC0
{
public static int GetOverload0<T>() where T : var
{
T val = default;
return Overload0(val);
}
}
}
@ -21,3 +26,10 @@ extension LibClassA
}
}
static
{
public static int Overload0(int32 a)
{
return 3;
}
}

View file

@ -0,0 +1,60 @@
using System;
using System.Collections;
namespace LibA
{
extension Handler
{
public static int Handle(Tests.MethodSelection.StructA val)
{
return 4;
}
public static int Handle(LibA.LibAStruct val)
{
return 4;
}
public static int Handle(List<Tests.MethodSelection.StructA> val)
{
return 4;
}
}
}
namespace Tests
{
class MethodSelection
{
public struct StructA
{
int mA;
}
[Test]
public static void TestBasics()
{
Test.Assert(LibA.LibA0.GetOverload0<int8>() == 1);
Test.Assert(LibA.LibA0.GetOverload0<int16>() == 0);
Test.Assert(LibA.LibA0.GetOverload0<int32>() == 0);
Test.Assert(LibA.LibA0.GetOverload0<int64>() == 0);
Test.Assert(LibB.LibB0.GetOverload0<int8>() == 1);
Test.Assert(LibB.LibB0.GetOverload0<int16>() == 2);
Test.Assert(LibB.LibB0.GetOverload0<int32>() == 0);
Test.Assert(LibB.LibB0.GetOverload0<int64>() == 0);
Test.Assert(LibC.LibC0.GetOverload0<int8>() == 1);
Test.Assert(LibC.LibC0.GetOverload0<int16>() == 3);
Test.Assert(LibC.LibC0.GetOverload0<int32>() == 3);
Test.Assert(LibC.LibC0.GetOverload0<int64>() == 0);
StructA sa = .();
List<StructA> sal = null;
LibA.LibAStruct las = .();
Test.Assert(LibA.Handler.HandleT(sa) == 4);
Test.Assert(LibA.Handler.HandleT(sal) == 4);
Test.Assert(LibA.Handler.HandleT(las) == 0);
}
}
}