You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

29 lines
583 B

5 years ago
export const tests = []
const isConst = (name) => {
try {
eval(`${name} = 'm'`)
return false
} catch (err) {
return true
}
}
5 years ago
const t = (f) => tests.push(f)
5 years ago
// str is declared and of type string
t(() => typeof str === 'string')
// num is declared and of type number
t(() => typeof num === 'number')
// bool is declared and of type boolean
t(() => typeof bool === 'boolean')
// undef is declared and of type undefined
t(() => undef === undefined)
// check if all variables are const
t(() => ['str', 'num', 'bool', 'undef']
.every(isConst))
5 years ago
Object.freeze(tests)