Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
ruanhaishen
NLua
Commits
2937d569
Commit
2937d569
authored
May 28, 2013
by
Vinicius Jarina
Browse files
Added LoadFileTests.
Bumped KeraLua.
parent
caff04f5
Changes
3
Hide whitespace changes
Inline
Side-by-side
KeraLua
@
c82d8a1b
Compare
c26a0517
...
c82d8a1b
Subproject commit c
26a051774b700ad4271dac601aee0c665c637a9
Subproject commit c
82d8a1bcce31ab57def18dc6ea3804ba13244be
NLuaTest/LoadFileTests.cs
0 → 100644
View file @
2937d569
using
System
;
using
NUnit.Framework
;
using
NLua
;
using
NLuaTest.Mock
;
#if MONOTOUCH
using
MonoTouch.Foundation
;
using
MonoTouch
;
#endif
namespace
LoadFileTests
{
[
TestFixture
]
#
if
MONOTOUCH
[
Preserve
(
AllMembers
=
true
)]
#
endif
public
class
LoadLuaFile
{
/*
* Tests capturing an exception
*/
[
Test
]
public
void
TestLoadFile
()
{
using
(
Lua
lua
=
new
Lua
())
{
lua
.
LoadCLRPackage
();
lua
.
DoFile
(
"test.lua"
);
int
width
=
(
int
)(
double
)
lua
[
"width"
];
int
height
=
(
int
)(
double
)
lua
[
"height"
];
string
message
=
(
string
)
lua
[
"message"
];
int
color_g
=
(
int
)(
double
)
lua
[
"color.g"
];
LuaFunction
func
=
(
LuaFunction
)
lua
[
"func"
];
object
[]
res
=
func
.
Call
(
12
,
34
);
int
x
=
(
int
)(
double
)
res
[
0
];
int
y
=
(
int
)(
double
)
res
[
1
];
//function func(x,y)
// return x,x+y
//end
Assert
.
AreEqual
(
100
,
width
);
Assert
.
AreEqual
(
200
,
height
);
Assert
.
AreEqual
(
"Hello World!"
,
message
);
Assert
.
AreEqual
(
20
,
color_g
);
Assert
.
AreEqual
(
12
,
x
);
Assert
.
AreEqual
(
46
,
y
);
}
}
[
Test
]
public
void
TestBinaryLoadFile
()
{
// using (Lua lua = new Lua ()) {
// lua.LoadCLRPackage ();
//
// lua.LoadFile ("test.luac");
//
// int width = (int)(double)lua ["width"];
// int height = (int)(double)lua ["height"];
// string message = (string)lua ["message"];
// int color_g = (int)(double)lua ["color.g"];
// LuaFunction func = (LuaFunction)lua ["func"];
// object[] res = func.Call (12, 34);
// int x = (int)(double)res [0];
// int y = (int)(double)res [1];
// //function func(x,y)
// // return x,x+y
// //end
//
// Assert.AreEqual (100, width);
// Assert.AreEqual (200, height);
// Assert.AreEqual ("Hello World!", message);
// Assert.AreEqual (20, color_g);
// Assert.AreEqual (12, x);
// Assert.AreEqual (46, y);
// }
}
// [Test]
// public void TestBinaryLoadFile ()
// {
// using (Lua lua = new Lua ()) {
// lua.LoadCLRPackage ();
//
// lua.LoadFile ("test.luac");
//
// int width = (int)(double)lua ["width"];
// int height = (int)(double)lua ["height"];
// string message = (string)lua ["message"];
// int color_g = (int)(double)lua ["color.g"];
// LuaFunction func = (LuaFunction)lua ["func"];
// object[] res = func.Call (12, 34);
// int x = (int)(double)res [0];
// int y = (int)(double)res [1];
// //function func(x,y)
// // return x,x+y
// //end
//
// Assert.AreEqual (100, width);
// Assert.AreEqual (200, height);
// Assert.AreEqual ("Hello World!", message);
// Assert.AreEqual (20, color_g);
// Assert.AreEqual (12, x);
// Assert.AreEqual (46, y);
// }
// }
}
}
NLuaTest/NLuaTest.csproj
View file @
2937d569
...
...
@@ -53,6 +53,7 @@
<Compile
Include=
"..\tests\Core.cs"
>
<Link>
Core.cs
</Link>
</Compile>
<Compile
Include=
"LoadFileTests.cs"
/>
<Compile
Include=
"Properties\AssemblyInfo.cs"
/>
</ItemGroup>
<ItemGroup>
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment