xref: /third_party/node/test/parallel/test-runner-string-to-regexp.js
  • Home
  • History
  • Annotate Annotate
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
  • only in /third_party/node/test/parallel/
11cb0ef41Sopenharmony_ci// Flags: --expose-internals
21cb0ef41Sopenharmony_ci'use strict';
31cb0ef41Sopenharmony_ciconst common = require('../common');
41cb0ef41Sopenharmony_ciconst { deepStrictEqual, throws } = require('node:assert');
51cb0ef41Sopenharmony_ciconst { convertStringToRegExp } = require('internal/test_runner/utils');
61cb0ef41Sopenharmony_ci
71cb0ef41Sopenharmony_cideepStrictEqual(convertStringToRegExp('foo', 'x'), /foo/);
81cb0ef41Sopenharmony_cideepStrictEqual(convertStringToRegExp('/bar/', 'x'), /bar/);
91cb0ef41Sopenharmony_cideepStrictEqual(convertStringToRegExp('/baz/gi', 'x'), /baz/gi);
101cb0ef41Sopenharmony_cideepStrictEqual(convertStringToRegExp('/foo/9', 'x'), /\/foo\/9/);
111cb0ef41Sopenharmony_ci
121cb0ef41Sopenharmony_cithrows(
131cb0ef41Sopenharmony_ci  () => convertStringToRegExp('/foo/abcdefghijk', 'x'),
141cb0ef41Sopenharmony_ci  common.expectsError({
151cb0ef41Sopenharmony_ci    code: 'ERR_INVALID_ARG_VALUE',
161cb0ef41Sopenharmony_ci    message: "The argument 'x' is an invalid regular expression. " +
171cb0ef41Sopenharmony_ci             "Invalid flags supplied to RegExp constructor 'abcdefghijk'. " +
181cb0ef41Sopenharmony_ci             "Received '/foo/abcdefghijk'",
191cb0ef41Sopenharmony_ci  })
201cb0ef41Sopenharmony_ci);
21

Indexes created Thu Nov 07 10:32:03 CST 2024