MIRROR: javascript for 馃悳's, a tiny runtime with big ambitions
1import { test, summary } from './helpers.js';
2
3console.log('Typeof Tests\n');
4
5test('typeof number', typeof 42, 'number');
6test('typeof float', typeof 3.14, 'number');
7test('typeof NaN', typeof NaN, 'number');
8test('typeof Infinity', typeof Infinity, 'number');
9test('typeof bigint', typeof 123n, 'bigint');
10
11test('typeof string', typeof 'hello', 'string');
12test('typeof empty string', typeof '', 'string');
13test('typeof template', typeof `template`, 'string');
14
15test('typeof boolean true', typeof true, 'boolean');
16test('typeof boolean false', typeof false, 'boolean');
17
18test('typeof undefined', typeof undefined, 'undefined');
19test('typeof undeclared', typeof undeclaredVar, 'undefined');
20
21test('typeof null', typeof null, 'object');
22
23test('typeof object', typeof {}, 'object');
24test('typeof array', typeof [], 'object');
25test('typeof date', typeof new Date(), 'object');
26test('typeof regexp', typeof /test/, 'object');
27
28test('typeof function', typeof function () {}, 'function');
29test('typeof arrow', typeof (() => {}), 'function');
30test('typeof class', typeof class {}, 'function');
31test('typeof symbol', typeof Symbol('test'), 'symbol');
32
33summary();