-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
e7ffc4a
commit c0f449b
Showing
19 changed files
with
970 additions
and
3 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
return { | ||
group = "Angle:Add", | ||
|
||
cases = { | ||
{ | ||
name = "Exists on the Angle meta table", | ||
func = function() | ||
local meta = FindMetaTable( "Angle" ) | ||
expect( meta.Add ).to.beA( "function" ) | ||
end | ||
}, | ||
|
||
{ | ||
name = "Returns nothing", | ||
func = function() | ||
local a = Angle( 1, 1, 1 ) | ||
local b = Angle( 1, 1, 1 ) | ||
|
||
local out = a:Add( b ) | ||
expect( out ).to.beNil() | ||
end | ||
}, | ||
|
||
{ | ||
name = "Modifies only the base Angle", | ||
func = function() | ||
local a = Angle( 1, 1, 1 ) | ||
local b = Angle( 1, 1, 1 ) | ||
|
||
a:Add( b ) | ||
|
||
local p1, y1, r1 = a[1], a[2], a[3] | ||
expect( p1 ).to.equal( 2 ) | ||
expect( y1 ).to.equal( 2 ) | ||
expect( r1 ).to.equal( 2 ) | ||
|
||
local p2, y2, r2 = b[1], b[2], b[3] | ||
expect( p2 ).to.equal( 1 ) | ||
expect( y2 ).to.equal( 1 ) | ||
expect( r2 ).to.equal( 1 ) | ||
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,76 @@ | ||
return { | ||
groupName = "Angle:Div", | ||
cases = { | ||
{ | ||
name = "Exits on the Angle meta table", | ||
func = function() | ||
local meta = FindMetaTable( "Angle" ) | ||
expect( meta.Div ).to.beA( "function" ) | ||
end | ||
}, | ||
|
||
{ | ||
name = "Returns nothing", | ||
func = function() | ||
local a = Angle( 2, 2, 2 ) | ||
|
||
local out = a:Div( 2 ) | ||
expect( out ).to.beNil() | ||
end | ||
}, | ||
|
||
{ | ||
name = "Modifies the base Angle", | ||
func = function() | ||
local a = Angle( 2, 2, 2 ) | ||
|
||
a:Div( 2 ) | ||
|
||
local p1, y1, r1 = a[1], a[2], a[3] | ||
expect( p1 ).to.equal( 1 ) | ||
expect( y1 ).to.equal( 1 ) | ||
expect( r1 ).to.equal( 1 ) | ||
end | ||
}, | ||
|
||
{ | ||
name = "Works when given a negative number", | ||
func = function() | ||
local a = Angle( 2, 2, 2 ) | ||
|
||
a:Div( -2 ) | ||
|
||
local p1, y1, r1 = a[1], a[2], a[3] | ||
expect( p1 ).to.equal( -1 ) | ||
expect( y1 ).to.equal( -1 ) | ||
expect( r1 ).to.equal( -1 ) | ||
end | ||
}, | ||
|
||
{ | ||
name = "Functions correctly when given a numeric string", | ||
func = function() | ||
local a = Angle( 2, 2, 2 ) | ||
|
||
a:Div( "2" ) | ||
local p1, y1, r1 = a[1], a[2], a[3] | ||
expect( p1 ).to.equal( 1 ) | ||
expect( y1 ).to.equal( 1 ) | ||
expect( r1 ).to.equal( 1 ) | ||
end | ||
}, | ||
{ | ||
name = "Errors when given a non-numeric string", | ||
func = function() | ||
local a = Angle( 2, 2, 2 ) | ||
|
||
local test = function() | ||
a:Div( "a" ) | ||
end | ||
|
||
expect( test ).to.errWith( [[bad argument #1 to 'Div' (number expected, got string)]] ) | ||
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,51 @@ | ||
return { | ||
groupName = "Angle:Forward", | ||
|
||
cases = { | ||
{ | ||
name = "Exists on the Angle meta table", | ||
func = function() | ||
local meta = FindMetaTable( "Angle" ) | ||
expect( meta.Forward ).to.beA( "function" ) | ||
end | ||
}, | ||
|
||
{ | ||
name = "Returns a Vector", | ||
func = function() | ||
local a = Angle( 0, 0, 0 ) | ||
|
||
local out = a:Forward() | ||
expect( out ).to.beA( "Vector" ) | ||
end | ||
}, | ||
|
||
{ | ||
name = "Returns the correct Vector", | ||
func = function() | ||
local a = Angle( 0, 0, 0 ) | ||
|
||
local out = a:Forward() | ||
local x, y, z = out[1], out[2], out[3] | ||
|
||
expect( x ).to.equal( 1 ) | ||
expect( y ).to.equal( 0 ) | ||
expect( z ).to.equal( 0 ) | ||
end | ||
}, | ||
|
||
{ | ||
name = "Does not modify the Angle", | ||
func = function() | ||
local a = Angle( 1, 1, 1 ) | ||
|
||
a:Forward() | ||
|
||
local p, y, r = a[1], a[2], a[3] | ||
expect( p ).to.equal( 1 ) | ||
expect( y ).to.equal( 1 ) | ||
expect( r ).to.equal( 1 ) | ||
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,113 @@ | ||
return { | ||
groupName = "Angle:IsEqualTol", | ||
|
||
cases = { | ||
{ | ||
name = "Exists on the Angle meta table", | ||
func = function() | ||
local meta = FindMetaTable( "Angle" ) | ||
expect( meta.IsEqualTol ).to.beA( "function" ) | ||
end | ||
}, | ||
|
||
{ | ||
name = "Returns a boolean", | ||
func = function() | ||
local a = Angle( 0, 0, 0 ) | ||
local b = Angle( 0, 0, 0 ) | ||
|
||
local out = a:IsEqualTol( b, 0 ) | ||
expect( out ).to.beA( "boolean" ) | ||
end | ||
}, | ||
|
||
{ | ||
name = "Returns true when the Angles are equal", | ||
func = function() | ||
local a = Angle( 0, 0, 0 ) | ||
local b = Angle( 0, 0, 0 ) | ||
|
||
local out = a:IsEqualTol( b, 0 ) | ||
expect( out ).to.beTrue() | ||
end | ||
}, | ||
|
||
{ | ||
name = "Returns false when the Angles are not equal", | ||
func = function() | ||
local a = Angle( 0, 0, 0 ) | ||
local b = Angle( 1, 1, 1 ) | ||
|
||
local out = a:IsEqualTol( b, 0 ) | ||
expect( out ).to.beFalse() | ||
end | ||
}, | ||
|
||
{ | ||
name = "Returns true when the Angles are within the tolerance", | ||
func = function() | ||
local a = Angle( 0, 0, 0 ) | ||
local b = Angle( 0.1, 0.1, 0.1 ) | ||
|
||
local out = a:IsEqualTol( b, 0.1 ) | ||
expect( out ).to.beTrue() | ||
end | ||
}, | ||
|
||
{ | ||
name = "Returns false when the Angles are not within the tolerance", | ||
func = function() | ||
local a = Angle( 0, 0, 0 ) | ||
local b = Angle( 0.1, 0.1, 0.1 ) | ||
|
||
local out = a:IsEqualTol( b, 0 ) | ||
expect( out ).to.beFalse() | ||
end | ||
}, | ||
|
||
{ | ||
name = "Does not modify the Angles", | ||
func = function() | ||
local a = Angle( 1, 1, 1 ) | ||
local b = Angle( 1, 1, 1 ) | ||
|
||
a:IsEqualTol( b, 0 ) | ||
|
||
local p1, y1, r1 = a[1], a[2], a[3] | ||
expect( p1 ).to.equal( 1 ) | ||
expect( y1 ).to.equal( 1 ) | ||
expect( r1 ).to.equal( 1 ) | ||
|
||
local p2, y2, r2 = b[1], b[2], b[3] | ||
expect( p2 ).to.equal( 1 ) | ||
expect( y2 ).to.equal( 1 ) | ||
expect( r2 ).to.equal( 1 ) | ||
end | ||
}, | ||
|
||
{ | ||
name = "Works when given a numeric string for the tolerance", | ||
func = function() | ||
local a = Angle( 0, 0, 0 ) | ||
local b = Angle( 0.1, 0.1, 0.1 ) | ||
|
||
local out = a:IsEqualTol( b, "0.1" ) | ||
expect( out ).to.beTrue() | ||
end | ||
}, | ||
|
||
{ | ||
name = "Errors when given a non-numeric string for the tolerance", | ||
func = function() | ||
local a = Angle( 0, 0, 0 ) | ||
local b = Angle( 0.1, 0.1, 0.1 ) | ||
|
||
local test = function() | ||
a:IsEqualTol( b, "a" ) | ||
end | ||
|
||
expect( test ).to.errWith( [[bad argument #2 to 'IsEqualTol' (number expected, got string)]] ) | ||
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,43 @@ | ||
return { | ||
groupName = "Angle:IsZero", | ||
|
||
cases = { | ||
{ | ||
name = "Exists on the Angle meta table", | ||
func = function() | ||
local meta = FindMetaTable( "Angle" ) | ||
expect( meta.IsZero ).to.beA( "function" ) | ||
end | ||
}, | ||
|
||
{ | ||
name = "Returns a boolean", | ||
func = function() | ||
local a = Angle( 0, 0, 0 ) | ||
|
||
local out = a:IsZero() | ||
expect( out ).to.beA( "boolean" ) | ||
end | ||
}, | ||
|
||
{ | ||
name = "Returns true when the Angle is zero", | ||
func = function() | ||
local a = Angle( 0, 0, 0 ) | ||
|
||
local out = a:IsZero() | ||
expect( out ).to.beTrue() | ||
end | ||
}, | ||
|
||
{ | ||
name = "Returns false when the Angle has no 0's", | ||
func = function() | ||
local a = Angle( 1, 1, 1 ) | ||
|
||
local out = a:IsZero() | ||
expect( out ).to.beFalse() | ||
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,65 @@ | ||
return { | ||
groupName = "Angle:Mul", | ||
|
||
cases = { | ||
{ | ||
name = "Exists on the Angle meta table", | ||
func = function() | ||
local meta = FindMetaTable( "Angle" ) | ||
expect( meta.Mul ).to.beA( "function" ) | ||
end | ||
}, | ||
|
||
{ | ||
name = "Returns nothing", | ||
func = function() | ||
local a = Angle( 2, 2, 2 ) | ||
|
||
local out = a:Mul( 2 ) | ||
expect( out ).to.beNil() | ||
end | ||
}, | ||
|
||
{ | ||
name = "Modifies the base Angle", | ||
func = function() | ||
local a = Angle( 2, 2, 2 ) | ||
|
||
a:Mul( 2 ) | ||
|
||
local p1, y1, r1 = a[1], a[2], a[3] | ||
expect( p1 ).to.equal( 4 ) | ||
expect( y1 ).to.equal( 4 ) | ||
expect( r1 ).to.equal( 4 ) | ||
end | ||
}, | ||
|
||
{ | ||
name = "Modifies the base Angle with a string scalar", | ||
func = function() | ||
local a = Angle( 2, 2, 2 ) | ||
|
||
a:Mul( "2" ) | ||
|
||
local p1, y1, r1 = a[1], a[2], a[3] | ||
expect( p1 ).to.equal( 4 ) | ||
expect( y1 ).to.equal( 4 ) | ||
expect( r1 ).to.equal( 4 ) | ||
end | ||
}, | ||
|
||
-- non numeric string | ||
{ | ||
name = "Does not modify the Angle with a non numeric string", | ||
func = function() | ||
local a = Angle( 2, 2, 2 ) | ||
|
||
local function test() | ||
a:Mul( "a" ) | ||
end | ||
|
||
expect( test ).to.errWith( [[bad argument #1 to 'Mul' (number expected, got string)]] ) | ||
end | ||
} | ||
} | ||
} |
Oops, something went wrong.