'use strict';

var d = require('d')

  , create = Object.create, setPrototypeOf = Object.setPrototypeOf;

module.exports = function () {
	var map, iterator, result, SubMap;
	if (typeof Map !== 'function') return false;
	if (String(Map.prototype) !== '[object Map]') return false;
	try {
		// WebKit doesn't support arguments and crashes
		map = new Map([['raz', 'one'], ['dwa', 'two'], ['trzy', 'three']]);
	} catch (e) {
		return false;
	}
	if (map.size !== 3) return false;
	if (typeof map.clear !== 'function') return false;
	if (typeof map.delete !== 'function') return false;
	if (typeof map.entries !== 'function') return false;
	if (typeof map.forEach !== 'function') return false;
	if (typeof map.get !== 'function') return false;
	if (typeof map.has !== 'function') return false;
	if (typeof map.keys !== 'function') return false;
	if (typeof map.set !== 'function') return false;
	if (typeof map.values !== 'function') return false;

	iterator = map.entries();
	result = iterator.next();
	if (result.done !== false) return false;
	if (!result.value) return false;
	if (result.value[0] !== 'raz') return false;
	if (result.value[1] !== 'one') return false;

	// Non new call
	try { map = Map([[1, 2], [2, 3], [3, 4]]); } catch (e) { return false; } //jslint: ignore

	if (!map) return false;
	if (map.size !== 3) return false;

	// Extendable
	if (setPrototypeOf) {
		SubMap = function () { Map.apply(this, arguments); };
		setPrototypeOf(SubMap, Map);
		SubMap.prototype = create(Map.prototype, { constructor: d(SubMap) });
		try { map = new SubMap([[1, 2], [2, 3], [3, 4]]); } catch (e) { return false; }
		try {
			if (map.size !== 3) return false;
		} catch (e) { return false; }
	}
	return true;
};

'use strict';

var d = require('d')

  , create = Object.create, setPrototypeOf = Object.setPrototypeOf;

module.exports = function () {
	var map, iterator, result, SubMap;
	if (typeof Map !== 'function') return false;
	if (String(Map.prototype) !== '[object Map]') return false;
	try {
		// WebKit doesn't support arguments and crashes
		map = new Map([['raz', 'one'], ['dwa', 'two'], ['trzy', 'three']]);
	} catch (e) {
		return false;
	}
	if (map.size !== 3) return false;
	if (typeof map.clear !== 'function') return false;
	if (typeof map.delete !== 'function') return false;
	if (typeof map.entries !== 'function') return false;
	if (typeof map.forEach !== 'function') return false;
	if (typeof map.get !== 'function') return false;
	if (typeof map.has !== 'function') return false;
	if (typeof map.keys !== 'function') return false;
	if (typeof map.set !== 'function') return false;
	if (typeof map.values !== 'function') return false;

	iterator = map.entries();
	result = iterator.next();
	if (result.done !== false) return false;
	if (!result.value) return false;
	if (result.value[0] !== 'raz') return false;
	if (result.value[1] !== 'one') return false;

	if (!map) return false;
	if (map.size !== 3) return false;

	// Extendable
	if (setPrototypeOf) {
		SubMap = function () { Map.apply(this, arguments); };
		setPrototypeOf(SubMap, Map);
		SubMap.prototype = create(Map.prototype, { constructor: d(SubMap) });
		try { map = new SubMap([[1, 2], [2, 3], [3, 4]]); } catch (e) { return false; }
		try {
			if (map.size !== 3) return false;
		} catch (e) { return false; }
	}
	return true;
};

Remove invalid constructor test