<commit_before>/* eslint-env mocha, browser */
/* global proclaim */

// Modified version of the test262 tests located at
// https://github.com/tc39/test262/tree/master/test/built-ins/Object/entries
// Copyright (C) 2015 <NAME>. All rights reserved.
// This code is governed by the BSD license.

var arePropertyDescriptorsSupported = function() {
	var obj = {};
	try {
		Object.defineProperty(obj, 'x', {
			enumerable: false,
			value: obj
		});
		/* eslint-disable no-unused-vars, no-restricted-syntax */
		for (var _ in obj) {
			return false;
		}
		/* eslint-enable no-unused-vars, no-restricted-syntax */
		return obj.x === obj;
	} catch (e) { // this is IE 8.
		return false;
	}
};

var supportsDescriptors = Object.defineProperty && arePropertyDescriptorsSupported();

var functionsHaveNames = (function foo() {}).name === 'foo';

var hasSymbols = typeof Symbol === 'function' && typeof Symbol() === 'symbol';

var objectKeysWorksWithPrimitives = (function() {
	try {
		return Object.keys(2) === undefined;
	} catch (e) {
		return false;
	}
}());

it('should have name `entries`', function() {
	if (functionsHaveNames) {
		proclaim.equal(Object.entries.name, 'entries');
	} else {
		this.skip();
	}
});

it('has length `1`', function() {
	proclaim.equal(Object.entries.length, 1);
});

it('should terminate if getting a value throws an exception', function() {
	proclaim.throws(function() {
		Object.entries({
			get a() {
				throw new Error('This is the thrown error');
			},
			get b() {
				throw new Error();
			}
		});
	}, Error, 'This is the thrown error');
});

it('should throw TypeError when called with `null`', function() {
	proclaim.throws(function() {
		Object.entries(null);
	}, TypeError);
});

it('should throw TypeError when called with `undefined`', function() {
	proclaim.throws(function() {
		Object.entries(undefined);
	}, TypeError);
});

it('does not see a new element added by a getter that is hit during iteration', function() {
	var bAddsC = {
		a: 'A',
		get b() {
			this.c = 'C';
			return 'B';
		}
	};

	var result = Object.entries(bAddsC);

	proclaim.isArray(result, 'result is an array');
	proclaim.equal(result.length, 2, 'result has 2 items');

	proclaim.isArray(result[0], 'first entry is an array');
	proclaim.isArray(result[1], 'second entry is an array');

	proclaim.deepEqual(result, [
		['a', 'A'],
		['b', 'B']
	]);
});

it('does not see an element made non-enumerable by a getter that is hit during iteration', function() {
	if (supportsDescriptors) {

		var bDeletesC = {
			a: 'A',
			get b() {
				Object.defineProperty(this, 'c', {
					enumerable: false
				});
				return 'B';
			},
			c: 'C'
		};

		var result = Object.entries(bDeletesC);

		proclaim.isArray(result, 'result is an array');
		proclaim.equal(result.length, 2, 'result has 2 items');

		proclaim.isArray(result[0], 'first entry is an array');
		proclaim.isArray(result[1], 'second entry is an array');

		proclaim.deepEqual(result, [
			['a', 'A'],
			['b', 'B']
		]);
	} else {
		this.skip();
	}
});

it('does not see an element removed by a getter that is hit during iteration', function() {

	var bDeletesC = {
		a: 'A',
		get b() {
			delete this.c;
			return 'B';
		},
		c: 'C'
	};

	var result = Object.entries(bDeletesC);

	proclaim.isArray(result, 'result is an array');
	proclaim.equal(result.length, 2, 'result has 2 items');

	proclaim.isArray(result[0], 'first entry is an array');
	proclaim.isArray(result[1], 'second entry is an array');

	proclaim.deepEqual(result, [
		['a', 'A'],
		['b', 'B']
	]);
});
<commit_msg>Make Object.entries tests use ES3 syntax to enable them to run in ES3 environments (#1508)<commit_after>/* eslint-env mocha, browser */
/* global proclaim */

// Modified version of the test262 tests located at
// https://github.com/tc39/test262/tree/master/test/built-ins/Object/entries
// Copyright (C) 2015 <NAME>. All rights reserved.
// This code is governed by the BSD license.

var arePropertyDescriptorsSupported = function() {
	var obj = {};
	try {
		Object.defineProperty(obj, 'x', {
			enumerable: false,
			value: obj
		});
		/* eslint-disable no-unused-vars, no-restricted-syntax */
		for (var _ in obj) {
			return false;
		}
		/* eslint-enable no-unused-vars, no-restricted-syntax */
		return obj.x === obj;
	} catch (e) { // this is IE 8.
		return false;
	}
};

var supportsDescriptors = Object.defineProperty && arePropertyDescriptorsSupported();

var functionsHaveNames = (function foo() {}).name === 'foo';

var hasSymbols = typeof Symbol === 'function' && typeof Symbol() === 'symbol';

var objectKeysWorksWithPrimitives = (function() {
	try {
		return Object.keys(2) === undefined;
	} catch (e) {
		return false;
	}
}());

it('should have name `entries`', function() {
	if (functionsHaveNames) {
		proclaim.equal(Object.entries.name, 'entries');
	} else {
		this.skip();
	}
});

it('has length `1`', function() {
	proclaim.equal(Object.entries.length, 1);
});

if (supportsDescriptors) {
	it('should terminate if getting a value throws an exception', function () {
		proclaim.throws(function () {
			var obj = {};
			Object.defineProperty(obj, 'a', {
				enumerable: true,
				get: function () {
					throw new Error('This is the thrown error');
				}
			});
			Object.defineProperty(obj, 'b', {
				enumerable: true,
				get: function () {
					throw new Error();
				}
			});
			Object.entries(obj);
		}, Error, 'This is the thrown error');
	});
}

it('should throw TypeError when called with `null`', function() {
	proclaim.throws(function() {
		Object.entries(null);
	}, TypeError);
});

it('should throw TypeError when called with `undefined`', function() {
	proclaim.throws(function() {
		Object.entries(undefined);
	}, TypeError);
});

if (supportsDescriptors) {
	it('does not see a new element added by a getter that is hit during iteration', function () {
		var bAddsC = {
			a: 'A'
		};
		Object.defineProperty(bAddsC, 'b', {
			enumerable: true,
			get: function () {
				this.c = 'C';
				return 'B';
			}
		});

		var result = Object.entries(bAddsC);

		proclaim.isArray(result, 'result is an array');
		proclaim.equal(result.length, 2);

		proclaim.isArray(result[0], 'first entry is an array');
		proclaim.isArray(result[1], 'second entry is an array');

		proclaim.deepEqual(result, [
			['a', 'A'],
			['b', 'B']
		]);
	});

	it('does not see an element made non-enumerable by a getter that is hit during iteration', function () {
		var bHidesC = {
			a: 'A'
		};
		Object.defineProperty(bHidesC, 'b', {
			enumerable: true,
			get: function () {
				Object.defineProperty(this, 'c', {
					enumerable: false
				});
				return 'B';
			}
		});
		bHidesC.c = 'C';

		var result = Object.entries(bHidesC);

		proclaim.isArray(result, 'result is an array');
		proclaim.equal(result.length, 2, 'result has 2 items');

		proclaim.isArray(result[0], 'first entry is an array');
		proclaim.isArray(result[1], 'second entry is an array');

		proclaim.deepEqual(result, [
			['a', 'A'],
			['b', 'B']
		]);
	});

	it('does not see an element removed by a getter that is hit during iteration', function () {
		var bDeletesC = {
			a: 'A'
		};
		Object.defineProperty(bDeletesC, 'b', {
			enumerable: true,
			get: function () {
				delete this.c;
				return 'B';
			}
		});
		bDeletesC.c = 'C';

		var result = Object.entries(bDeletesC);

		proclaim.isArray(result, 'result is an array');
		proclaim.equal(result.length, 2, 'result has 2 items');

		proclaim.isArray(result[0], 'first entry is an array');
		proclaim.isArray(result[1], 'second entry is an array');

		proclaim.deepEqual(result, [
			['a', 'A'],
			['b', 'B']
		]);
	});
}

{'fraction_non_alphanumeric': 0.16719160104986877, 'fraction_numerical': 0.008005249343832021, 'mean_word_length': 3.6020531400966185, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3931784', 'n_tokens_mistral': 2897, 'n_tokens_neox': 2579, 'n_words': 722}