This repository has been archived on 2023-03-25. You can view files and clone it, but cannot push or open issues or pull requests.
mightyscape-1.1-deprecated/extensions/fablabchemnitz/papercraft/openjscad/node_modules/sylvester/test/_setup.js

60 lines
1.3 KiB
JavaScript

import chai from 'chai';
import { Matrix, Vector, Sylvester } from '../src';
chai.Assertion.addProperty('matrix', function () {
new chai.Assertion(this._obj).to.be.instanceOf(Matrix);
return {
equal: other => {
if (!(other instanceof Matrix)) {
other = Matrix.create(other);
}
this.assert(
this._obj.eql(other),
'expected #{this} to equal #{exp}',
'expected #{this} to not equal #{exp}',
this._obj,
other,
true
);
}
};
});
chai.Assertion.addProperty('vector', function () {
new chai.Assertion(this._obj).to.be.instanceOf(Vector);
return {
equal: other => {
if (!(other instanceof Vector)) {
other = Vector.create(other);
}
this.assert(
this._obj.eql(other),
'expected #{this} to equal #{exp}',
'expected #{this} to not equal #{exp}',
this._obj,
other,
true
);
}
};
});
chai.Assertion.addProperty('approx', function () {
return {
equal: other => {
this.assert(
Math.abs(this._obj - other) < Sylvester.precision,
'expected #{this} to about equal #{exp}',
'expected #{this} to not equal #{exp}',
this._obj,
other,
true
);
}
};
});