-
Notifications
You must be signed in to change notification settings - Fork 58
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
6e0a765
commit 07b5ac0
Showing
14 changed files
with
317 additions
and
43 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,5 @@ | ||
describe('', () => { | ||
it('Function.length is always 1, the only "required" param', () => { | ||
assert.strictEqual(Function.length, 1); | ||
}); | ||
}); |
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,11 @@ | ||
describe('Using `new Function()` creates a new function', () => { | ||
it('WHEN using `new Function()` THEN this is equivalent to `Function()` with the same parameters', () => { | ||
const fn1 = new Function('a', 'b', 'return a + b'); | ||
const fn2 = Function('a', 'b', 'return a + b'); | ||
assert.deepStrictEqual(Object.getOwnPropertyDescriptors(fn1), Object.getOwnPropertyDescriptors(fn2)); | ||
}); | ||
it('num params', () => { | ||
const fn = new Function('a, b', 'c', 'return null'); | ||
assert.strictEqual(fn.length, 3); | ||
}); | ||
}); |
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,12 @@ | ||
describe('The `Function` prototype contains all methods and properties of a function', () => { | ||
it('the specified methods and props', () => { | ||
const ownPropertyNames = Object.getOwnPropertyNames(Function.prototype); | ||
['length', 'name', 'constructor', 'apply', 'bind', 'call', 'toString'] | ||
.forEach(name => assert(ownPropertyNames.includes(name), `Failed to find "${name}".`)); | ||
}); | ||
it('the old/deprecated/inofficial methods and props', () => { | ||
const ownPropertyNames = Object.getOwnPropertyNames(Function.prototype); | ||
['arguments', 'caller'] | ||
.forEach(name => assert(ownPropertyNames.includes(name), `Failed to find "${name}".`)); | ||
}); | ||
}); |
Empty file.
Empty file.
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
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
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,19 @@ | ||
describe('The `arguments` prop - discouraged since 1997 (and might not work)', () => { | ||
it('WHEN accessing `arguments` in strict mode THEN the JS throws', () => { | ||
const fn = function() {} | ||
assert.throws(() => fn.arguments); | ||
}); | ||
it('WHEN reading `arguments` using an Object-method THEN it returns `undefined`', () => { | ||
const fn = function() {} | ||
assert.equal(Object.getOwnPropertyDescriptor(fn, 'arguments'), undefined); | ||
}); | ||
|
||
it('WHEN reading `arguments` in the function body THEN it is an array-like object containing all parameters the function was called with', () => { | ||
let args; | ||
const fn = function() { | ||
args = arguments; | ||
} | ||
fn(1, 'abc', {x: 'y'}); | ||
assert.deepStrictEqual(Array.from(args), [1, 'abc', {x: 'y'}]); | ||
}); | ||
}); |
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,10 @@ | ||
describe('The `prototype` property - the place to add shared functionality', () => { | ||
it('WHEN defining the `prototype` on a function THEN the instance of that function inherits these properties', () => { | ||
const fn = function() {} | ||
fn.prototype = { | ||
solution: 42, | ||
}; | ||
const obj = new fn(); | ||
assert.equal(obj.solution, 42); | ||
}); | ||
}); |
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
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
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
Oops, something went wrong.