<commit_before>var test = require('tape');
var assign = require('../');
var hasSymbols = require('../hasSymbols')();

test('error cases', function (t) {
	t.throws(function () { assign(null); }, TypeError, 'target must be an object');
	t.end();<commit_msg>Adding `Object.assign` tests for non-object targets, per https://github.com/paulmillr/es6-shim/issues/348<commit_after>var test = require('tape');
var assign = require('../');
var hasSymbols = require('../hasSymbols')();

test('error cases', function (t) {
	t.throws(function () { assign(null); }, TypeError, 'target must be an object');
	t.throws(function () { assign(undefined); }, TypeError, 'target must be an object');
	t.throws(function () { assign(null, {}); }, TypeError, 'target must be an object');
	t.throws(function () { assign(undefined, {}); }, TypeError, 'target must be an object');
	t.end();
});

test('non-object target, no sources', function (t) {
	var bool = assign(true);
	t.equal(typeof bool, 'object', 'bool is object');
	t.equal(Boolean.prototype.valueOf.call(bool), true, 'bool coerces to `true`');

	var number = assign(1);
	t.equal(typeof number, 'object', 'number is object');
	t.equal(Number.prototype.valueOf.call(number), 1, 'number coerces to `1`');

	var string = assign('1');
	t.equal(typeof string, 'object', 'number is object');
	t.equal(String.prototype.valueOf.call(string), '1', 'number coerces to `"1"`');

	t.end();
});

test('non-object target, with sources', function (t) {
	var signal = {};
	var bool = assign(true, { a: signal });
	t.equal(typeof bool, 'object', 'bool is object');
	t.equal(Boolean.prototype.valueOf.call(bool), true, 'bool coerces to `true`');
	t.equal(bool.a, signal, 'source properties copied');

	var number = assign(1, { a: signal });
	t.equal(typeof number, 'object', 'number is object');
	t.equal(Number.prototype.valueOf.call(number), 1, 'number coerces to `1`');
	t.equal(number.a, signal, 'source properties copied');

	var string = assign('1', { a: signal });
	t.equal(typeof string, 'object', 'number is object');
	t.equal(String.prototype.valueOf.call(string), '1', 'number coerces to `"1"`');
	t.equal(string.a, signal, 'source properties copied');

	t.end();
{'fraction_non_alphanumeric': 0.19908675799086759, 'fraction_numerical': 0.0073059360730593605, 'mean_word_length': 5.1892655367231635, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 1, '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': '5471786', 'n_tokens_mistral': 731, 'n_tokens_neox': 719, 'n_words': 201}