michael@0: /* This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: 'use strict'; michael@0: michael@0: const { merge, extend, has, each } = require('sdk/util/object'); michael@0: michael@0: let o = { michael@0: 'paper': 0, michael@0: 'rock': 1, michael@0: 'scissors': 2 michael@0: }; michael@0: michael@0: //exports.testMerge = function(assert) {} michael@0: //exports.testExtend = function(assert) {} michael@0: michael@0: exports.testHas = function(assert) { michael@0: assert.equal(has(o, 'paper'), true, 'has correctly finds key'); michael@0: assert.equal(has(o, 'rock'), true, 'has correctly finds key'); michael@0: assert.equal(has(o, 'scissors'), true, 'has correctly finds key'); michael@0: assert.equal(has(o, 'nope'), false, 'has correctly does not find key'); michael@0: assert.equal(has(o, '__proto__'), false, 'has correctly does not find key'); michael@0: assert.equal(has(o, 'isPrototypeOf'), false, 'has correctly does not find key'); michael@0: }; michael@0: michael@0: exports.testEach = function(assert) { michael@0: var keys = new Set(); michael@0: each(o, function (value, key, object) { michael@0: keys.add(key); michael@0: assert.equal(o[key], value, 'Key and value pairs passed in'); michael@0: assert.equal(o, object, 'Object passed in'); michael@0: }); michael@0: assert.equal(keys.size, 3, 'All keys have been iterated upon'); michael@0: }; michael@0: michael@0: require('sdk/test').run(exports);