| 1 |
/* jscs:disable requireUseStrict */ |
| 2 |
/* eslint strict: 0, max-statements: 0 */ |
| 3 |
|
| 4 |
module.exports = function (theGlobal, t) { |
| 5 |
t.equal(typeof theGlobal, 'object', 'is an object'); |
| 6 |
|
| 7 |
t.test('built-in globals', function (st) { |
| 8 |
st.equal(theGlobal.Math, Math, 'Math is on the global'); |
| 9 |
st.equal(theGlobal.JSON, JSON, 'JSON is on the global'); |
| 10 |
st.equal(theGlobal.String, String, 'String is on the global'); |
| 11 |
st.equal(theGlobal.Array, Array, 'Array is on the global'); |
| 12 |
st.equal(theGlobal.Number, Number, 'Number is on the global'); |
| 13 |
st.equal(theGlobal.Boolean, Boolean, 'Boolean is on the global'); |
| 14 |
st.equal(theGlobal.Object, Object, 'Object is on the global'); |
| 15 |
st.equal(theGlobal.Function, Function, 'Function is on the global'); |
| 16 |
st.equal(theGlobal.Date, Date, 'Date is on the global'); |
| 17 |
st.equal(theGlobal.RegExp, RegExp, 'RegExp is on the global'); |
| 18 |
|
| 19 |
if (typeof Symbol === 'undefined') { |
| 20 |
st.comment('# SKIP Symbol is not supported'); |
| 21 |
} else { |
| 22 |
st.equal(theGlobal.Symbol, Symbol, 'Symbol is on the global'); |
| 23 |
} |
| 24 |
st.end(); |
| 25 |
}); |
| 26 |
|
| 27 |
t.test('custom property', function (st) { |
| 28 |
var key = 'random_custom_key_' + new Date().getTime(); |
| 29 |
var semaphore = {}; |
| 30 |
/* eslint no-eval: 1 */ |
| 31 |
eval(key + ' = semaphore;'); |
| 32 |
st.equal(theGlobal[key], semaphore, 'global variable ends up on the global object'); |
| 33 |
delete theGlobal[key]; |
| 34 |
st.end(); |
| 35 |
}); |
| 36 |
}; |