unexpected-function-equality
Version:
Determine function equivalence by pretty-printing, then comparing the strings
44 lines (32 loc) • 1.64 kB
Markdown
# unexpected-function-equality
[](http://badge.fury.io/js/unexpected-function-equality)
[](https://travis-ci.org/unexpectedjs/unexpected-function-equality)
[](https://coveralls.io/r/unexpectedjs/unexpected-function-equality)
[](https://david-dm.org/unexpectedjs/unexpected-function-equality)

Plugin for Unexpected 10+ that overrides the `<function> to equal <function>`
assertion with an implementation that disregards whitespace. This is
accomplished by parsing and pretty-printing the functions, then doing a string
comparison.
Example:
```js
var expect = require('unexpected')
.clone()
.use(require('unexpected-function-equality'));
it('should consider the two functions equal', function () {
expect(
function (a) {
return 123 - 456;
},
'to equal',
function (a) {
return 123 - 456;
}
);
});
```
This is handy when testing code that generates code.
## Releases
[Changelog](https://github.com/unexpectedjs/unexpected-function-equality/blob/master/CHANGELOG.md)
## License
Unexpected-function-equality is licensed under a standard 3-clause BSD license -- see the `LICENSE` file for details.