Skip to content
This repository was archived by the owner on Jan 26, 2022. It is now read-only.

Commit fc217e2

Browse files
committed
test AsyncGeneratorFunction's basic properties
1 parent 7bd31a5 commit fc217e2

10 files changed

+117
-0
lines changed
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
/*---
2+
* author: Sakthipriyan Vairamani (thefourtheye) <thechargingvolcano@gmail.com>
3+
* description: Make sure %AsyncGeneratorFunction% is exposed via the
4+
* `.constructor` property.
5+
---*/
6+
7+
const AsyncGeneratorFunction = async function* () {}.constructor;
8+
assert.sameValue(typeof AsyncGeneratorFunction, 'function');
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
/*---
2+
* author: Sakthipriyan Vairamani (thefourtheye) <thechargingvolcano@gmail.com>
3+
* description: Check if %AsyncGeneratorFunction% function derives from
4+
* `Function` object.
5+
---*/
6+
7+
async function* foo() {};
8+
const AsyncGeneratorFunction = async function* () {}.constructor;
9+
10+
assert.sameValue(Object.getPrototypeOf(AsyncGeneratorFunction), Function);
11+
assert.sameValue(
12+
Object.getPrototypeOf(AsyncGeneratorFunction.prototype),
13+
Function.prototype
14+
);
15+
assert(foo instanceof Function);
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
/*---
2+
* author: Sakthipriyan Vairamani (thefourtheye) <thechargingvolcano@gmail.com>
3+
* description: Check if %AsyncGeneratorFunction% function is extensible, by
4+
* adding and removing properties to it.
5+
---*/
6+
7+
const AsyncGeneratorFunction = async function* () {}.constructor;
8+
AsyncGeneratorFunction.testProperty = 'thefourtheye';
9+
10+
assert.sameValue(AsyncGeneratorFunction.testProperty, 'thefourtheye');
11+
assert(delete AsyncGeneratorFunction.testProperty);
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
/*---
2+
* author: Sakthipriyan Vairamani (thefourtheye) <thechargingvolcano@gmail.com>
3+
* description: Make sure %AsyncGeneratorFunction% is not a global function
4+
---*/
5+
6+
assert.throws(ReferenceError, function() {
7+
AsyncGeneratorFunction
8+
}, 'AsyncGeneratorFunction should not be available in global scope');
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
/*---
2+
* author: Sakthipriyan Vairamani (thefourtheye) <thechargingvolcano@gmail.com>
3+
* description: Validate %AsyncGeneratorFunction%'s `length` property and its
4+
* property descriptors
5+
---*/
6+
7+
const AsyncGeneratorFunction = async function* () {}.constructor;
8+
assert.sameValue(AsyncGeneratorFunction.length, 1);
9+
10+
verifyNotEnumerable(AsyncGeneratorFunction, 'length');
11+
verifyNotWritable(AsyncGeneratorFunction, 'length');
12+
verifyConfigurable(AsyncGeneratorFunction, 'length');
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
/*---
2+
* author: Sakthipriyan Vairamani (thefourtheye) <thechargingvolcano@gmail.com>
3+
* description: Validate %AsyncGeneratorFunction%'s `name` property and its
4+
* property descriptors
5+
---*/
6+
7+
const AsyncGeneratorFunction = async function* () {}.constructor;
8+
assert.sameValue(AsyncGeneratorFunction.name, 'AsyncGeneratorFunction');
9+
10+
verifyNotEnumerable(AsyncGeneratorFunction, 'name');
11+
verifyNotWritable(AsyncGeneratorFunction, 'name');
12+
verifyConfigurable(AsyncGeneratorFunction, 'name');
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
/*---
2+
* author: Sakthipriyan Vairamani (thefourtheye) <thechargingvolcano@gmail.com>
3+
* description: Check if %AsyncGeneratorFunction% function's `prototype`
4+
* object's `constructor` property is %AsyncGeneratorFunction%
5+
* itself
6+
---*/
7+
8+
const AsyncGeneratorFunction = async function* () {}.constructor;
9+
const AGFPrototype = AsyncGeneratorFunction.prototype;
10+
assert.sameValue(AGFPrototype.constructor, AsyncGeneratorFunction);
11+
12+
verifyNotEnumerable(AGFPrototype, 'constructor');
13+
verifyNotWritable(AGFPrototype, 'constructor');
14+
verifyConfigurable(AGFPrototype, 'constructor');
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
/*---
2+
* author: Sakthipriyan Vairamani (thefourtheye) <thechargingvolcano@gmail.com>
3+
* description: Check if %AsyncGeneratorFunction% function's `prototype` object
4+
* is extensible, by adding and removing properties to it.
5+
---*/
6+
7+
const AGFPrototype = async function* () {}.constructor.prototype;
8+
AGFPrototype.testProperty = 'thefourtheye';
9+
10+
assert.sameValue(AGFPrototype.testProperty, 'thefourtheye');
11+
assert(delete AGFPrototype.testProperty);
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
/*---
2+
* author: Sakthipriyan Vairamani (thefourtheye) <thechargingvolcano@gmail.com>
3+
* description: Check if %AsyncGeneratorFunction% function's `prototype`
4+
* object's `Symbol.toStringTag` property is
5+
* 'AsyncGeneratorFunction'
6+
---*/
7+
8+
const AsyncGeneratorFunction = async function* () {}.constructor;
9+
const AGFPrototype = AsyncGeneratorFunction.prototype;
10+
11+
assert.sameValue(AGFPrototype[Symbol.toStringTag], 'AsyncGeneratorFunction');
12+
13+
verifyNotEnumerable(AGFPrototype, Symbol.toStringTag);
14+
verifyNotWritable(AGFPrototype, Symbol.toStringTag);
15+
verifyConfigurable(AGFPrototype, Symbol.toStringTag);
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
/*---
2+
* author: Sakthipriyan Vairamani (thefourtheye) <thechargingvolcano@gmail.com>
3+
* description: Validate %AsyncGeneratorFunction% function's prototype
4+
* property.
5+
---*/
6+
7+
const AsyncGeneratorFunction = async function* () {}.constructor;
8+
9+
verifyNotEnumerable(AsyncGeneratorFunction, 'prototype');
10+
verifyNotWritable(AsyncGeneratorFunction, 'prototype');
11+
verifyNotConfigurable(AsyncGeneratorFunction, 'prototype');

0 commit comments

Comments
 (0)