MIRROR: javascript for ๐Ÿœ's, a tiny runtime with big ambitions
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

spec: add process and ant tests

+101
+71
examples/spec/ant.js
··· 1 + import { test, summary } from './helpers.js'; 2 + 3 + console.log('Ant Global Tests\n'); 4 + 5 + test('Ant exists', typeof Ant, 'object'); 6 + test('version is string', typeof Ant.version, 'string'); 7 + test('version format', /^\d+\.\d+\.\d+/.test(Ant.version), true); 8 + test('target is string', typeof Ant.target, 'string'); 9 + test('target not empty', Ant.target.length > 0, true); 10 + test('revision is string', typeof Ant.revision, 'string'); 11 + test('buildDate is string', typeof Ant.buildDate, 'string'); 12 + test('host is string', typeof Ant.host, 'string'); 13 + 14 + const validHosts = [ 15 + 'cygwin', 16 + 'darwin', 17 + 'dragonfly', 18 + 'emscripten', 19 + 'freebsd', 20 + 'gnu', 21 + 'haiku', 22 + 'linux', 23 + 'netbsd', 24 + 'openbsd', 25 + 'windows', 26 + 'sunos', 27 + 'os/2' 28 + ]; 29 + 30 + test('host is valid', validHosts.includes(Ant.host), true); 31 + 32 + test('typeof is function', typeof Ant.typeof, 'function'); 33 + test('typeof number', Ant.typeof(42), 'number'); 34 + test('typeof string', Ant.typeof('hello'), 'string'); 35 + test('typeof object', Ant.typeof({}), 'object'); 36 + test('typeof array', Ant.typeof([]), 'array'); 37 + 38 + test( 39 + 'typeof function', 40 + Ant.typeof(() => {}), 41 + 'function' 42 + ); 43 + 44 + test('typeof null', Ant.typeof(null), 'null'); 45 + test('typeof undefined', Ant.typeof(undefined), 'undefined'); 46 + test('typeof boolean', Ant.typeof(true), 'boolean'); 47 + 48 + test('gc is function', typeof Ant.gc, 'function'); 49 + const gcResult = Ant.gc(); 50 + test('gc returns object', typeof gcResult, 'object'); 51 + test('gc has heapBefore', typeof gcResult.heapBefore, 'number'); 52 + test('gc has heapAfter', typeof gcResult.heapAfter, 'number'); 53 + test('gc has freed', typeof gcResult.freed, 'number'); 54 + 55 + test('alloc is function', typeof Ant.alloc, 'function'); 56 + const allocResult = Ant.alloc(); 57 + test('alloc returns object', typeof allocResult, 'object'); 58 + test('alloc has arenaSize', typeof allocResult.arenaSize, 'number'); 59 + test('alloc has heapSize', typeof allocResult.heapSize, 'number'); 60 + test('alloc has freeBytes', typeof allocResult.freeBytes, 'number'); 61 + 62 + test('stats is function', typeof Ant.stats, 'function'); 63 + test('raw is object', typeof Ant.raw, 'object'); 64 + test('raw.typeof is function', typeof Ant.raw.typeof, 'function'); 65 + test('serve is function', typeof Ant.serve, 'function'); 66 + test('sleep is function', typeof Ant.sleep, 'function'); 67 + test('msleep is function', typeof Ant.msleep, 'function'); 68 + test('usleep is function', typeof Ant.usleep, 'function'); 69 + test('signal is function', typeof Ant.signal, 'function'); 70 + 71 + summary();
+30
examples/spec/process.js
··· 1 + import { test, summary } from './helpers.js'; 2 + 3 + console.log('Process Tests\n'); 4 + 5 + test('process exists', typeof process, 'object'); 6 + test('process toStringTag', Object.prototype.toString.call(process), '[object process]'); 7 + 8 + test('pid is number', typeof process.pid, 'number'); 9 + test('pid is positive', process.pid > 0, true); 10 + 11 + test('platform is string', typeof process.platform, 'string'); 12 + test('platform valid', ['darwin', 'linux', 'win32', 'freebsd'].includes(process.platform), true); 13 + 14 + test('arch is string', typeof process.arch, 'string'); 15 + test('arch valid', ['x64', 'ia32', 'arm64', 'arm'].includes(process.arch), true); 16 + 17 + test('argv is array', Array.isArray(process.argv), true); 18 + test('argv has entries', process.argv.length >= 1, true); 19 + 20 + test('cwd is function', typeof process.cwd, 'function'); 21 + const cwd = process.cwd(); 22 + test('cwd returns string', typeof cwd, 'string'); 23 + test('cwd not empty', cwd.length > 0, true); 24 + 25 + test('env is object', typeof process.env, 'object'); 26 + test('env has PATH or Path', process.env.PATH !== undefined || process.env.Path !== undefined, true); 27 + 28 + test('exit is function', typeof process.exit, 'function'); 29 + 30 + summary();