Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/npm/cli.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'node_modules/es-abstract/test/GetIntrinsic.js')
-rw-r--r--node_modules/es-abstract/test/GetIntrinsic.js60
1 files changed, 60 insertions, 0 deletions
diff --git a/node_modules/es-abstract/test/GetIntrinsic.js b/node_modules/es-abstract/test/GetIntrinsic.js
index ed8e7ecc6..a3e69a7bc 100644
--- a/node_modules/es-abstract/test/GetIntrinsic.js
+++ b/node_modules/es-abstract/test/GetIntrinsic.js
@@ -22,6 +22,26 @@ test('throws', function (t) {
'nonexistent intrinsic throws a syntax error'
);
+ t['throws'](
+ function () { GetIntrinsic(''); },
+ TypeError,
+ 'empty string intrinsic throws a type error'
+ );
+
+ t['throws'](
+ function () { GetIntrinsic('.'); },
+ SyntaxError,
+ '"just a dot" intrinsic throws a syntax error'
+ );
+
+ forEach(v.nonStrings, function (nonString) {
+ t['throws'](
+ function () { GetIntrinsic(nonString); },
+ TypeError,
+ debug(nonString) + ' is not a String'
+ );
+ });
+
forEach(v.nonBooleans, function (nonBoolean) {
t['throws'](
function () { GetIntrinsic('%', nonBoolean); },
@@ -30,5 +50,45 @@ test('throws', function (t) {
);
});
+ forEach([
+ 'toString',
+ 'propertyIsEnumerable',
+ 'hasOwnProperty'
+ ], function (objectProtoMember) {
+ t['throws'](
+ function () { GetIntrinsic(objectProtoMember); },
+ SyntaxError,
+ debug(objectProtoMember) + ' is not an intrinsic'
+ );
+ });
+
+ t.end();
+});
+
+test('base intrinsics', function (t) {
+ t.equal(GetIntrinsic('%Object%'), Object, '%Object% yields Object');
+ t.equal(GetIntrinsic('Object'), Object, 'Object yields Object');
+ t.equal(GetIntrinsic('%Array%'), Array, '%Array% yields Array');
+ t.equal(GetIntrinsic('Array'), Array, 'Array yields Array');
+
+ t.end();
+});
+
+test('dotted paths', function (t) {
+ t.equal(GetIntrinsic('%Object.prototype.toString%'), Object.prototype.toString, '%Object.prototype.toString% yields Object.prototype.toString');
+ t.equal(GetIntrinsic('Object.prototype.toString'), Object.prototype.toString, 'Object.prototype.toString yields Object.prototype.toString');
+ t.equal(GetIntrinsic('%Array.prototype.push%'), Array.prototype.push, '%Array.prototype.push% yields Array.prototype.push');
+ t.equal(GetIntrinsic('Array.prototype.push'), Array.prototype.push, 'Array.prototype.push yields Array.prototype.push');
+
+ t.end();
+});
+
+test('accessors', { skip: !Object.getOwnPropertyDescriptor || typeof Map !== 'function' }, function (t) {
+ var actual = Object.getOwnPropertyDescriptor(Map.prototype, 'size');
+ t.ok(actual, 'Map.prototype.size has a descriptor');
+ t.equal(typeof actual.get, 'function', 'Map.prototype.size has a getter function');
+ t.equal(GetIntrinsic('%Map.prototype.size%'), actual.get, '%Map.prototype.size% yields the getter for it');
+ t.equal(GetIntrinsic('Map.prototype.size'), actual.get, 'Map.prototype.size yields the getter for it');
+
t.end();
});