From 52b7fe4b20458e900a12089d0a569103ce637bb6 Mon Sep 17 00:00:00 2001 From: Denis Pushkarev Date: Mon, 23 Nov 2015 14:32:02 +0600 Subject: [PATCH] some additional tests related #134 --- tests/es.js | 107 ++++++++++++++--- tests/library.js | 108 +++++++++++++++--- tests/library/es6.map.ls | 4 + .../es6.object.statics-accept-primitives.ls | 27 +++-- tests/library/es6.set.ls | 4 + tests/library/es6.weak-map.ls | 4 + tests/library/es6.weak-set.ls | 4 + tests/tests.js | 107 ++++++++++++++--- tests/tests/es6.map.ls | 4 + .../es6.object.statics-accept-primitives.ls | 26 +++-- tests/tests/es6.set.ls | 4 + tests/tests/es6.weak-map.ls | 4 + tests/tests/es6.weak-set.ls | 4 + 13 files changed, 332 insertions(+), 75 deletions(-) diff --git a/tests/es.js b/tests/es.js index 9481d68b8242..6d3b18d8742c 100644 --- a/tests/es.js +++ b/tests/es.js @@ -1179,7 +1179,7 @@ }; getOwnPropertyDescriptor = Object.getOwnPropertyDescriptor, freeze = Object.freeze; test('Map', function(assert){ - var x$, done, iter, a, o; + var x$, done, iter, a, o, key; assert.isFunction(Map); assert.arity(Map, 0); assert.name(Map, 'Map'); @@ -1212,8 +1212,19 @@ assert.ok(done); o = {}; new Map().set(o, 1); + if (DESCRIPTORS) { + assert.arrayEqual((function(){ + var results$ = []; + for (key in o) { + results$.push(key); + } + return results$; + }()), []); + assert.arrayEqual(Object.keys(o), []); + } assert.arrayEqual(Object.getOwnPropertyNames(o), []); - return assert.arrayEqual(Object.getOwnPropertySymbols(o), []); + assert.arrayEqual(Object.getOwnPropertySymbols(o), []); + return assert.arrayEqual(Reflect.ownKeys(o), []); }); test('Map#clear', function(assert){ var M, x$, y$, f; @@ -2668,9 +2679,10 @@ // Generated by LiveScript 1.3.1 (function(){ - var module, test, toString$ = {}.toString; + var module, test, seal, freeze, preventExtensions, keys, getOwnPropertyNames, getOwnPropertySymbols, toString$ = {}.toString; module = QUnit.module, test = QUnit.test; module('ES6'); + seal = Object.seal, freeze = Object.freeze, preventExtensions = Object.preventExtensions, keys = Object.keys, getOwnPropertyNames = Object.getOwnPropertyNames, getOwnPropertySymbols = Object.getOwnPropertySymbols; test('Object static methods accept primitives', function(assert){ var i$, ref$, len$, method, j$, ref1$, len1$, value; for (i$ = 0, len$ = (ref$ = ['freeze', 'seal', 'preventExtensions', 'getOwnPropertyDescriptor', 'getPrototypeOf', 'isExtensible', 'isSealed', 'isFrozen', 'keys', 'getOwnPropertyNames']).length; i$ < len$; ++i$) { @@ -2718,22 +2730,46 @@ } }); test('Object.seal', function(assert){ - var seal; - seal = Object.seal; - assert.arrayEqual(Object.getOwnPropertyNames(seal({})), []); - assert.arrayEqual(Object.getOwnPropertySymbols(seal({})), []); + var key; + assert.arrayEqual((function(){ + var results$ = []; + for (key in seal({})) { + results$.push(key); + } + return results$; + }()), []); + assert.arrayEqual(keys(seal({})), []); + assert.arrayEqual(getOwnPropertyNames(seal({})), []); + assert.arrayEqual(getOwnPropertySymbols(seal({})), []); + assert.arrayEqual(Reflect.ownKeys(seal({})), []); }); test('Object.freeze', function(assert){ - var freeze; - freeze = Object.freeze; - assert.arrayEqual(Object.getOwnPropertyNames(freeze({})), []); - assert.arrayEqual(Object.getOwnPropertySymbols(freeze({})), []); + var key; + assert.arrayEqual((function(){ + var results$ = []; + for (key in freeze({})) { + results$.push(key); + } + return results$; + }()), []); + assert.arrayEqual(keys(freeze({})), []); + assert.arrayEqual(getOwnPropertyNames(freeze({})), []); + assert.arrayEqual(getOwnPropertySymbols(freeze({})), []); + assert.arrayEqual(Reflect.ownKeys(freeze({})), []); }); test('Object.preventExtensions', function(assert){ - var preventExtensions; - preventExtensions = Object.preventExtensions; - assert.arrayEqual(Object.getOwnPropertyNames(preventExtensions({})), []); - assert.arrayEqual(Object.getOwnPropertySymbols(preventExtensions({})), []); + var key; + assert.arrayEqual((function(){ + var results$ = []; + for (key in preventExtensions({})) { + results$.push(key); + } + return results$; + }()), []); + assert.arrayEqual(keys(preventExtensions({})), []); + assert.arrayEqual(getOwnPropertyNames(preventExtensions({})), []); + assert.arrayEqual(getOwnPropertySymbols(preventExtensions({})), []); + assert.arrayEqual(Reflect.ownKeys(preventExtensions({})), []); }); }).call(this); @@ -4809,7 +4845,7 @@ }; getOwnPropertyDescriptor = Object.getOwnPropertyDescriptor, freeze = Object.freeze; test('Set', function(assert){ - var x$, y$, S, r, z$, z1$, done, iter, _add, a, o; + var x$, y$, S, r, z$, z1$, done, iter, _add, a, o, key; assert.isFunction(Set); assert.name(Set, 'Set'); assert.arity(Set, 0); @@ -4862,8 +4898,19 @@ assert.ok(done); o = {}; new Set().add(o); + if (DESCRIPTORS) { + assert.arrayEqual((function(){ + var results$ = []; + for (key in o) { + results$.push(key); + } + return results$; + }()), []); + assert.arrayEqual(Object.keys(o), []); + } assert.arrayEqual(Object.getOwnPropertyNames(o), []); - return assert.arrayEqual(Object.getOwnPropertySymbols(o), []); + assert.arrayEqual(Object.getOwnPropertySymbols(o), []); + return assert.arrayEqual(Reflect.ownKeys(o), []); }); test('Set#add', function(assert){ var a, x$, S, chain, y$, f; @@ -6109,7 +6156,7 @@ module('ES6'); freeze = Object.freeze; test('WeakMap', function(assert){ - var a, x$, f, M, done, iter, o; + var a, x$, f, M, done, iter, o, key; assert.isFunction(WeakMap); assert.name(WeakMap, 'WeakMap'); assert.arity(WeakMap, 0); @@ -6149,8 +6196,19 @@ assert.ok(done); o = {}; new WeakMap().set(o, 1); + if (DESCRIPTORS) { + assert.arrayEqual((function(){ + var results$ = []; + for (key in o) { + results$.push(key); + } + return results$; + }()), []); + assert.arrayEqual(Object.keys(o), []); + } assert.arrayEqual(Object.getOwnPropertyNames(o), []); assert.arrayEqual(Object.getOwnPropertySymbols(o), []); + assert.arrayEqual(Reflect.ownKeys(o), []); }); test('WeakMap#delete', function(assert){ var x$, M, a, b; @@ -6237,7 +6295,7 @@ module('ES6'); freeze = Object.freeze; test('WeakSet', function(assert){ - var a, x$, f, S, done, iter, o; + var a, x$, f, S, done, iter, o, key; assert.isFunction(WeakSet); assert.name(WeakSet, 'WeakSet'); assert.arity(WeakSet, 0); @@ -6274,8 +6332,19 @@ assert.ok(done); o = {}; new WeakSet().add(o); + if (DESCRIPTORS) { + assert.arrayEqual((function(){ + var results$ = []; + for (key in o) { + results$.push(key); + } + return results$; + }()), []); + assert.arrayEqual(Object.keys(o), []); + } assert.arrayEqual(Object.getOwnPropertyNames(o), []); assert.arrayEqual(Object.getOwnPropertySymbols(o), []); + assert.arrayEqual(Reflect.ownKeys(o), []); }); test('WeakSet#add', function(assert){ var a, e, wset; diff --git a/tests/library.js b/tests/library.js index b2fe87491c13..3c4e500314be 100644 --- a/tests/library.js +++ b/tests/library.js @@ -1711,7 +1711,7 @@ ref$ = core.Object, getOwnPropertyDescriptor = ref$.getOwnPropertyDescriptor, freeze = ref$.freeze; iterator = core.Symbol.iterator; test('Map', function(assert){ - var done, iter, a, o; + var done, iter, a, o, key; assert.isFunction(Map); assert.ok('clear' in Map.prototype, 'clear in Map.prototype'); assert.ok('delete' in Map.prototype, 'delete in Map.prototype'); @@ -1743,8 +1743,19 @@ assert.ok(done); o = {}; new Map().set(o, 1); + if (DESCRIPTORS) { + assert.arrayEqual((function(){ + var results$ = []; + for (key in o) { + results$.push(key); + } + return results$; + }()), []); + assert.arrayEqual(core.Object.keys(o), []); + } assert.arrayEqual(core.Object.getOwnPropertyNames(o), []); - return assert.arrayEqual(core.Object.getOwnPropertySymbols(o), []); + assert.arrayEqual(core.Object.getOwnPropertySymbols(o), []); + return assert.arrayEqual(core.Reflect.ownKeys(o), []); }); test('Map#clear', function(assert){ var M, f; @@ -2766,9 +2777,11 @@ // Generated by LiveScript 1.3.1 (function(){ - var module, test, toString$ = {}.toString; + var module, test, ref$, seal, freeze, preventExtensions, keys, getOwnPropertyNames, getOwnPropertySymbols, Reflect, toString$ = {}.toString; module = QUnit.module, test = QUnit.test; module('ES6'); + ref$ = core.Object, seal = ref$.seal, freeze = ref$.freeze, preventExtensions = ref$.preventExtensions, keys = ref$.keys, getOwnPropertyNames = ref$.getOwnPropertyNames, getOwnPropertySymbols = ref$.getOwnPropertySymbols; + Reflect = core.Reflect; test('Object static methods accept primitives', function(assert){ var i$, ref$, len$, method, j$, ref1$, len1$, value; for (i$ = 0, len$ = (ref$ = ['freeze', 'seal', 'preventExtensions', 'getOwnPropertyDescriptor', 'getPrototypeOf', 'isExtensible', 'isSealed', 'isFrozen', 'keys', 'getOwnPropertyNames']).length; i$ < len$; ++i$) { @@ -2815,22 +2828,46 @@ } }); test('Object.seal', function(assert){ - var seal; - seal = core.Object.seal; - assert.arrayEqual(core.Object.getOwnPropertyNames(seal({})), []); - assert.arrayEqual(core.Object.getOwnPropertySymbols(seal({})), []); + var key; + assert.arrayEqual((function(){ + var results$ = []; + for (key in seal({})) { + results$.push(key); + } + return results$; + }()), []); + assert.arrayEqual(keys(seal({})), []); + assert.arrayEqual(getOwnPropertyNames(seal({})), []); + assert.arrayEqual(getOwnPropertySymbols(seal({})), []); + assert.arrayEqual(Reflect.ownKeys(seal({})), []); }); test('Object.freeze', function(assert){ - var freeze; - freeze = core.Object.freeze; - assert.arrayEqual(core.Object.getOwnPropertyNames(freeze({})), []); - assert.arrayEqual(core.Object.getOwnPropertySymbols(freeze({})), []); + var key; + assert.arrayEqual((function(){ + var results$ = []; + for (key in freeze({})) { + results$.push(key); + } + return results$; + }()), []); + assert.arrayEqual(keys(freeze({})), []); + assert.arrayEqual(getOwnPropertyNames(freeze({})), []); + assert.arrayEqual(getOwnPropertySymbols(freeze({})), []); + assert.arrayEqual(Reflect.ownKeys(freeze({})), []); }); test('Object.preventExtensions', function(assert){ - var preventExtensions; - preventExtensions = core.Object.preventExtensions; - assert.arrayEqual(core.Object.getOwnPropertyNames(preventExtensions({})), []); - assert.arrayEqual(core.Object.getOwnPropertySymbols(preventExtensions({})), []); + var key; + assert.arrayEqual((function(){ + var results$ = []; + for (key in preventExtensions({})) { + results$.push(key); + } + return results$; + }()), []); + assert.arrayEqual(keys(preventExtensions({})), []); + assert.arrayEqual(getOwnPropertyNames(preventExtensions({})), []); + assert.arrayEqual(getOwnPropertySymbols(preventExtensions({})), []); + assert.arrayEqual(Reflect.ownKeys(preventExtensions({})), []); }); }).call(this); @@ -3523,7 +3560,7 @@ ref$ = core.Object, getOwnPropertyDescriptor = ref$.getOwnPropertyDescriptor, freeze = ref$.freeze; iterator = core.Symbol.iterator; test('Set', function(assert){ - var from, S, r, done, iter, _add, a, o; + var from, S, r, done, iter, _add, a, o, key; from = core.Array.from; assert.isFunction(Set); assert.ok('add' in Set.prototype, 'add in Set.prototype'); @@ -3569,8 +3606,19 @@ assert.ok(done); o = {}; new Set().add(o); + if (DESCRIPTORS) { + assert.arrayEqual((function(){ + var results$ = []; + for (key in o) { + results$.push(key); + } + return results$; + }()), []); + assert.arrayEqual(core.Object.keys(o), []); + } assert.arrayEqual(core.Object.getOwnPropertyNames(o), []); - return assert.arrayEqual(core.Object.getOwnPropertySymbols(o), []); + assert.arrayEqual(core.Object.getOwnPropertySymbols(o), []); + return assert.arrayEqual(core.Reflect.ownKeys(o), []); }); test('Set#add', function(assert){ var a, S, chain, f; @@ -4692,7 +4740,7 @@ freeze = core.Object.freeze; iterator = core.Symbol.iterator; test('WeakMap', function(assert){ - var a, f, M, done, iter, o; + var a, f, M, done, iter, o, key; assert.isFunction(WeakMap); assert.ok('delete' in WeakMap.prototype, 'delete in WeakMap.prototype'); assert.ok('get' in WeakMap.prototype, 'get in WeakMap.prototype'); @@ -4730,8 +4778,19 @@ assert.ok(done); o = {}; new WeakMap().set(o, 1); + if (DESCRIPTORS) { + assert.arrayEqual((function(){ + var results$ = []; + for (key in o) { + results$.push(key); + } + return results$; + }()), []); + assert.arrayEqual(core.Object.keys(o), []); + } assert.arrayEqual(core.Object.getOwnPropertyNames(o), []); assert.arrayEqual(core.Object.getOwnPropertySymbols(o), []); + assert.arrayEqual(core.Reflect.ownKeys(o), []); }); test('WeakMap#delete', function(assert){ var M, a, b; @@ -4805,7 +4864,7 @@ freeze = core.Object.freeze; iterator = core.Symbol.iterator; test('WeakSet', function(assert){ - var a, f, S, done, iter, o; + var a, f, S, done, iter, o, key; assert.isFunction(WeakSet); assert.ok('add' in WeakSet.prototype, 'add in WeakSet.prototype'); assert.ok('delete' in WeakSet.prototype, 'delete in WeakSet.prototype'); @@ -4840,8 +4899,19 @@ assert.ok(done); o = {}; new WeakSet().add(o); + if (DESCRIPTORS) { + assert.arrayEqual((function(){ + var results$ = []; + for (key in o) { + results$.push(key); + } + return results$; + }()), []); + assert.arrayEqual(core.Object.keys(o), []); + } assert.arrayEqual(core.Object.getOwnPropertyNames(o), []); assert.arrayEqual(core.Object.getOwnPropertySymbols(o), []); + assert.arrayEqual(core.Reflect.ownKeys(o), []); }); test('WeakSet#add', function(assert){ var w, e; diff --git a/tests/library/es6.map.ls b/tests/library/es6.map.ls index a9c526c4f8b7..8d71ee8e832d 100644 --- a/tests/library/es6.map.ls +++ b/tests/library/es6.map.ls @@ -33,8 +33,12 @@ test 'Map' (assert)-> assert.ok done o = {} new Map!set o, 1 + if DESCRIPTORS + assert.arrayEqual [key for key of o], [] + assert.arrayEqual core.Object.keys(o), [] assert.arrayEqual core.Object.getOwnPropertyNames(o), [] assert.arrayEqual core.Object.getOwnPropertySymbols(o), [] + assert.arrayEqual core.Reflect.ownKeys(o), [] test 'Map#clear' (assert)-> assert.isFunction Map::clear diff --git a/tests/library/es6.object.statics-accept-primitives.ls b/tests/library/es6.object.statics-accept-primitives.ls index ef4c95d61120..1c5ea96c8279 100644 --- a/tests/library/es6.object.statics-accept-primitives.ls +++ b/tests/library/es6.object.statics-accept-primitives.ls @@ -1,6 +1,9 @@ {module, test} = QUnit module \ES6 +{seal, freeze, preventExtensions, keys, getOwnPropertyNames, getOwnPropertySymbols} = core.Object +Reflect = core.Reflect + test 'Object static methods accept primitives' (assert)-> for method in <[freeze seal preventExtensions getOwnPropertyDescriptor getPrototypeOf isExtensible isSealed isFrozen keys getOwnPropertyNames]> for value in [42 \foo no] @@ -19,16 +22,22 @@ test 'Object static methods accept primitives' (assert)-> assert.strictEqual core.Object.getPrototypeOf(\foo), String:: test 'Object.seal' (assert)!-> - {seal} = core.Object - assert.arrayEqual core.Object.getOwnPropertyNames(seal {}), [] - assert.arrayEqual core.Object.getOwnPropertySymbols(seal {}), [] + assert.arrayEqual [key for key of seal {}], [] + assert.arrayEqual keys(seal {}), [] + assert.arrayEqual getOwnPropertyNames(seal {}), [] + assert.arrayEqual getOwnPropertySymbols(seal {}), [] + assert.arrayEqual Reflect.ownKeys(seal {}), [] test 'Object.freeze' (assert)!-> - {freeze} = core.Object - assert.arrayEqual core.Object.getOwnPropertyNames(freeze {}), [] - assert.arrayEqual core.Object.getOwnPropertySymbols(freeze {}), [] + assert.arrayEqual [key for key of freeze {}], [] + assert.arrayEqual keys(freeze {}), [] + assert.arrayEqual getOwnPropertyNames(freeze {}), [] + assert.arrayEqual getOwnPropertySymbols(freeze {}), [] + assert.arrayEqual Reflect.ownKeys(freeze {}), [] test 'Object.preventExtensions' (assert)!-> - {preventExtensions} = core.Object - assert.arrayEqual core.Object.getOwnPropertyNames(preventExtensions {}), [] - assert.arrayEqual core.Object.getOwnPropertySymbols(preventExtensions {}), [] \ No newline at end of file + assert.arrayEqual [key for key of preventExtensions {}], [] + assert.arrayEqual keys(preventExtensions {}), [] + assert.arrayEqual getOwnPropertyNames(preventExtensions {}), [] + assert.arrayEqual getOwnPropertySymbols(preventExtensions {}), [] + assert.arrayEqual Reflect.ownKeys(preventExtensions {}), [] \ No newline at end of file diff --git a/tests/library/es6.set.ls b/tests/library/es6.set.ls index f10c2454e802..cdf976bfd214 100644 --- a/tests/library/es6.set.ls +++ b/tests/library/es6.set.ls @@ -43,8 +43,12 @@ test 'Set' (assert)-> assert.ok done o = {} new Set!add o + if DESCRIPTORS + assert.arrayEqual [key for key of o], [] + assert.arrayEqual core.Object.keys(o), [] assert.arrayEqual core.Object.getOwnPropertyNames(o), [] assert.arrayEqual core.Object.getOwnPropertySymbols(o), [] + assert.arrayEqual core.Reflect.ownKeys(o), [] test 'Set#add' (assert)-> assert.isFunction Set::add diff --git a/tests/library/es6.weak-map.ls b/tests/library/es6.weak-map.ls index ec0fe0d3e126..6f6b480934de 100644 --- a/tests/library/es6.weak-map.ls +++ b/tests/library/es6.weak-map.ls @@ -38,8 +38,12 @@ test 'WeakMap' (assert)!-> assert.ok done o = {} new WeakMap!set o, 1 + if DESCRIPTORS + assert.arrayEqual [key for key of o], [] + assert.arrayEqual core.Object.keys(o), [] assert.arrayEqual core.Object.getOwnPropertyNames(o), [] assert.arrayEqual core.Object.getOwnPropertySymbols(o), [] + assert.arrayEqual core.Reflect.ownKeys(o), [] test 'WeakMap#delete' (assert)!-> assert.isFunction WeakMap::delete diff --git a/tests/library/es6.weak-set.ls b/tests/library/es6.weak-set.ls index 563ef25f00a3..546f5c7c5a60 100644 --- a/tests/library/es6.weak-set.ls +++ b/tests/library/es6.weak-set.ls @@ -35,8 +35,12 @@ test 'WeakSet' (assert)!-> assert.ok done o = {} new WeakSet!add o + if DESCRIPTORS + assert.arrayEqual [key for key of o], [] + assert.arrayEqual core.Object.keys(o), [] assert.arrayEqual core.Object.getOwnPropertyNames(o), [] assert.arrayEqual core.Object.getOwnPropertySymbols(o), [] + assert.arrayEqual core.Reflect.ownKeys(o), [] test 'WeakSet#add' (assert)!-> assert.isFunction WeakSet::add diff --git a/tests/tests.js b/tests/tests.js index 0749c62aee3c..b168e34c5e3c 100644 --- a/tests/tests.js +++ b/tests/tests.js @@ -1990,7 +1990,7 @@ }; getOwnPropertyDescriptor = Object.getOwnPropertyDescriptor, freeze = Object.freeze; test('Map', function(assert){ - var x$, done, iter, a, o; + var x$, done, iter, a, o, key; assert.isFunction(Map); assert.arity(Map, 0); assert.name(Map, 'Map'); @@ -2023,8 +2023,19 @@ assert.ok(done); o = {}; new Map().set(o, 1); + if (DESCRIPTORS) { + assert.arrayEqual((function(){ + var results$ = []; + for (key in o) { + results$.push(key); + } + return results$; + }()), []); + assert.arrayEqual(Object.keys(o), []); + } assert.arrayEqual(Object.getOwnPropertyNames(o), []); - return assert.arrayEqual(Object.getOwnPropertySymbols(o), []); + assert.arrayEqual(Object.getOwnPropertySymbols(o), []); + return assert.arrayEqual(Reflect.ownKeys(o), []); }); test('Map#clear', function(assert){ var M, x$, y$, f; @@ -3479,9 +3490,10 @@ // Generated by LiveScript 1.3.1 (function(){ - var module, test, toString$ = {}.toString; + var module, test, seal, freeze, preventExtensions, keys, getOwnPropertyNames, getOwnPropertySymbols, toString$ = {}.toString; module = QUnit.module, test = QUnit.test; module('ES6'); + seal = Object.seal, freeze = Object.freeze, preventExtensions = Object.preventExtensions, keys = Object.keys, getOwnPropertyNames = Object.getOwnPropertyNames, getOwnPropertySymbols = Object.getOwnPropertySymbols; test('Object static methods accept primitives', function(assert){ var i$, ref$, len$, method, j$, ref1$, len1$, value; for (i$ = 0, len$ = (ref$ = ['freeze', 'seal', 'preventExtensions', 'getOwnPropertyDescriptor', 'getPrototypeOf', 'isExtensible', 'isSealed', 'isFrozen', 'keys', 'getOwnPropertyNames']).length; i$ < len$; ++i$) { @@ -3529,22 +3541,46 @@ } }); test('Object.seal', function(assert){ - var seal; - seal = Object.seal; - assert.arrayEqual(Object.getOwnPropertyNames(seal({})), []); - assert.arrayEqual(Object.getOwnPropertySymbols(seal({})), []); + var key; + assert.arrayEqual((function(){ + var results$ = []; + for (key in seal({})) { + results$.push(key); + } + return results$; + }()), []); + assert.arrayEqual(keys(seal({})), []); + assert.arrayEqual(getOwnPropertyNames(seal({})), []); + assert.arrayEqual(getOwnPropertySymbols(seal({})), []); + assert.arrayEqual(Reflect.ownKeys(seal({})), []); }); test('Object.freeze', function(assert){ - var freeze; - freeze = Object.freeze; - assert.arrayEqual(Object.getOwnPropertyNames(freeze({})), []); - assert.arrayEqual(Object.getOwnPropertySymbols(freeze({})), []); + var key; + assert.arrayEqual((function(){ + var results$ = []; + for (key in freeze({})) { + results$.push(key); + } + return results$; + }()), []); + assert.arrayEqual(keys(freeze({})), []); + assert.arrayEqual(getOwnPropertyNames(freeze({})), []); + assert.arrayEqual(getOwnPropertySymbols(freeze({})), []); + assert.arrayEqual(Reflect.ownKeys(freeze({})), []); }); test('Object.preventExtensions', function(assert){ - var preventExtensions; - preventExtensions = Object.preventExtensions; - assert.arrayEqual(Object.getOwnPropertyNames(preventExtensions({})), []); - assert.arrayEqual(Object.getOwnPropertySymbols(preventExtensions({})), []); + var key; + assert.arrayEqual((function(){ + var results$ = []; + for (key in preventExtensions({})) { + results$.push(key); + } + return results$; + }()), []); + assert.arrayEqual(keys(preventExtensions({})), []); + assert.arrayEqual(getOwnPropertyNames(preventExtensions({})), []); + assert.arrayEqual(getOwnPropertySymbols(preventExtensions({})), []); + assert.arrayEqual(Reflect.ownKeys(preventExtensions({})), []); }); }).call(this); @@ -5620,7 +5656,7 @@ }; getOwnPropertyDescriptor = Object.getOwnPropertyDescriptor, freeze = Object.freeze; test('Set', function(assert){ - var x$, y$, S, r, z$, z1$, done, iter, _add, a, o; + var x$, y$, S, r, z$, z1$, done, iter, _add, a, o, key; assert.isFunction(Set); assert.name(Set, 'Set'); assert.arity(Set, 0); @@ -5673,8 +5709,19 @@ assert.ok(done); o = {}; new Set().add(o); + if (DESCRIPTORS) { + assert.arrayEqual((function(){ + var results$ = []; + for (key in o) { + results$.push(key); + } + return results$; + }()), []); + assert.arrayEqual(Object.keys(o), []); + } assert.arrayEqual(Object.getOwnPropertyNames(o), []); - return assert.arrayEqual(Object.getOwnPropertySymbols(o), []); + assert.arrayEqual(Object.getOwnPropertySymbols(o), []); + return assert.arrayEqual(Reflect.ownKeys(o), []); }); test('Set#add', function(assert){ var a, x$, S, chain, y$, f; @@ -6920,7 +6967,7 @@ module('ES6'); freeze = Object.freeze; test('WeakMap', function(assert){ - var a, x$, f, M, done, iter, o; + var a, x$, f, M, done, iter, o, key; assert.isFunction(WeakMap); assert.name(WeakMap, 'WeakMap'); assert.arity(WeakMap, 0); @@ -6960,8 +7007,19 @@ assert.ok(done); o = {}; new WeakMap().set(o, 1); + if (DESCRIPTORS) { + assert.arrayEqual((function(){ + var results$ = []; + for (key in o) { + results$.push(key); + } + return results$; + }()), []); + assert.arrayEqual(Object.keys(o), []); + } assert.arrayEqual(Object.getOwnPropertyNames(o), []); assert.arrayEqual(Object.getOwnPropertySymbols(o), []); + assert.arrayEqual(Reflect.ownKeys(o), []); }); test('WeakMap#delete', function(assert){ var x$, M, a, b; @@ -7048,7 +7106,7 @@ module('ES6'); freeze = Object.freeze; test('WeakSet', function(assert){ - var a, x$, f, S, done, iter, o; + var a, x$, f, S, done, iter, o, key; assert.isFunction(WeakSet); assert.name(WeakSet, 'WeakSet'); assert.arity(WeakSet, 0); @@ -7085,8 +7143,19 @@ assert.ok(done); o = {}; new WeakSet().add(o); + if (DESCRIPTORS) { + assert.arrayEqual((function(){ + var results$ = []; + for (key in o) { + results$.push(key); + } + return results$; + }()), []); + assert.arrayEqual(Object.keys(o), []); + } assert.arrayEqual(Object.getOwnPropertyNames(o), []); assert.arrayEqual(Object.getOwnPropertySymbols(o), []); + assert.arrayEqual(Reflect.ownKeys(o), []); }); test('WeakSet#add', function(assert){ var a, e, wset; diff --git a/tests/tests/es6.map.ls b/tests/tests/es6.map.ls index 515088c07f28..10c6865c3558 100644 --- a/tests/tests/es6.map.ls +++ b/tests/tests/es6.map.ls @@ -35,8 +35,12 @@ test 'Map' (assert)-> assert.ok done o = {} new Map!set o, 1 + if DESCRIPTORS + assert.arrayEqual [key for key of o], [] + assert.arrayEqual Object.keys(o), [] assert.arrayEqual Object.getOwnPropertyNames(o), [] assert.arrayEqual Object.getOwnPropertySymbols(o), [] + assert.arrayEqual Reflect.ownKeys(o), [] test 'Map#clear' (assert)-> assert.isFunction Map::clear diff --git a/tests/tests/es6.object.statics-accept-primitives.ls b/tests/tests/es6.object.statics-accept-primitives.ls index fc8d78f05e79..d2638a37fb2f 100644 --- a/tests/tests/es6.object.statics-accept-primitives.ls +++ b/tests/tests/es6.object.statics-accept-primitives.ls @@ -1,6 +1,8 @@ {module, test} = QUnit module \ES6 +{seal, freeze, preventExtensions, keys, getOwnPropertyNames, getOwnPropertySymbols} = Object + test 'Object static methods accept primitives' (assert)-> for method in <[freeze seal preventExtensions getOwnPropertyDescriptor getPrototypeOf isExtensible isSealed isFrozen keys getOwnPropertyNames]> assert.ok /native code/.test(Object[method]), "Object.#method looks like native" @@ -20,16 +22,22 @@ test 'Object static methods accept primitives' (assert)-> assert.strictEqual Object.getPrototypeOf(\foo), String:: test 'Object.seal' (assert)!-> - {seal} = Object - assert.arrayEqual Object.getOwnPropertyNames(seal {}), [] - assert.arrayEqual Object.getOwnPropertySymbols(seal {}), [] + assert.arrayEqual [key for key of seal {}], [] + assert.arrayEqual keys(seal {}), [] + assert.arrayEqual getOwnPropertyNames(seal {}), [] + assert.arrayEqual getOwnPropertySymbols(seal {}), [] + assert.arrayEqual Reflect.ownKeys(seal {}), [] test 'Object.freeze' (assert)!-> - {freeze} = Object - assert.arrayEqual Object.getOwnPropertyNames(freeze {}), [] - assert.arrayEqual Object.getOwnPropertySymbols(freeze {}), [] + assert.arrayEqual [key for key of freeze {}], [] + assert.arrayEqual keys(freeze {}), [] + assert.arrayEqual getOwnPropertyNames(freeze {}), [] + assert.arrayEqual getOwnPropertySymbols(freeze {}), [] + assert.arrayEqual Reflect.ownKeys(freeze {}), [] test 'Object.preventExtensions' (assert)!-> - {preventExtensions} = Object - assert.arrayEqual Object.getOwnPropertyNames(preventExtensions {}), [] - assert.arrayEqual Object.getOwnPropertySymbols(preventExtensions {}), [] \ No newline at end of file + assert.arrayEqual [key for key of preventExtensions {}], [] + assert.arrayEqual keys(preventExtensions {}), [] + assert.arrayEqual getOwnPropertyNames(preventExtensions {}), [] + assert.arrayEqual getOwnPropertySymbols(preventExtensions {}), [] + assert.arrayEqual Reflect.ownKeys(preventExtensions {}), [] \ No newline at end of file diff --git a/tests/tests/es6.set.ls b/tests/tests/es6.set.ls index 406733c01f80..05809b7bfbc2 100644 --- a/tests/tests/es6.set.ls +++ b/tests/tests/es6.set.ls @@ -56,8 +56,12 @@ test 'Set' (assert)-> assert.ok done o = {} new Set!add o + if DESCRIPTORS + assert.arrayEqual [key for key of o], [] + assert.arrayEqual Object.keys(o), [] assert.arrayEqual Object.getOwnPropertyNames(o), [] assert.arrayEqual Object.getOwnPropertySymbols(o), [] + assert.arrayEqual Reflect.ownKeys(o), [] test 'Set#add' (assert)-> assert.isFunction Set::add diff --git a/tests/tests/es6.weak-map.ls b/tests/tests/es6.weak-map.ls index 2856bcec2012..65df4739334a 100644 --- a/tests/tests/es6.weak-map.ls +++ b/tests/tests/es6.weak-map.ls @@ -40,8 +40,12 @@ test 'WeakMap' (assert)!-> assert.ok done o = {} new WeakMap!set o, 1 + if DESCRIPTORS + assert.arrayEqual [key for key of o], [] + assert.arrayEqual Object.keys(o), [] assert.arrayEqual Object.getOwnPropertyNames(o), [] assert.arrayEqual Object.getOwnPropertySymbols(o), [] + assert.arrayEqual Reflect.ownKeys(o), [] test 'WeakMap#delete' (assert)!-> assert.isFunction WeakMap::delete diff --git a/tests/tests/es6.weak-set.ls b/tests/tests/es6.weak-set.ls index aae308f1bd78..dbc3c6a4b989 100644 --- a/tests/tests/es6.weak-set.ls +++ b/tests/tests/es6.weak-set.ls @@ -37,8 +37,12 @@ test 'WeakSet' (assert)!-> assert.ok done o = {} new WeakSet!add o + if DESCRIPTORS + assert.arrayEqual [key for key of o], [] + assert.arrayEqual Object.keys(o), [] assert.arrayEqual Object.getOwnPropertyNames(o), [] assert.arrayEqual Object.getOwnPropertySymbols(o), [] + assert.arrayEqual Reflect.ownKeys(o), [] test 'WeakSet#add' (assert)!-> assert.isFunction WeakSet::add