C0b0ll Posted March 10, 2013 Share Posted March 10, 2013 (edited) Hi, Lua and MTA are new for me and I tried some peace of code. It is very powerful and particularly the unit testing. I read and tried the tutorial on UnitTesting (http://lua-users.org/wiki/UnitTesting) : -- Some super function to test function my_super_function( arg1, arg2 ) return arg1 + arg2 end -- Unit testing starts require('luaunit') TestMyStuff = {} --class function TestMyStuff:testWithNumbers() a = 1 b = 2 result = my_super_function( a, b ) assertEquals( type(result), 'number' ) assertEquals( result, 3 ) end function TestMyStuff:testWithRealNumbers() a = 1.1 b = 2.2 result = my_super_function( a, b ) assertEquals( type(result), 'number' ) -- I would like the result to be always rounded to an integer -- but it won't work with my simple implementation -- thus, the test will fail assertEquals( result, 3 ) end -- class TestMyStuff luaUnit:run() When I execute this code, the "compilator" (i'm using SciTO editor) says me : Quote > >lua -e "io.stdout:setvbuf 'no'" "aaa.lua" lua: aaa.lua:29: attempt to index global 'luaUnit' (a nil value) stack traceback: aaa.lua:29: in main chunk [C]: ? >Exit code: 1 What can I do to fix that problem ? Thanks a lot ! Edited March 11, 2013 by Guest Link to comment
50p Posted March 10, 2013 Share Posted March 10, 2013 As far as I know, MTA blocks 3rd party Lua libraries for security reasons, so require will not load any lib. Link to comment
C0b0ll Posted March 10, 2013 Author Share Posted March 10, 2013 Thanks for your reply, Then, how to write unit testing for my MTA script ? Link to comment
50p Posted March 10, 2013 Share Posted March 10, 2013 There is no need for it. If you really need one then you'll have to write it yourself. Link to comment
C0b0ll Posted March 11, 2013 Author Share Posted March 11, 2013 Thanks again for your help. I'll probably do it myself, but I have to learn more before . Link to comment
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now