-
Notifications
You must be signed in to change notification settings - Fork 15
Open
Description
This issue was found thanks to performing mutation analysis with Mutator (http://ortask.com/mutator/) on test suite homog-test.js.
The constructor for Homog (homog.js) seems to support 2D systems by accepting a 2D rotation matrix and 2D vector as parameters. However, the resulting matrix is not initialized properly.
In particular, I added the following test to homog-test.js as suggested by mutation analysis:
it('creates matrix with good values for 2D systems', function () {
var Rz = new Matrix(2, 2);
var Trans = new Vector(0,0)
var H1 = new Homog(Rz, Trans);
H1.m.should.eql([[0, 0, 0, 0], [0, 0, 0, 0], [0, 0, 1, 0], [0, 0, 0, 1]]);
});
but get the following error when running the tests:
1) Create a homogenous matrix creates matrix with good values for 2D systems:
AssertionError: expected [ [ 0, 0, , 0 ], [ 0, 0, , 0 ], [ 0, 0, 1, 0 ], [
0, 0, 0, 1 ] ] to equal [ [ 0, 0, 0, 0 ], [ 0, 0, 0, 0 ], [ 0, 0, 1, 0 ], [ 0,
0, 0, 1 ] ]
+ expected - actual
[
[
0
0
- null
0
+ 0
]
[
0
0
- null
0
+ 0
]
[
0
0
Inspecting the constructor for Homog, it seems that the following loop only sets the first four elements of the matrix (as that is the limit when passing in a 2x2 rotation matrix), but leaves elements (0,2) and (1,2) uninitialized (i.e. as null):
// fill in the rotation part
for (var r = 0; r < rot.rows; ++r) {
for (var c = 0; c < rot.cols; ++c) {
H.set(r, c, rot.get(r, c));
}
}
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels