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