'use strict';

var test = require('tape');
var debug = require('object-inspect');
var forEach = require('foreach');

var v = require('./values');
var getSymbolDescription = require('../../helpers/getSymbolDescription');
var getInferredName = require('../../helpers/getInferredName');

test('getSymbolDescription', function (t) {
	t.test('no symbols', { skip: v.hasSymbols }, function (st) {
		st['throws'](
			getSymbolDescription,
			SyntaxError,
			'requires Symbol support'
		);

		st.end();
	});

	forEach(v.nonSymbolPrimitives.concat(v.objects), function (nonSymbol) {
		t['throws'](
			function () { getSymbolDescription(nonSymbol); },
			v.hasSymbols ? TypeError : SyntaxError,
			debug(nonSymbol) + ' is not a Symbol'
		);
	});

	t.test('with symbols', { skip: !v.hasSymbols }, function (st) {
		forEach(
			[
				[Symbol(), undefined],
				[Symbol(undefined), undefined],
				[Symbol(null), 'null'],
				[Symbol.iterator, 'Symbol.iterator'],
				[Symbol('foo'), 'foo']
			],
			function (pair) {
				var sym = pair[0];
				var desc = pair[1];
				st.equal(getSymbolDescription(sym), desc, debug(sym) + ' yields ' + debug(desc));
			}
		);

		st.test('only possible when inference is supported', { skip: !getInferredName }, function (s2t) {
			s2t.equal(getSymbolDescription(Symbol('')), '', 'Symbol("") description is empty string');
			s2t.end();
		});

		st.end();
	});

	t.end();
});

@@ -108,16 +108,42 @@
 reach');
+%0Avar has = require('has');
 %0A%0Avar v 
@@ -1136,13 +1136,21 @@
 + ' 
-yield
+description i
 s ' 
@@ -1215,16 +1215,57 @@
 nference
+ or native %60Symbol.prototype.description%60
  is supp
@@ -1269,25 +1269,28 @@
 upported', %7B
- 
+%0A%09%09%09
 skip: !getIn
@@ -1300,16 +1300,59 @@
 redName 
+&& !has(Symbol.prototype, 'description')%0A%09%09
 %7D, funct
@@ -1445,20 +1445,322 @@
  is 
-empty string
+%22%22');%0A%09%09%09s2t.end();%0A%09%09%7D);%0A%0A%09%09st.test('only possible when global symbols are supported', %7B%0A%09%09%09skip: !has(Symbol, 'for') %7C%7C !has(Symbol, 'keyFor')%0A%09%09%7D, function (s2t) %7B%0A%09%09%09// eslint-disable-next-line no-restricted-properties%0A%09%09%09s2t.equal(getSymbolDescription(Symbol%5B'for'%5D('')), '', 'Symbol.for(%22%22) description is %22%22
 ');%0A

add test cases