Server : nginx/1.20.1 System : Linux ccpf-production-2021 5.4.0-148-generic #165-Ubuntu SMP Tue Apr 18 08:53:12 UTC 2023 x86_64 User : forge ( 1000) PHP Version : 7.4.21 Disable Function : pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_get_handler,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,pcntl_async_signals,pcntl_unshare, Directory : /lib/node_modules/pm2/node_modules/fast-printf/dist/test/fast-printf/ |
"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const ava_1 = __importDefault(require("ava"));
const tokenize_1 = require("../../src/tokenize");
ava_1.default('tokenizes a string without placeholders', (t) => {
t.deepEqual(tokenize_1.tokenize('foo bar'), [
{
literal: 'foo bar',
type: 'literal',
},
]);
});
ava_1.default('tokenizes a string with placeholders (%%)', (t) => {
t.deepEqual(tokenize_1.tokenize('%%'), [
{
literal: '%',
type: 'literal',
},
]);
t.deepEqual(tokenize_1.tokenize('foo %% bar'), [
{
literal: 'foo % bar',
type: 'literal',
},
]);
});
ava_1.default('tokenizes a string with placeholders (%%s)', (t) => {
t.deepEqual(tokenize_1.tokenize('%%s'), [
{
literal: '%s',
type: 'literal',
},
]);
t.deepEqual(tokenize_1.tokenize('foo %%s bar'), [
{
literal: 'foo %s bar',
type: 'literal',
},
]);
});
ava_1.default('tokenizes a string with placeholders (\\%)', (t) => {
t.deepEqual(tokenize_1.tokenize('foo \\% bar'), [
{
literal: 'foo % bar',
type: 'literal',
},
]);
});
ava_1.default('tokenizes a string with a placeholder', (t) => {
t.deepEqual(tokenize_1.tokenize('foo %s bar'), [
{
literal: 'foo ',
type: 'literal',
},
{
conversion: 's',
flag: null,
placeholder: '%s',
position: 0,
precision: null,
type: 'placeholder',
width: null,
},
{
literal: ' bar',
type: 'literal',
},
]);
});
ava_1.default('tokenizes a string with multiple placeholders', (t) => {
t.deepEqual(tokenize_1.tokenize('foo %s %s bar'), [
{
literal: 'foo ',
type: 'literal',
},
{
conversion: 's',
flag: null,
placeholder: '%s',
position: 0,
precision: null,
type: 'placeholder',
width: null,
},
{
literal: ' ',
type: 'literal',
},
{
conversion: 's',
flag: null,
placeholder: '%s',
position: 1,
precision: null,
type: 'placeholder',
width: null,
},
{
literal: ' bar',
type: 'literal',
},
]);
});
ava_1.default('tokenizes a string containing only a placeholder', (t) => {
t.deepEqual(tokenize_1.tokenize('%s'), [
{
conversion: 's',
flag: null,
placeholder: '%s',
position: 0,
precision: null,
type: 'placeholder',
width: null,
},
]);
});
ava_1.default('identifies flag (%+d)', (t) => {
t.deepEqual(tokenize_1.tokenize('%+d'), [
{
conversion: 'd',
flag: '+',
placeholder: '%+d',
position: 0,
precision: null,
type: 'placeholder',
width: null,
},
]);
});
ava_1.default('identifies width (%1d)', (t) => {
t.deepEqual(tokenize_1.tokenize('%1d'), [
{
conversion: 'd',
flag: null,
placeholder: '%1d',
position: 0,
precision: null,
type: 'placeholder',
width: 1,
},
]);
});
ava_1.default('identifies precision (%.1f)', (t) => {
t.deepEqual(tokenize_1.tokenize('%.1f'), [
{
conversion: 'f',
flag: null,
placeholder: '%.1f',
position: 0,
precision: 1,
type: 'placeholder',
width: null,
},
]);
});
ava_1.default('tokenizes positional arguments (%2$s %1$s)', (t) => {
t.deepEqual(tokenize_1.tokenize('%2$s %1$s'), [
{
conversion: 's',
flag: null,
placeholder: '%2$s',
position: 1,
precision: null,
type: 'placeholder',
width: null,
},
{
literal: ' ',
type: 'literal',
},
{
conversion: 's',
flag: null,
placeholder: '%1$s',
position: 0,
precision: null,
type: 'placeholder',
width: null,
},
]);
});