• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1'use strict';
2const common = require('../common');
3const assert = require('assert');
4
5const expected_keys = [
6  'ares',
7  'brotli',
8  'modules',
9  'node',
10  'uv',
11  'v8',
12  'zlib',
13  'nghttp2',
14  'napi',
15  'llhttp',
16];
17
18if (common.hasCrypto) {
19  expected_keys.push('openssl');
20}
21
22if (common.hasIntl) {
23  expected_keys.push('icu');
24  expected_keys.push('cldr');
25  expected_keys.push('tz');
26  expected_keys.push('unicode');
27}
28
29expected_keys.sort();
30const actual_keys = Object.keys(process.versions).sort();
31
32assert.deepStrictEqual(actual_keys, expected_keys);
33
34const commonTemplate = /^\d+\.\d+\.\d+(?:-.*)?$/;
35
36assert(commonTemplate.test(process.versions.ares));
37assert(commonTemplate.test(process.versions.brotli));
38assert(commonTemplate.test(process.versions.llhttp));
39assert(commonTemplate.test(process.versions.node));
40assert(commonTemplate.test(process.versions.uv));
41assert(commonTemplate.test(process.versions.zlib));
42
43assert(/^\d+\.\d+\.\d+(?:\.\d+)?-node\.\d+(?: \(candidate\))?$/
44  .test(process.versions.v8));
45assert(/^\d+$/.test(process.versions.modules));
46
47if (common.hasCrypto) {
48  assert(/^\d+\.\d+\.\d+[a-z]?(-fips)?$/.test(process.versions.openssl));
49}
50
51for (let i = 0; i < expected_keys.length; i++) {
52  const key = expected_keys[i];
53  const descriptor = Object.getOwnPropertyDescriptor(process.versions, key);
54  assert.strictEqual(descriptor.writable, false);
55}
56
57assert.strictEqual(process.config.variables.napi_build_version,
58                   process.versions.napi);
59