Commit 61231a74 authored by Vinicius Jarina's avatar Vinicius Jarina
Browse files

Added core tests to NLua (bisect, life, trace-globals...)

parent 2da7b6e8
......@@ -9,8 +9,11 @@
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>ConsoleTest</RootNamespace>
<AssemblyName>ConsoleTest</AssemblyName>
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<ReleaseVersion>2.x</ReleaseVersion>
<ProductVersion>12.0.0</ProductVersion>
<SchemaVersion>2.0</SchemaVersion>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
......@@ -53,7 +56,7 @@
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Core\NLua\NLua.csproj">
<Project>{f55cabbb-4108-4a39-94e1-581fd46dc021}</Project>
<Project>{F55CABBB-4108-4A39-94E1-581FD46DC021}</Project>
<Name>NLua</Name>
</ProjectReference>
</ItemGroup>
......
......@@ -1006,6 +1006,11 @@ namespace NLua
LuaLib.lua_settop (luaState, oldTop);
}
public LuaFunction RegisterFunction (string path,MethodBase function /*MethodInfo function*/)
{
return RegisterFunction (path, null, function);
}
/*
* Registers an object's method as a Lua function (global or table field)
* The method may have any signature
......
......@@ -50,6 +50,9 @@
<Compile Include="..\tests\TestLua.cs">
<Link>TestLua.cs</Link>
</Compile>
<Compile Include="..\tests\Core.cs">
<Link>Core.cs</Link>
</Compile>
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>
......
using System;
using NUnit.Framework;
namespace NLuaTest
{
[TestFixture]
public class Core
{
[Test]
public void Pass ()
{
Assert.True (true);
}
[Test]
public void Fail ()
{
//Assert.False (true);
}
[Test]
[Ignore ("another time")]
public void Ignore ()
{
//Assert.True (false);
}
}
}
cd Core\KeraLua
Makefile.Win32.bat
call Makefile.Win32.bat
msbuild KeraLua.sln /p:Configuration=Release
cd ..\..
xcopy Core\KeraLua\external\lua\win32\bin\*.dll tests\*.dll
......
using System;
using NUnit.Framework;
using NLua;
using NLua.Exceptions;
using System.IO;
#if MONOTOUCH
using MonoTouch.Foundation;
#endif
namespace NLuaTest
{
[TestFixture]
#if MONOTOUCH
[Preserve (AllMembers = true)]
#endif
public class Core
{
Lua lua = null;
string GetTestPath(string name)
{
string filePath = Path.Combine (Path.Combine ("LuaTests", "core"), name + ".lua");
return filePath;
}
void AssertFile (string path)
{
lua.DoFile (path);
}
void TestLuaFile (string name)
{
string path = GetTestPath (name);
AssertFile (path);
}
[SetUp]
public void Setup()
{
lua = new Lua ();
lua.RegisterFunction ("print", typeof (Console).GetMethod ("WriteLine", new Type [] { typeof(String) }));
}
[TearDown]
public void TearDown ()
{
lua.Dispose ();
lua = null;
}
[Test]
public void Bisect ()
{
TestLuaFile ("bisect");
Assert.True (true);
}
[Test]
public void CF ()
{
TestLuaFile ("cf");
}
[Test]
public void Env ()
{
TestLuaFile ("env");
}
[Test]
public void Factorial ()
{
TestLuaFile ("factorial");
}
[Test]
public void FibFor ()
{
TestLuaFile ("fibfor");
}
[Test]
public void Life ()
{
TestLuaFile ("life");
}
[Test]
public void Printf ()
{
TestLuaFile ("printf");
}
[Test]
public void ReadOnly ()
{
TestLuaFile ("readonly");
}
[Test]
public void Sieve ()
{
TestLuaFile ("sieve");
}
[Test]
public void Sort ()
{
TestLuaFile ("sort");
}
[Test]
public void TraceGlobals ()
{
TestLuaFile ("trace-globals");
}
}
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment