-
Notifications
You must be signed in to change notification settings - Fork 227
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Add Travis CI Image * Added math.lua Test Cases * fixed luaunit_example.lua to work from root * add util test file * Made Test work with only one file * .. * LUA! It's called regex not some random ass bullshit! * Remove Regex Test * Added math.lua Test Cases * fixed luaunit_example.lua to work from root * add util test file * Made Test work with only one file * .. * LUA! It's called regex not some random ass bullshit! * Remove Regex Test * Added functional.lua test * Apparently I'm doing something wrong with partial * revert files
- Loading branch information
1 parent
2a688fc
commit 1405e05
Showing
5 changed files
with
234 additions
and
111 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
require('game/scripts/vscripts/libraries/functional') | ||
|
||
TestPartial = {} | ||
|
||
function TestPartial:setUp () | ||
print("Testing partial() from function.lua") | ||
end | ||
|
||
function add (a, b) | ||
return a + b | ||
end | ||
|
||
function TestPartial:test1 () | ||
print("simple test") | ||
local addToFive = partial(add, 5) | ||
assertEquals(addToFive(5), 10) | ||
assertEquals(addToFive(-5), 0) | ||
assertEquals(addToFive(-10), -5) | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
require('game/scripts/vscripts/libraries/math') | ||
|
||
TestMath = {} | ||
|
||
function TestMath:setUp() | ||
print("Testing doLinesIntersect() from libraries/math.lua") | ||
self.P1 = { x = 0, y = 0 } | ||
self.P2 = { x = 1, y = 1 } | ||
self.P3 = { x = 0, y = 1 } | ||
self.P4 = { x = 1, y = 0 } | ||
self.P5 = { x = -1, y = 1 } | ||
self.P6 = { x = 1, y = -1 } | ||
self.P7 = { x = 0, y = -1 } | ||
self.P8 = { x = -1, y = 0 } | ||
self.P9 = { x = -1, y = -1 } | ||
end | ||
|
||
function TestMath:test1() | ||
print("with a simple intersection at (0,0)") | ||
local isIntersecting, intersection = math.doLinesIntersect(self.P5, self.P6, self.P9, self.P2) | ||
luaunit.assertTrue(isIntersecting) | ||
luaunit.assertEquals(intersection, self.P1) | ||
end | ||
|
||
function TestMath:test2() | ||
print("with parallel not touching lines") | ||
local isIntersecting, intersection = math.doLinesIntersect(self.P5, self.P2, self.P9, self.P6) | ||
luaunit.assertFalse(isIntersecting) | ||
end | ||
|
||
function TestMath:test3() | ||
print("with weird not touching lines") | ||
local isIntersecting, intersection = math.doLinesIntersect(self.P9, self.P1, self.P7, self.P6) | ||
luaunit.assertFalse(isIntersecting) | ||
end | ||
|
||
function TestMath:test4() | ||
print("with lines touching at the end") | ||
local isIntersecting, intersection = math.doLinesIntersect(self.P5, self.P3, self.P2, self.P3) | ||
luaunit.assertTrue(isIntersecting) | ||
luaunit.assertEquals(intersection, self.P1) | ||
end | ||
|
||
function TestMath:test5() | ||
print("with the same lines") | ||
local isIntersecting, intersection = math.doLinesIntersect(self.P1, self.P2, self.P1, self.P2) | ||
luaunit.assertTrue(isIntersecting) | ||
luaunit.assertEquals(intersection, self.P1) | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
luaunit = require('contrib/luaunit') | ||
require('contrib/test_math') | ||
require('contrib/test_util') | ||
require('contrib/test_functional') | ||
|
||
local runner = luaunit.LuaUnit.new() | ||
runner:setOutputType("tap") | ||
os.exit( runner:runSuite() ) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
require('game/scripts/vscripts/internal/util') | ||
|
||
TestSplit = {} | ||
|
||
function TestSplit:setUp() | ||
self.string1 = "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nam sed orci arcu. Duis tristique sagittis turpis, eget laoreet nisi lobortis ac. Nullam eu ultricies est, vitae venenatis nunc. Ut faucibus, nisi vel eleifend rutrum, sapien elit lacinia nibh, vitae gravida lacus tortor sed magna. Sed ullamcorper accumsan tellus, et tempus neque lobortis ut. Quisque at lacinia elit. Curabitur posuere orci vel orci ultrices posuere. Donec tristique lobortis lectus, non semper risus egestas non. Phasellus bibendum, arcu et feugiat condimentum, erat nibh ornare justo, nec ullamcorper nunc tortor quis mi. Vivamus interdum molestie elit, quis commodo neque tempor eget. Curabitur consequat at massa in convallis." | ||
end | ||
|
||
function TestSplit:test1() | ||
print("Splitting on ','") | ||
local result = { | ||
"Lorem ipsum dolor sit amet", | ||
" consectetur adipiscing elit. Nam sed orci arcu. Duis tristique sagittis turpis", | ||
" eget laoreet nisi lobortis ac. Nullam eu ultricies est", | ||
" vitae venenatis nunc. Ut faucibus", | ||
" nisi vel eleifend rutrum", | ||
" sapien elit lacinia nibh", | ||
" vitae gravida lacus tortor sed magna. Sed ullamcorper accumsan tellus", | ||
" et tempus neque lobortis ut. Quisque at lacinia elit. Curabitur posuere orci vel orci ultrices posuere. Donec tristique lobortis lectus", | ||
" non semper risus egestas non. Phasellus bibendum", | ||
" arcu et feugiat condimentum", | ||
" erat nibh ornare justo", | ||
" nec ullamcorper nunc tortor quis mi. Vivamus interdum molestie elit", | ||
" quis commodo neque tempor eget. Curabitur consequat at massa in convallis." | ||
} | ||
luaunit.assertEquals(split(self.string1, ","), result) | ||
end | ||
|
||
function TestSplit:test2() | ||
print("Splitting on '.'") | ||
local result = { | ||
"Lorem ipsum dolor sit amet, consectetur adipiscing elit", | ||
" Nam sed orci arcu", | ||
" Duis tristique sagittis turpis, eget laoreet nisi lobortis ac", | ||
" Nullam eu ultricies est, vitae venenatis nunc", | ||
" Ut faucibus, nisi vel eleifend rutrum, sapien elit lacinia nibh, vitae gravida lacus tortor sed magna", | ||
" Sed ullamcorper accumsan tellus, et tempus neque lobortis ut", | ||
" Quisque at lacinia elit", | ||
" Curabitur posuere orci vel orci ultrices posuere", | ||
" Donec tristique lobortis lectus, non semper risus egestas non", | ||
" Phasellus bibendum, arcu et feugiat condimentum, erat nibh ornare justo, nec ullamcorper nunc tortor quis mi", | ||
" Vivamus interdum molestie elit, quis commodo neque tempor eget", | ||
" Curabitur consequat at massa in convallis", | ||
"" | ||
} | ||
luaunit.assertEquals(split(self.string1, "%."), result) | ||
end |