Sha256: 47bdd49a040ffe6ab6257c0c40b63a9c260436e0af62d388976f3f3828b63fba

Contents?: true

Size: 1.48 KB

Versions: 53

Compression:

Stored size: 1.48 KB

Contents

'use strict';

var aFrom       = require('es5-ext/array/from')
  , getIterator = require('es6-iterator/get')
  , toArray     = require('es5-ext/array/to-array');

module.exports = function (T, a) {
	var arr = ['raz', 'dwa', 'trzy'], set = new T(arr), x = 'other', y = 'other2'
	  , i = 0, result = [];

	a(set instanceof T, true, "Set");
	a(set.size, 3, "Size");
	a(set.has('raz'), true, "Has: true");
	a(set.has(x), false, "Has: false");
	a(set.add(x), set, "Add: return");
	a(set.has(x), true, "Add");
	a(set.size, 4, "Add: Size");
	a(set.delete('else'), false, "Delete: false");
	a(set.get('raz'), 'raz', "Get");

	arr.push(x);
	set.forEach(function () {
		result.push(aFrom(arguments));
		a(this, y, "ForEach: Context: #" + i);
	}, y);

	a.deep(result.sort(function (a, b) {
		return a[0].localeCompare(b[0]);
	}), arr.sort().map(function (val) { return [val, val, set]; }));

	a.deep(toArray(set.entries()).sort(), [['dwa', 'dwa'], ['trzy', 'trzy'],
		[x, x], ['raz', 'raz']].sort(), "Entries");
	a.deep(toArray(set.keys()).sort(), ['dwa', 'trzy', x, 'raz'].sort(),
		"Keys");
	a.deep(toArray(set.values()).sort(), ['dwa', 'trzy', x, 'raz'].sort(),
		"Values");
	a.deep(toArray(getIterator(set)).sort(), ['dwa', 'trzy', x, 'raz'].sort(),
		"Iterator");

	set.clear();
	a(set.size, 0, "Clear: size");
	a(set.has('trzy'), false, "Clear: has");
	a.deep(toArray(set.values()), [], "Clear: Values");

	a.h1("Empty initialization");
	set = new T();
	set.add('foo');
	a(set.size, 1);
	a(set.has('foo'), true);
};

Version data entries

53 entries across 53 versions & 7 rubygems

Version Path
govuk_publishing_components-18.0.0 node_modules/es6-set/test/primitive/index.js
govuk_publishing_components-17.21.0 node_modules/es6-set/test/primitive/index.js
govuk_publishing_components-17.20.0 node_modules/es6-set/test/primitive/index.js
govuk_publishing_components-17.19.1 node_modules/es6-set/test/primitive/index.js
govuk_publishing_components-17.19.0 node_modules/es6-set/test/primitive/index.js
govuk_publishing_components-17.18.0 node_modules/es6-set/test/primitive/index.js
govuk_publishing_components-17.17.0 node_modules/es6-set/test/primitive/index.js
govuk_publishing_components-17.16.0 node_modules/es6-set/test/primitive/index.js
govuk_publishing_components-17.15.0 node_modules/es6-set/test/primitive/index.js
govuk_publishing_components-17.14.0 node_modules/es6-set/test/primitive/index.js
govuk_publishing_components-17.13.0 node_modules/es6-set/test/primitive/index.js
govuk_publishing_components-17.12.2 node_modules/es6-set/test/primitive/index.js
govuk_publishing_components-17.12.1 node_modules/es6-set/test/primitive/index.js
govuk_publishing_components-17.12.0 node_modules/es6-set/test/primitive/index.js
govuk_publishing_components-17.11.0 node_modules/es6-set/test/primitive/index.js
govuk_publishing_components-17.10.0 node_modules/es6-set/test/primitive/index.js
govuk_publishing_components-17.9.0 node_modules/es6-set/test/primitive/index.js
govuk_publishing_components-17.8.0 node_modules/es6-set/test/primitive/index.js
govuk_publishing_components-17.7.0 node_modules/es6-set/test/primitive/index.js
govuk_publishing_components-17.6.1 node_modules/es6-set/test/primitive/index.js