mirror of
https://github.com/github/codeql.git
synced 2025-12-17 17:23:36 +01:00
27 lines
596 B
JavaScript
27 lines
596 B
JavaScript
function should(v) {
|
|
this.value = v;
|
|
}
|
|
should.prototype = {
|
|
get be() { return this; },
|
|
get ok() {
|
|
if (!this.value)
|
|
throw new Error("assertion failed");
|
|
}
|
|
};
|
|
|
|
Object.defineProperty(Object.prototype, 'should', {
|
|
get: function() { return new should(this.valueOf()); }
|
|
});
|
|
|
|
var myComplicatedPropertyDescriptor = (function(k) {
|
|
return {
|
|
[k]: function() { throw new Error("too complicated!"); }
|
|
}
|
|
})("get");
|
|
Object.defineProperty(Object.prototype, 'foo', myComplicatedPropertyDescriptor);
|
|
|
|
// OK - getters
|
|
(false).should.be.ok;
|
|
(false).should;
|
|
should.prototype.be;
|
|
({}).foo; |